Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: trunk/src/net/url_request/url_request_http_job.cc

Issue 12605011: Revert 188912 "Removed static factories for data, ftp, file, and..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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"
47 #include "net/url_request/url_request_redirect_job.h" 46 #include "net/url_request/url_request_redirect_job.h"
48 #include "net/url_request/url_request_throttler_header_adapter.h" 47 #include "net/url_request/url_request_throttler_header_adapter.h"
49 #include "net/url_request/url_request_throttler_manager.h" 48 #include "net/url_request/url_request_throttler_manager.h"
50 49
51 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; 50 static const char kAvailDictionaryHeader[] = "Avail-Dictionary";
52 51
53 namespace net { 52 namespace net {
54 53
55 class URLRequestHttpJob::HttpFilterContext : public FilterContext { 54 class URLRequestHttpJob::HttpFilterContext : public FilterContext {
56 public: 55 public:
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 // some decoding, as some proxies strip encoding completely. In such cases, 1006 // some decoding, as some proxies strip encoding completely. In such cases,
1008 // we may need to add (for example) SDCH filtering (when the context suggests 1007 // we may need to add (for example) SDCH filtering (when the context suggests
1009 // it is appropriate). 1008 // it is appropriate).
1010 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); 1009 Filter::FixupEncodingTypes(*filter_context_, &encoding_types);
1011 1010
1012 return !encoding_types.empty() 1011 return !encoding_types.empty()
1013 ? Filter::Factory(encoding_types, *filter_context_) : NULL; 1012 ? Filter::Factory(encoding_types, *filter_context_) : NULL;
1014 } 1013 }
1015 1014
1016 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { 1015 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) {
1017 // HTTP is always safe. 1016 // We only allow redirects to certain "safe" protocols. This does not
1018 // TODO(pauljensen): Remove once crbug.com/146591 is fixed. 1017 // restrict redirects to externally handled protocols. Our consumer would
1019 if (location.is_valid() && 1018 // need to take care of those.
1020 (location.scheme() == "http" || location.scheme() == "https")) { 1019
1020 if (!URLRequest::IsHandledURL(location))
1021 return true; 1021 return true;
1022
1023 static const char* kSafeSchemes[] = {
1024 "http",
1025 "https",
1026 "ftp"
1027 };
1028
1029 for (size_t i = 0; i < arraysize(kSafeSchemes); ++i) {
1030 if (location.SchemeIs(kSafeSchemes[i]))
1031 return true;
1022 } 1032 }
1023 // Query URLRequestJobFactory as to whether |location| would be safe to 1033
1024 // redirect to. 1034 return false;
1025 return request_->context()->job_factory() &&
1026 request_->context()->job_factory()->IsSafeRedirectTarget(location);
1027 } 1035 }
1028 1036
1029 bool URLRequestHttpJob::NeedsAuth() { 1037 bool URLRequestHttpJob::NeedsAuth() {
1030 int code = GetResponseCode(); 1038 int code = GetResponseCode();
1031 if (code == -1) 1039 if (code == -1)
1032 return false; 1040 return false;
1033 1041
1034 // Check if we need either Proxy or WWW Authentication. This could happen 1042 // Check if we need either Proxy or WWW Authentication. This could happen
1035 // because we either provided no auth info, or provided incorrect info. 1043 // because we either provided no auth info, or provided incorrect info.
1036 switch (code) { 1044 switch (code) {
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 1570
1563 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1571 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1564 awaiting_callback_ = false; 1572 awaiting_callback_ = false;
1565 } 1573 }
1566 1574
1567 void URLRequestHttpJob::OnDetachRequest() { 1575 void URLRequestHttpJob::OnDetachRequest() {
1568 http_transaction_delegate_->OnDetachRequest(); 1576 http_transaction_delegate_->OnDetachRequest();
1569 } 1577 }
1570 1578
1571 } // namespace net 1579 } // namespace net
OLDNEW
« no previous file with comments | « trunk/src/net/url_request/url_request_ftp_job_unittest.cc ('k') | trunk/src/net/url_request/url_request_job_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698