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

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 1017583002: Set Origin header to "null" for cross origin redirects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Addressed nits Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/web_url_loader_impl.h" 5 #include "content/child/web_url_loader_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "content/child/weburlresponse_extradata_impl.h" 27 #include "content/child/weburlresponse_extradata_impl.h"
28 #include "content/common/resource_messages.h" 28 #include "content/common/resource_messages.h"
29 #include "content/common/resource_request_body.h" 29 #include "content/common/resource_request_body.h"
30 #include "content/common/service_worker/service_worker_types.h" 30 #include "content/common/service_worker/service_worker_types.h"
31 #include "content/public/child/request_peer.h" 31 #include "content/public/child/request_peer.h"
32 #include "content/public/common/content_switches.h" 32 #include "content/public/common/content_switches.h"
33 #include "net/base/data_url.h" 33 #include "net/base/data_url.h"
34 #include "net/base/filename_util.h" 34 #include "net/base/filename_util.h"
35 #include "net/base/mime_util.h" 35 #include "net/base/mime_util.h"
36 #include "net/base/net_errors.h" 36 #include "net/base/net_errors.h"
37 #include "net/http/http_request_headers.h"
37 #include "net/http/http_response_headers.h" 38 #include "net/http/http_response_headers.h"
38 #include "net/http/http_util.h" 39 #include "net/http/http_util.h"
39 #include "net/url_request/redirect_info.h" 40 #include "net/url_request/redirect_info.h"
40 #include "net/url_request/url_request_data_job.h" 41 #include "net/url_request/url_request_data_job.h"
41 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" 42 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
43 #include "third_party/WebKit/public/platform/WebString.h"
42 #include "third_party/WebKit/public/platform/WebURL.h" 44 #include "third_party/WebKit/public/platform/WebURL.h"
43 #include "third_party/WebKit/public/platform/WebURLError.h" 45 #include "third_party/WebKit/public/platform/WebURLError.h"
44 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" 46 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h"
45 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 47 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
46 #include "third_party/WebKit/public/platform/WebURLRequest.h" 48 #include "third_party/WebKit/public/platform/WebURLRequest.h"
47 #include "third_party/WebKit/public/platform/WebURLResponse.h" 49 #include "third_party/WebKit/public/platform/WebURLResponse.h"
48 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 50 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
49 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h" 51 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h"
50 52
51 using base::Time; 53 using base::Time;
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 new_request.setFetchCredentialsMode(request_.fetchCredentialsMode()); 557 new_request.setFetchCredentialsMode(request_.fetchCredentialsMode());
556 558
557 new_request.setHTTPReferrer(WebString::fromUTF8(redirect_info.new_referrer), 559 new_request.setHTTPReferrer(WebString::fromUTF8(redirect_info.new_referrer),
558 referrer_policy_); 560 referrer_policy_);
559 561
560 std::string old_method = request_.httpMethod().utf8(); 562 std::string old_method = request_.httpMethod().utf8();
561 new_request.setHTTPMethod(WebString::fromUTF8(redirect_info.new_method)); 563 new_request.setHTTPMethod(WebString::fromUTF8(redirect_info.new_method));
562 if (redirect_info.new_method == old_method) 564 if (redirect_info.new_method == old_method)
563 new_request.setHTTPBody(request_.httpBody()); 565 new_request.setHTTPBody(request_.httpBody());
564 566
567 // This is necessary to avoid laundering the Origin header across redirects,
568 // which would break some CSRF protections. See the comment in
569 // URLRequest::Redirect in //net/url_request.cc for more information.
570 WebString origin_header =
571 WebString::fromUTF8(net::HttpRequestHeaders::kOrigin);
572 new_request.setHTTPHeaderField(origin_header,
573 request_.httpHeaderField(origin_header));
davidben 2015/03/24 23:47:38 I think this does the opposite of what the comment
jww 2015/03/27 22:16:15 Hm, okay, I'm happy to remove it. All of the tests
davidben 2015/03/27 22:46:51 Well, the cases where Blink's version of the reque
574
565 // Protect from deletion during call to willSendRequest. 575 // Protect from deletion during call to willSendRequest.
566 scoped_refptr<Context> protect(this); 576 scoped_refptr<Context> protect(this);
567 577
568 client_->willSendRequest(loader_, new_request, response); 578 client_->willSendRequest(loader_, new_request, response);
569 request_ = new_request; 579 request_ = new_request;
570 580
571 // Only follow the redirect if WebKit left the URL unmodified. 581 // Only follow the redirect if WebKit left the URL unmodified.
572 if (redirect_info.new_url == GURL(new_request.url())) { 582 if (redirect_info.new_url == GURL(new_request.url())) {
573 // First-party cookie logic moved from DocumentLoader in Blink to 583 // First-party cookie logic moved from DocumentLoader in Blink to
574 // net::URLRequest in the browser. Assert that Blink didn't try to change it 584 // net::URLRequest in the browser. Assert that Blink didn't try to change it
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 int intra_priority_value) { 1148 int intra_priority_value) {
1139 context_->DidChangePriority(new_priority, intra_priority_value); 1149 context_->DidChangePriority(new_priority, intra_priority_value);
1140 } 1150 }
1141 1151
1142 bool WebURLLoaderImpl::attachThreadedDataReceiver( 1152 bool WebURLLoaderImpl::attachThreadedDataReceiver(
1143 blink::WebThreadedDataReceiver* threaded_data_receiver) { 1153 blink::WebThreadedDataReceiver* threaded_data_receiver) {
1144 return context_->AttachThreadedDataReceiver(threaded_data_receiver); 1154 return context_->AttachThreadedDataReceiver(threaded_data_receiver);
1145 } 1155 }
1146 1156
1147 } // namespace content 1157 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | net/data/url_request_unittest/redirect301-to-ftp » ('j') | net/url_request/url_request.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698