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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_protocol.cc

Issue 686343002: Add MaybeInterceptRedirect/Response to URLRequestInterceptor (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 side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_protocol.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_protocol.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_protocol.cc
index b5212813b1f4389272ccb0cf4b5725b897ed7baf..2964bfa3093553a2a08ec5cb45256694ed3b0657 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_protocol.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_protocol.cc
@@ -44,7 +44,6 @@ bool MaybeBypassProxyAndPrepareToRetry(
const DataReductionProxyParams* data_reduction_proxy_params,
net::URLRequest* request,
const net::HttpResponseHeaders* original_response_headers,
- scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
DataReductionProxyBypassType* proxy_bypass_type) {
if (!data_reduction_proxy_params)
return false;
@@ -125,15 +124,15 @@ bool MaybeBypassProxyAndPrepareToRetry(
data_reduction_proxy_info.bypass_duration,
data_reduction_proxy_info.bypass_all,
data_reduction_proxy_type_info.proxy_servers);
+ } else {
+ request->SetLoadFlags(request->load_flags() |
+ net::LOAD_DISABLE_CACHE |
+ net::LOAD_BYPASS_PROXY);
}
// Only retry idempotent methods.
if (!IsRequestIdempotent(request))
return false;
-
- OverrideResponseAsRedirect(request,
- original_response_headers,
- override_response_headers);
return true;
}
@@ -175,40 +174,6 @@ bool IsRequestIdempotent(const net::URLRequest* request) {
return false;
}
-void OverrideResponseAsRedirect(
- net::URLRequest* request,
- const net::HttpResponseHeaders* original_response_headers,
- scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
- DCHECK(request);
- DCHECK(original_response_headers);
- DCHECK(override_response_headers->get() == NULL);
-
- request->SetLoadFlags(request->load_flags() |
- net::LOAD_DISABLE_CACHE |
- net::LOAD_BYPASS_PROXY);
- *override_response_headers = new net::HttpResponseHeaders(
- original_response_headers->raw_headers());
- (*override_response_headers)->ReplaceStatusLine("HTTP/1.1 302 Found");
- (*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?
-}
-
void MarkProxiesAsBadUntil(
net::URLRequest* request,
base::TimeDelta& bypass_duration,

Powered by Google App Engine
This is Rietveld 408576698