w3c规定,当请求的header匹配以下不安全字符时,将被终止,具体参考如下:
Accept-Charset
Accept-Encoding
Connection
Content-Length
Cookie
Cookie2
Content-Transfer-Encoding
Date
Expect
Host
Keep-Alive
Referer
TE
Trailer
Transfer-Encoding
Upgrade
User-Agent
Via
插件解决方案
chrome.webRequest.onBeforeSendHeaders.addListener(function(details){
var headers = details.requestHeaders;
// 遍历headers ,查出含有我们定义标识头的请求头,去掉自定义的标识头覆盖同名w3c
for(let [key,name] of Object.entries(headers)) {
// code ...
}
// details.requestHeaders.push({
// name: 'xxxxx",
// value: 'yyyyy'
// })
console.log(headers)
return {requestHeaders: details.requestHeaders}
},{urls: ["要伪造的地址"]},