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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 // some decoding, as some proxies strip encoding completely. In such cases, | 1043 // some decoding, as some proxies strip encoding completely. In such cases, |
1043 // we may need to add (for example) SDCH filtering (when the context suggests | 1044 // we may need to add (for example) SDCH filtering (when the context suggests |
1044 // it is appropriate). | 1045 // it is appropriate). |
1045 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); | 1046 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); |
1046 | 1047 |
1047 return !encoding_types.empty() | 1048 return !encoding_types.empty() |
1048 ? Filter::Factory(encoding_types, *filter_context_) : NULL; | 1049 ? Filter::Factory(encoding_types, *filter_context_) : NULL; |
1049 } | 1050 } |
1050 | 1051 |
1051 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { | 1052 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { |
1052 // We only allow redirects to certain "safe" protocols. This does not | 1053 // HTTP is always safe. |
1053 // restrict redirects to externally handled protocols. Our consumer would | 1054 // TODO(pauljensen): Remove once crbug.com/146591 is fixed. |
1054 // need to take care of those. | 1055 if (location.is_valid() && |
1055 | 1056 (location.scheme() == "http" || location.scheme() == "https")) { |
1056 if (!URLRequest::IsHandledURL(location)) | |
1057 return true; | 1057 return true; |
1058 | |
1059 static const char* kSafeSchemes[] = { | |
1060 "http", | |
1061 "https", | |
1062 "ftp" | |
1063 }; | |
1064 | |
1065 for (size_t i = 0; i < arraysize(kSafeSchemes); ++i) { | |
1066 if (location.SchemeIs(kSafeSchemes[i])) | |
1067 return true; | |
1068 } | 1058 } |
1069 | 1059 // Query URLRequestJobFactory as to whether |location| would be safe to |
1070 return false; | 1060 // redirect to. |
| 1061 return request_->context()->job_factory() && |
| 1062 request_->context()->job_factory()->IsSafeRedirectTarget(location); |
1071 } | 1063 } |
1072 | 1064 |
1073 bool URLRequestHttpJob::NeedsAuth() { | 1065 bool URLRequestHttpJob::NeedsAuth() { |
1074 int code = GetResponseCode(); | 1066 int code = GetResponseCode(); |
1075 if (code == -1) | 1067 if (code == -1) |
1076 return false; | 1068 return false; |
1077 | 1069 |
1078 // Check if we need either Proxy or WWW Authentication. This could happen | 1070 // Check if we need either Proxy or WWW Authentication. This could happen |
1079 // because we either provided no auth info, or provided incorrect info. | 1071 // because we either provided no auth info, or provided incorrect info. |
1080 switch (code) { | 1072 switch (code) { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 | 1462 |
1471 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1463 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1472 awaiting_callback_ = false; | 1464 awaiting_callback_ = false; |
1473 } | 1465 } |
1474 | 1466 |
1475 void URLRequestHttpJob::OnDetachRequest() { | 1467 void URLRequestHttpJob::OnDetachRequest() { |
1476 http_transaction_delegate_->OnDetachRequest(); | 1468 http_transaction_delegate_->OnDetachRequest(); |
1477 } | 1469 } |
1478 | 1470 |
1479 } // namespace net | 1471 } // namespace net |
OLD | NEW |