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

Side by Side 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: Add more tests 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return; 282 return;
283 283
284 weak_factory_.InvalidateWeakPtrs(); 284 weak_factory_.InvalidateWeakPtrs();
285 DestroyTransaction(); 285 DestroyTransaction();
286 URLRequestJob::Kill(); 286 URLRequestJob::Kill();
287 } 287 }
288 288
289 void URLRequestHttpJob::NotifyHeadersComplete() { 289 void URLRequestHttpJob::NotifyHeadersComplete() {
290 DCHECK(!response_info_); 290 DCHECK(!response_info_);
291 291
292 if (GetResponseHeaders()->HasSafeRedirect()) {
293 // Do not store non-server-issued redirects in cache.
294 transaction_->StopCaching();
mmenke 2014/03/20 15:22:25 I don't think we actually need this. My cache com
robwu 2014/03/20 16:21:11 DoneReading() just calls DoneWritingToEntry(true);
mmenke 2014/03/20 16:40:28 We should have a test for that, too, then. Does t
mmenke 2014/03/20 17:22:38 Turns out this is a bug added back in September by
robwu 2014/03/20 17:28:14 Okay, great! Do you think whether it's acceptable
295 }
296
292 response_info_ = transaction_->GetResponseInfo(); 297 response_info_ = transaction_->GetResponseInfo();
293 298
294 // Save boolean, as we'll need this info at destruction time, and filters may 299 // Save boolean, as we'll need this info at destruction time, and filters may
295 // also need this info. 300 // also need this info.
296 is_cached_content_ = response_info_->was_cached; 301 is_cached_content_ = response_info_->was_cached;
297 302
298 if (!is_cached_content_ && throttling_entry_.get()) { 303 if (!is_cached_content_ && throttling_entry_.get()) {
299 URLRequestThrottlerHeaderAdapter response_adapter(GetResponseHeaders()); 304 URLRequestThrottlerHeaderAdapter response_adapter(GetResponseHeaders());
300 throttling_entry_->UpdateWithResponse(request_info_.url.host(), 305 throttling_entry_->UpdateWithResponse(request_info_.url.host(),
301 &response_adapter); 306 &response_adapter);
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 ? Filter::Factory(encoding_types, *filter_context_) : NULL; 1035 ? Filter::Factory(encoding_types, *filter_context_) : NULL;
1031 } 1036 }
1032 1037
1033 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { 1038 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) {
1034 // HTTP is always safe. 1039 // HTTP is always safe.
1035 // TODO(pauljensen): Remove once crbug.com/146591 is fixed. 1040 // TODO(pauljensen): Remove once crbug.com/146591 is fixed.
1036 if (location.is_valid() && 1041 if (location.is_valid() &&
1037 (location.scheme() == "http" || location.scheme() == "https")) { 1042 (location.scheme() == "http" || location.scheme() == "https")) {
1038 return true; 1043 return true;
1039 } 1044 }
1045 if (GetResponseHeaders()->IsSafeRedirect(location)) {
mmenke 2014/03/20 15:22:25 I don't think this should be part of the headers,
robwu 2014/03/20 16:21:11 So, basically the situation from patch set 1? Then
mmenke 2014/03/20 16:40:28 We allow overriding the entire headers, so I don't
robwu 2014/03/20 17:28:14 After re-reading your previous comment, I see that
mmenke 2014/03/20 17:31:59 Not sure you're completely following me... Here's
1046 return true;
1047 }
1040 // Query URLRequestJobFactory as to whether |location| would be safe to 1048 // Query URLRequestJobFactory as to whether |location| would be safe to
1041 // redirect to. 1049 // redirect to.
1042 return request_->context()->job_factory() && 1050 return request_->context()->job_factory() &&
1043 request_->context()->job_factory()->IsSafeRedirectTarget(location); 1051 request_->context()->job_factory()->IsSafeRedirectTarget(location);
1044 } 1052 }
1045 1053
1046 bool URLRequestHttpJob::NeedsAuth() { 1054 bool URLRequestHttpJob::NeedsAuth() {
1047 int code = GetResponseCode(); 1055 int code = GetResponseCode();
1048 if (code == -1) 1056 if (code == -1)
1049 return false; 1057 return false;
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 return override_response_headers_.get() ? 1474 return override_response_headers_.get() ?
1467 override_response_headers_.get() : 1475 override_response_headers_.get() :
1468 transaction_->GetResponseInfo()->headers.get(); 1476 transaction_->GetResponseInfo()->headers.get();
1469 } 1477 }
1470 1478
1471 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1479 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1472 awaiting_callback_ = false; 1480 awaiting_callback_ = false;
1473 } 1481 }
1474 1482
1475 } // namespace net 1483 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698