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

Unified Diff: content/browser/download/download_item_impl.cc

Issue 1958383002: [Merge M51][Downloads] Set the Referrer header for resumed requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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: content/browser/download/download_item_impl.cc
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index a221cf2f9f36d0ba7b7d7ea41cb5ab1d8135b4da..55a62dbc7100d05aefdfbd054e12c58a4ae6ad0b 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -809,9 +809,9 @@ std::string DownloadItemImpl::DebugString(bool verbose) const {
" etag = '%s'"
" has_download_file = %s"
" url_chain = \n\t\"%s\"\n\t"
- " current_path = \"%" PRFilePath
- "\"\n\t"
- " target_path = \"%" PRFilePath "\"",
+ " current_path = \"%" PRFilePath "\"\n\t"
+ " target_path = \"%" PRFilePath "\""
+ " referrer = \"%s\"",
GetTotalBytes(),
GetReceivedBytes(),
DownloadInterruptReasonToString(last_reason_).c_str(),
@@ -825,7 +825,8 @@ std::string DownloadItemImpl::DebugString(bool verbose) const {
download_file_.get() ? "true" : "false",
url_list.c_str(),
GetFullPath().value().c_str(),
- GetTargetFilePath().value().c_str());
+ GetTargetFilePath().value().c_str(),
+ GetReferrerUrl().spec().c_str());
} else {
description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
}
@@ -1911,6 +1912,12 @@ void DownloadItemImpl::ResumeInterruptedDownload() {
download_params->set_hash_of_partial_file(hash_);
download_params->set_hash_state(std::move(hash_state_));
+ // Note that resumed downloads disallow redirects. Hence the referrer URL
+ // (which is the contents of the Referer header for the last download request)
+ // will only be sent to the URL returned by GetURL().
+ download_params->set_referrer(
+ Referrer(GetReferrerUrl(), blink::WebReferrerPolicyAlways));
+
TransitionTo(RESUMING_INTERNAL);
delegate_->ResumeInterruptedDownload(std::move(download_params), GetId());
// Just in case we were interrupted while paused.
« no previous file with comments | « content/browser/download/download_browsertest.cc ('k') | content/public/test/test_download_request_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698