| 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_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "net/http/http_transaction_delegate.h" | 36 #include "net/http/http_transaction_delegate.h" |
| 37 #include "net/http/http_transaction_factory.h" | 37 #include "net/http/http_transaction_factory.h" |
| 38 #include "net/http/http_util.h" | 38 #include "net/http/http_util.h" |
| 39 #include "net/ssl/ssl_cert_request_info.h" | 39 #include "net/ssl/ssl_cert_request_info.h" |
| 40 #include "net/ssl/ssl_config_service.h" | 40 #include "net/ssl/ssl_config_service.h" |
| 41 #include "net/url_request/fraudulent_certificate_reporter.h" | 41 #include "net/url_request/fraudulent_certificate_reporter.h" |
| 42 #include "net/url_request/http_user_agent_settings.h" | 42 #include "net/url_request/http_user_agent_settings.h" |
| 43 #include "net/url_request/url_request.h" | 43 #include "net/url_request/url_request.h" |
| 44 #include "net/url_request/url_request_context.h" | 44 #include "net/url_request/url_request_context.h" |
| 45 #include "net/url_request/url_request_error_job.h" | 45 #include "net/url_request/url_request_error_job.h" |
| 46 #include "net/url_request/url_request_job_factory.h" |
| 46 #include "net/url_request/url_request_redirect_job.h" | 47 #include "net/url_request/url_request_redirect_job.h" |
| 47 #include "net/url_request/url_request_throttler_header_adapter.h" | 48 #include "net/url_request/url_request_throttler_header_adapter.h" |
| 48 #include "net/url_request/url_request_throttler_manager.h" | 49 #include "net/url_request/url_request_throttler_manager.h" |
| 49 | 50 |
| 50 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; | 51 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; |
| 51 | 52 |
| 52 namespace net { | 53 namespace net { |
| 53 | 54 |
| 54 class URLRequestHttpJob::HttpFilterContext : public FilterContext { | 55 class URLRequestHttpJob::HttpFilterContext : public FilterContext { |
| 55 public: | 56 public: |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 // some decoding, as some proxies strip encoding completely. In such cases, | 1045 // some decoding, as some proxies strip encoding completely. In such cases, |
| 1045 // we may need to add (for example) SDCH filtering (when the context suggests | 1046 // we may need to add (for example) SDCH filtering (when the context suggests |
| 1046 // it is appropriate). | 1047 // it is appropriate). |
| 1047 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); | 1048 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); |
| 1048 | 1049 |
| 1049 return !encoding_types.empty() | 1050 return !encoding_types.empty() |
| 1050 ? Filter::Factory(encoding_types, *filter_context_) : NULL; | 1051 ? Filter::Factory(encoding_types, *filter_context_) : NULL; |
| 1051 } | 1052 } |
| 1052 | 1053 |
| 1053 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { | 1054 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { |
| 1054 // We only allow redirects to certain "safe" protocols. This does not | 1055 // HTTP is always safe. |
| 1055 // restrict redirects to externally handled protocols. Our consumer would | 1056 // TODO(pauljensen): Remove once crbug.com/146591 is fixed. |
| 1056 // need to take care of those. | 1057 if (location.is_valid() && |
| 1057 | 1058 (location.scheme() == "http" || location.scheme() == "https")) { |
| 1058 if (!URLRequest::IsHandledURL(location)) | |
| 1059 return true; | 1059 return true; |
| 1060 | |
| 1061 static const char* kSafeSchemes[] = { | |
| 1062 "http", | |
| 1063 "https", | |
| 1064 "ftp" | |
| 1065 }; | |
| 1066 | |
| 1067 for (size_t i = 0; i < arraysize(kSafeSchemes); ++i) { | |
| 1068 if (location.SchemeIs(kSafeSchemes[i])) | |
| 1069 return true; | |
| 1070 } | 1060 } |
| 1071 | 1061 // Query URLRequestJobFactory as to whether |location| would be safe to |
| 1072 return false; | 1062 // redirect to. |
| 1063 return request_->context()->job_factory() && |
| 1064 request_->context()->job_factory()->IsSafeRedirectTarget(location); |
| 1073 } | 1065 } |
| 1074 | 1066 |
| 1075 bool URLRequestHttpJob::NeedsAuth() { | 1067 bool URLRequestHttpJob::NeedsAuth() { |
| 1076 int code = GetResponseCode(); | 1068 int code = GetResponseCode(); |
| 1077 if (code == -1) | 1069 if (code == -1) |
| 1078 return false; | 1070 return false; |
| 1079 | 1071 |
| 1080 // Check if we need either Proxy or WWW Authentication. This could happen | 1072 // Check if we need either Proxy or WWW Authentication. This could happen |
| 1081 // because we either provided no auth info, or provided incorrect info. | 1073 // because we either provided no auth info, or provided incorrect info. |
| 1082 switch (code) { | 1074 switch (code) { |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 | 1464 |
| 1473 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1465 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1474 awaiting_callback_ = false; | 1466 awaiting_callback_ = false; |
| 1475 } | 1467 } |
| 1476 | 1468 |
| 1477 void URLRequestHttpJob::OnDetachRequest() { | 1469 void URLRequestHttpJob::OnDetachRequest() { |
| 1478 http_transaction_delegate_->OnDetachRequest(); | 1470 http_transaction_delegate_->OnDetachRequest(); |
| 1479 } | 1471 } |
| 1480 | 1472 |
| 1481 } // namespace net | 1473 } // namespace net |
| OLD | NEW |