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

Unified 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, 3 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc
index b638c2cfe5fa5a1f27604bae2c1553d7d33f4ccb..f0afdc4234b34dcb5aeb0c236bdc58aea11e4eb4 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc
@@ -182,6 +182,20 @@ void OverrideResponseAsRedirect(
(*override_response_headers)->RemoveHeader("Location");
(*override_response_headers)->AddHeader("Location: " +
request->url().spec());
+ std::string http_origin;
+ const net::HttpRequestHeaders& request_headers =
+ request->extra_request_headers();
+ if (request_headers.GetHeader("Origin", &http_origin)) {
+ // If this redirect is used in a cross-origin request, add CORS headers to
+ // make sure that the redirect gets through. Note that the destination URL
+ // is still subject to the usual CORS policy, i.e. the resource will only
+ // be available to web pages if the server serves the response with the
+ // required CORS response headers.
+ (*override_response_headers)->AddHeader(
+ "Access-Control-Allow-Origin: " + http_origin);
+ (*override_response_headers)->AddHeader(
+ "Access-Control-Allow-Credentials: true");
+ }
// TODO(bengr): Should we pop_back the request->url_chain?
}
« 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