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

Side by Side Diff: net/url_request/url_request.cc

Issue 159034: Change URLRequest to return net::ERR_INVALID_URL on redirects to invalid urls. (Closed)
Patch Set: Address minor nits. Created 11 years, 5 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "net/url_request/url_request.h" 5 #include "net/url_request/url_request.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/process_util.h" 8 #include "base/process_util.h"
9 #include "base/singleton.h" 9 #include "base/singleton.h"
10 #include "base/stats_counters.h" 10 #include "base/stats_counters.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 return net::HttpUtil::StripHeaders( 395 return net::HttpUtil::StripHeaders(
396 headers, kPostHeaders, arraysize(kPostHeaders)); 396 headers, kPostHeaders, arraysize(kPostHeaders));
397 } 397 }
398 398
399 int URLRequest::Redirect(const GURL& location, int http_status_code) { 399 int URLRequest::Redirect(const GURL& location, int http_status_code) {
400 if (redirect_limit_ <= 0) { 400 if (redirect_limit_ <= 0) {
401 DLOG(INFO) << "disallowing redirect: exceeds limit"; 401 DLOG(INFO) << "disallowing redirect: exceeds limit";
402 return net::ERR_TOO_MANY_REDIRECTS; 402 return net::ERR_TOO_MANY_REDIRECTS;
403 } 403 }
404 404
405 if (!location.is_valid())
406 return net::ERR_INVALID_URL;
407
405 if (!job_->IsSafeRedirect(location)) { 408 if (!job_->IsSafeRedirect(location)) {
406 DLOG(INFO) << "disallowing redirect: unsafe protocol"; 409 DLOG(INFO) << "disallowing redirect: unsafe protocol";
407 return net::ERR_UNSAFE_REDIRECT; 410 return net::ERR_UNSAFE_REDIRECT;
408 } 411 }
409 412
410 bool strip_post_specific_headers = false; 413 bool strip_post_specific_headers = false;
411 if (http_status_code != 307) { 414 if (http_status_code != 307) {
412 // NOTE: Even though RFC 2616 says to preserve the request method when 415 // NOTE: Even though RFC 2616 says to preserve the request method when
413 // following a 302 redirect, normal browsers don't do that. Instead, they 416 // following a 302 redirect, normal browsers don't do that. Instead, they
414 // all convert a POST into a GET in response to a 302 and so shall we. For 417 // all convert a POST into a GET in response to a 302 and so shall we. For
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } 477 }
475 478
476 #ifndef NDEBUG 479 #ifndef NDEBUG
477 480
478 URLRequestMetrics::~URLRequestMetrics() { 481 URLRequestMetrics::~URLRequestMetrics() {
479 DLOG_IF(WARNING, object_count != 0) << 482 DLOG_IF(WARNING, object_count != 0) <<
480 "Leaking " << object_count << " URLRequest object(s)"; 483 "Leaking " << object_count << " URLRequest object(s)";
481 } 484 }
482 485
483 #endif 486 #endif
OLDNEW
« no previous file with comments | « net/data/url_request_unittest/redirect-to-invalid-url.html.mock-http-headers ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698