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

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

Issue 1891623003: [Downloads] Set the Referrer header for resumed requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Catch up with ToT Created 4 years, 8 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 66f3106348dda6d97a12f5773f3fb42d4c41cc14..8df564b866660d9eaa13b1572c365dcf6d91fb0d 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -810,9 +810,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(),
@@ -826,7 +826,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());
}
@@ -1914,6 +1915,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