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

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

Issue 2860323002: net: add IsMethodSafe() method to HttpUtil (Closed)
Patch Set: remove IsMethodSafe() from generic_url_request_job.cc Created 3 years, 7 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
« no previous file with comments | « net/http/http_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 7 #include <vector>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "url/origin.h" 70 #include "url/origin.h"
71 71
72 #if defined(OS_ANDROID) 72 #if defined(OS_ANDROID)
73 #include "net/android/network_library.h" 73 #include "net/android/network_library.h"
74 #endif 74 #endif
75 75
76 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; 76 static const char kAvailDictionaryHeader[] = "Avail-Dictionary";
77 77
78 namespace { 78 namespace {
79 79
80 // True if the request method is "safe" (per section 4.2.1 of RFC 7231).
81 bool IsMethodSafe(const std::string& method) {
82 return method == "GET" || method == "HEAD" || method == "OPTIONS" ||
83 method == "TRACE";
84 }
85
86 // Logs whether the CookieStore used for this request matches the 80 // Logs whether the CookieStore used for this request matches the
87 // ChannelIDService used when establishing the connection that this request is 81 // ChannelIDService used when establishing the connection that this request is
88 // sent over. This logging is only done for requests to accounts.google.com, and 82 // sent over. This logging is only done for requests to accounts.google.com, and
89 // only for requests where Channel ID was sent when establishing the connection. 83 // only for requests where Channel ID was sent when establishing the connection.
90 void LogChannelIDAndCookieStores(const GURL& url, 84 void LogChannelIDAndCookieStores(const GURL& url,
91 const net::URLRequestContext* context, 85 const net::URLRequestContext* context,
92 const net::SSLInfo& ssl_info) { 86 const net::SSLInfo& ssl_info) {
93 if (url.host() != "accounts.google.com" || !ssl_info.channel_id_sent) 87 if (url.host() != "accounts.google.com" || !ssl_info.channel_id_sent)
94 return; 88 return;
95 // This enum is used for an UMA histogram - don't reuse or renumber entries. 89 // This enum is used for an UMA histogram - don't reuse or renumber entries.
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 // * Otherwise, do not include same-site cookies. 691 // * Otherwise, do not include same-site cookies.
698 if (registry_controlled_domains::SameDomainOrHost( 692 if (registry_controlled_domains::SameDomainOrHost(
699 request_->url(), request_->first_party_for_cookies(), 693 request_->url(), request_->first_party_for_cookies(),
700 registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) { 694 registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) {
701 if (!request_->initiator() || 695 if (!request_->initiator() ||
702 registry_controlled_domains::SameDomainOrHost( 696 registry_controlled_domains::SameDomainOrHost(
703 request_->url(), request_->initiator().value().GetURL(), 697 request_->url(), request_->initiator().value().GetURL(),
704 registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) { 698 registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) {
705 options.set_same_site_cookie_mode( 699 options.set_same_site_cookie_mode(
706 CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX); 700 CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX);
707 } else if (IsMethodSafe(request_->method())) { 701 } else if (HttpUtil::IsMethodSafe(request_->method())) {
708 options.set_same_site_cookie_mode( 702 options.set_same_site_cookie_mode(
709 CookieOptions::SameSiteCookieMode::INCLUDE_LAX); 703 CookieOptions::SameSiteCookieMode::INCLUDE_LAX);
710 } 704 }
711 } 705 }
712 706
713 cookie_store->GetCookieListWithOptionsAsync( 707 cookie_store->GetCookieListWithOptionsAsync(
714 request_->url(), options, 708 request_->url(), options,
715 base::Bind(&URLRequestHttpJob::SetCookieHeaderAndStart, 709 base::Bind(&URLRequestHttpJob::SetCookieHeaderAndStart,
716 weak_factory_.GetWeakPtr())); 710 weak_factory_.GetWeakPtr()));
717 } else { 711 } else {
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 awaiting_callback_ = false; 1574 awaiting_callback_ = false;
1581 1575
1582 // Notify NetworkQualityEstimator. 1576 // Notify NetworkQualityEstimator.
1583 NetworkQualityEstimator* network_quality_estimator = 1577 NetworkQualityEstimator* network_quality_estimator =
1584 request()->context()->network_quality_estimator(); 1578 request()->context()->network_quality_estimator();
1585 if (network_quality_estimator) 1579 if (network_quality_estimator)
1586 network_quality_estimator->NotifyURLRequestDestroyed(*request()); 1580 network_quality_estimator->NotifyURLRequestDestroyed(*request());
1587 } 1581 }
1588 1582
1589 } // namespace net 1583 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698