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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc

Issue 603323002: Maybe add CORS headers to data reduction proxy redirect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" 9 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
10 #include "components/data_reduction_proxy/browser/data_reduction_proxy_tamper_de tection.h" 10 #include "components/data_reduction_proxy/browser/data_reduction_proxy_tamper_de tection.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 request->SetLoadFlags(request->load_flags() | 176 request->SetLoadFlags(request->load_flags() |
177 net::LOAD_DISABLE_CACHE | 177 net::LOAD_DISABLE_CACHE |
178 net::LOAD_BYPASS_PROXY); 178 net::LOAD_BYPASS_PROXY);
179 *override_response_headers = new net::HttpResponseHeaders( 179 *override_response_headers = new net::HttpResponseHeaders(
180 original_response_headers->raw_headers()); 180 original_response_headers->raw_headers());
181 (*override_response_headers)->ReplaceStatusLine("HTTP/1.1 302 Found"); 181 (*override_response_headers)->ReplaceStatusLine("HTTP/1.1 302 Found");
182 (*override_response_headers)->RemoveHeader("Location"); 182 (*override_response_headers)->RemoveHeader("Location");
183 (*override_response_headers)->AddHeader("Location: " + 183 (*override_response_headers)->AddHeader("Location: " +
184 request->url().spec()); 184 request->url().spec());
185 std::string http_origin;
186 const net::HttpRequestHeaders& request_headers =
187 request->extra_request_headers();
188 if (request_headers.GetHeader("Origin", &http_origin)) {
189 // If this redirect is used in a cross-origin request, add CORS headers to
190 // make sure that the redirect gets through. Note that the destination URL
191 // is still subject to the usual CORS policy, i.e. the resource will only
192 // be available to web pages if the server serves the response with the
193 // required CORS response headers.
194 (*override_response_headers)->AddHeader(
195 "Access-Control-Allow-Origin: " + http_origin);
196 (*override_response_headers)->AddHeader(
197 "Access-Control-Allow-Credentials: true");
198 }
185 // TODO(bengr): Should we pop_back the request->url_chain? 199 // TODO(bengr): Should we pop_back the request->url_chain?
186 } 200 }
187 201
188 void MarkProxiesAsBadUntil( 202 void MarkProxiesAsBadUntil(
189 net::URLRequest* request, 203 net::URLRequest* request,
190 base::TimeDelta& bypass_duration, 204 base::TimeDelta& bypass_duration,
191 bool bypass_all, 205 bool bypass_all,
192 const std::pair<GURL, GURL>& data_reduction_proxies) { 206 const std::pair<GURL, GURL>& data_reduction_proxies) {
193 DCHECK(!data_reduction_proxies.first.is_empty()); 207 DCHECK(!data_reduction_proxies.first.is_empty());
194 // Synthesize a suitable |ProxyInfo| to add the proxies to the 208 // Synthesize a suitable |ProxyInfo| to add the proxies to the
(...skipping 17 matching lines...) Expand all
212 net::ProxyService* proxy_service = request->context()->proxy_service(); 226 net::ProxyService* proxy_service = request->context()->proxy_service();
213 DCHECK(proxy_service); 227 DCHECK(proxy_service);
214 228
215 proxy_service->MarkProxiesAsBadUntil(proxy_info, 229 proxy_service->MarkProxiesAsBadUntil(proxy_info,
216 bypass_duration, 230 bypass_duration,
217 fallback, 231 fallback,
218 request->net_log()); 232 request->net_log());
219 } 233 }
220 234
221 } // namespace data_reduction_proxy 235 } // namespace data_reduction_proxy
OLDNEW
« no previous file with comments | « no previous file | components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698