| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/url_request/url_request_ftp_job.h" | 5 #include "net/url_request/url_request_ftp_job.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
| 11 #include "net/base/host_port_pair.h" | 11 #include "net/base/host_port_pair.h" |
| 12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
| 15 #include "net/ftp/ftp_auth_cache.h" |
| 15 #include "net/ftp/ftp_response_info.h" | 16 #include "net/ftp/ftp_response_info.h" |
| 16 #include "net/ftp/ftp_transaction_factory.h" | 17 #include "net/ftp/ftp_transaction_factory.h" |
| 17 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
| 18 #include "net/http/http_transaction_factory.h" | 19 #include "net/http/http_transaction_factory.h" |
| 19 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
| 20 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
| 21 #include "net/url_request/url_request_error_job.h" | 22 #include "net/url_request/url_request_error_job.h" |
| 22 | 23 |
| 23 namespace net { | 24 namespace net { |
| 24 | 25 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 DCHECK(proxy_service_); | 40 DCHECK(proxy_service_); |
| 40 DCHECK(ftp_transaction_factory); | 41 DCHECK(ftp_transaction_factory); |
| 41 DCHECK(ftp_auth_cache); | 42 DCHECK(ftp_auth_cache); |
| 42 } | 43 } |
| 43 | 44 |
| 44 URLRequestFtpJob::~URLRequestFtpJob() { | 45 URLRequestFtpJob::~URLRequestFtpJob() { |
| 45 if (pac_request_) | 46 if (pac_request_) |
| 46 proxy_service_->CancelPacRequest(pac_request_); | 47 proxy_service_->CancelPacRequest(pac_request_); |
| 47 } | 48 } |
| 48 | 49 |
| 49 // static | |
| 50 URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request, | |
| 51 NetworkDelegate* network_delegate, | |
| 52 const std::string& scheme) { | |
| 53 DCHECK_EQ(scheme, "ftp"); | |
| 54 | |
| 55 int port = request->url().IntPort(); | |
| 56 if (request->url().has_port() && | |
| 57 !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) { | |
| 58 return new URLRequestErrorJob(request, | |
| 59 network_delegate, | |
| 60 ERR_UNSAFE_PORT); | |
| 61 } | |
| 62 | |
| 63 return new URLRequestFtpJob(request, | |
| 64 network_delegate, | |
| 65 request->context()->ftp_transaction_factory(), | |
| 66 request->context()->ftp_auth_cache()); | |
| 67 } | |
| 68 | |
| 69 bool URLRequestFtpJob::IsSafeRedirect(const GURL& location) { | 50 bool URLRequestFtpJob::IsSafeRedirect(const GURL& location) { |
| 70 // Disallow all redirects. | 51 // Disallow all redirects. |
| 71 return false; | 52 return false; |
| 72 } | 53 } |
| 73 | 54 |
| 74 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { | 55 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { |
| 75 if (proxy_info_.is_direct()) { | 56 if (proxy_info_.is_direct()) { |
| 76 if (ftp_transaction_->GetResponseInfo()->is_directory_listing) { | 57 if (ftp_transaction_->GetResponseInfo()->is_directory_listing) { |
| 77 *mime_type = "text/vnd.chromium.ftp-dir"; | 58 *mime_type = "text/vnd.chromium.ftp-dir"; |
| 78 return true; | 59 return true; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 if (cached_auth) { | 398 if (cached_auth) { |
| 418 // Retry using cached auth data. | 399 // Retry using cached auth data. |
| 419 SetAuth(cached_auth->credentials); | 400 SetAuth(cached_auth->credentials); |
| 420 } else { | 401 } else { |
| 421 // Prompt for a username/password. | 402 // Prompt for a username/password. |
| 422 NotifyHeadersComplete(); | 403 NotifyHeadersComplete(); |
| 423 } | 404 } |
| 424 } | 405 } |
| 425 | 406 |
| 426 } // namespace net | 407 } // namespace net |
| OLD | NEW |