mirror of
https://github.com/electron/electron.git
synced 2026-01-08 23:18:06 -05:00
fix: webContents.downloadURL() did not support referer header (#47625)
Signed-off-by: xufuhang <576484918@qq.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user