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

Unified Diff: net/url_request/url_request_http_job.cc

Issue 154473002: Support redirectUrl at onHeadersReceived in WebRequest / DWR API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix WebRequestRulesRegistrySimpleTest.StageChecker test Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_http_job.cc
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 56fed937e3b6fb781de75d205b3f59b32c0ee796..96609344ae500bfd4b7f60e05c25cf05d90e4d47 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -812,11 +812,13 @@ void URLRequestHttpJob::OnStartCompleted(int result) {
// |on_headers_received_callback_| or
// |NetworkDelegate::URLRequestDestroyed()| has been called.
OnCallToDelegate();
+ allowed_unsafe_redirect_url_ = GURL();
int error = network_delegate()->NotifyHeadersReceived(
request_,
on_headers_received_callback_,
headers.get(),
- &override_response_headers_);
+ &override_response_headers_,
+ &allowed_unsafe_redirect_url_);
if (error != net::OK) {
if (error == net::ERR_IO_PENDING) {
awaiting_callback_ = true;
@@ -1044,6 +1046,15 @@ bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) {
(location.scheme() == "http" || location.scheme() == "https")) {
return true;
}
+ // Delegates may mark an URL as safe for redirection.
+ if (allowed_unsafe_redirect_url_.is_valid()) {
+ GURL::Replacements replacements;
+ replacements.ClearRef();
+ if (allowed_unsafe_redirect_url_.ReplaceComponents(replacements) ==
+ location.ReplaceComponents(replacements)) {
+ return true;
+ }
+ }
// Query URLRequestJobFactory as to whether |location| would be safe to
// redirect to.
return request_->context()->job_factory() &&
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698