| 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 12 matching lines...) Expand all Loading... |
| 37 ftp_auth_cache_(ftp_auth_cache) { | 38 ftp_auth_cache_(ftp_auth_cache) { |
| 38 DCHECK(ftp_transaction_factory); | 39 DCHECK(ftp_transaction_factory); |
| 39 DCHECK(ftp_auth_cache); | 40 DCHECK(ftp_auth_cache); |
| 40 } | 41 } |
| 41 | 42 |
| 42 URLRequestFtpJob::~URLRequestFtpJob() { | 43 URLRequestFtpJob::~URLRequestFtpJob() { |
| 43 if (pac_request_) | 44 if (pac_request_) |
| 44 request_->context()->proxy_service()->CancelPacRequest(pac_request_); | 45 request_->context()->proxy_service()->CancelPacRequest(pac_request_); |
| 45 } | 46 } |
| 46 | 47 |
| 47 // static | |
| 48 URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request, | |
| 49 NetworkDelegate* network_delegate, | |
| 50 const std::string& scheme) { | |
| 51 DCHECK_EQ(scheme, "ftp"); | |
| 52 | |
| 53 int port = request->url().IntPort(); | |
| 54 if (request->url().has_port() && | |
| 55 !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) { | |
| 56 return new URLRequestErrorJob(request, | |
| 57 network_delegate, | |
| 58 ERR_UNSAFE_PORT); | |
| 59 } | |
| 60 | |
| 61 return new URLRequestFtpJob(request, | |
| 62 network_delegate, | |
| 63 request->context()->ftp_transaction_factory(), | |
| 64 request->context()->ftp_auth_cache()); | |
| 65 } | |
| 66 | |
| 67 bool URLRequestFtpJob::IsSafeRedirect(const GURL& location) { | 48 bool URLRequestFtpJob::IsSafeRedirect(const GURL& location) { |
| 68 // Disallow all redirects. | 49 // Disallow all redirects. |
| 69 return false; | 50 return false; |
| 70 } | 51 } |
| 71 | 52 |
| 72 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { | 53 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { |
| 73 if (proxy_info_.is_direct()) { | 54 if (proxy_info_.is_direct()) { |
| 74 if (ftp_transaction_->GetResponseInfo()->is_directory_listing) { | 55 if (ftp_transaction_->GetResponseInfo()->is_directory_listing) { |
| 75 *mime_type = "text/vnd.chromium.ftp-dir"; | 56 *mime_type = "text/vnd.chromium.ftp-dir"; |
| 76 return true; | 57 return true; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 if (cached_auth) { | 395 if (cached_auth) { |
| 415 // Retry using cached auth data. | 396 // Retry using cached auth data. |
| 416 SetAuth(cached_auth->credentials); | 397 SetAuth(cached_auth->credentials); |
| 417 } else { | 398 } else { |
| 418 // Prompt for a username/password. | 399 // Prompt for a username/password. |
| 419 NotifyHeadersComplete(); | 400 NotifyHeadersComplete(); |
| 420 } | 401 } |
| 421 } | 402 } |
| 422 | 403 |
| 423 } // namespace net | 404 } // namespace net |
| OLD | NEW |