fix: webContents.downloadURL()
did not support referer header (#47865)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: xufuhang <576484918@qq.com>
This commit is contained in:
parent
46dec46a82
commit
ee8290e707
2 changed files with 54 additions and 0 deletions
|
@ -2411,6 +2411,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