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

Unified Diff: net/url_request/url_request.cc

Issue 2917133002: Perform redirect checks before OnReceivedRedirect in //net. (Closed)
Patch Set: nasko comments Created 3 years, 6 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.h ('k') | net/url_request/url_request_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request.cc
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index 690bc37fdf7ee3564644791223d481fe5778b4be..148c3e805515557f4cb015d6fd880c5fdc3afe00 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -917,8 +917,12 @@ void URLRequest::PrepareToRestart() {
proxy_server_ = ProxyServer();
}
-int URLRequest::Redirect(const RedirectInfo& redirect_info) {
- // Matches call in NotifyReceivedRedirect.
+void URLRequest::Redirect(const RedirectInfo& redirect_info) {
+ // This method always succeeds. Whether |job_| is allowed to redirect to
+ // |redirect_info| is checked in URLRequestJob::CanFollowRedirect, before
+ // NotifyReceivedRedirect. This means the delegate can assume that, if it
+ // accepted the redirect, future calls to OnResponseStarted correspond to
+ // |redirect_info.new_url|.
OnCallToDelegateComplete();
if (net_log_.IsCapturing()) {
net_log_.AddEvent(
@@ -930,19 +934,6 @@ int URLRequest::Redirect(const RedirectInfo& redirect_info) {
if (network_delegate_)
network_delegate_->NotifyBeforeRedirect(this, redirect_info.new_url);
- if (redirect_limit_ <= 0) {
- DVLOG(1) << "disallowing redirect: exceeds limit";
- return ERR_TOO_MANY_REDIRECTS;
- }
-
- if (!redirect_info.new_url.is_valid())
- return ERR_INVALID_URL;
-
- if (!job_->IsSafeRedirect(redirect_info.new_url)) {
- DVLOG(1) << "disallowing redirect: unsafe protocol";
- return ERR_UNSAFE_REDIRECT;
- }
-
if (!final_upload_progress_.position() && upload_data_stream_)
final_upload_progress_ = upload_data_stream_->GetUploadProgress();
PrepareToRestart();
@@ -997,7 +988,6 @@ int URLRequest::Redirect(const RedirectInfo& redirect_info) {
--redirect_limit_;
Start();
- return OK;
}
const URLRequestContext* URLRequest::context() const {
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698