fix: webContents.downloadURL() did not support referer header (#47625)
Signed-off-by: xufuhang <576484918@qq.com>
This commit is contained in:
parent
2156ccb577
commit
b39a1fb877
2 changed files with 54 additions and 0 deletions
|
|
@ -2398,6 +2398,13 @@ void WebContents::DownloadURL(const GURL& url, gin::Arguments* args) {
|
|||
content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
|
||||
web_contents(), url, MISSING_TRAFFIC_ANNOTATION));
|
||||
for (const auto& [name, value] : headers) {
|
||||
if (base::ToLowerASCII(name) ==
|
||||
base::ToLowerASCII(net::HttpRequestHeaders::kReferer)) {
|
||||
// Setting a Referer header with HTTPS scheme while the download URL's
|
||||
// scheme is HTTP might lead to download failure.
|
||||
download_params->set_referrer(GURL(value));
|
||||
continue;
|
||||
}
|
||||
download_params->add_request_header(name, value);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue