I'm porting to Safari a Chrome/Firefox Extension that makes use of declarativeNetRequest.updateDynamicRules
to remove some HTTP headers from requests to a specific URL.
This works mostly fine, except for some headers for which this is not allowed by WebKit, such as the Priority
header (which is however served by Safari).
An annoying corner-case I found is that of the Cookie
header. When trying to remove it from the request by adding the following rule
{
id: <rule id>,
priority: <rule priority>,
action: {
type: "modifyHeaders",
requestHeaders: [{ "header": "Cookie", "operation": "remove" }]
},
condition: {
urlFilter: <my url>,
resourceTypes: ["main_frame", "sub_frame"]
}
}
nothing error is thrown, yet the Cookie
header is still being sent. This rule however works for other headers, such as Referer
. Changing "Cookie"
for "cookie"
does not help.
Questions:
- Is there an alternative way of removing the
Cookie
header from the HTTP request? - Is this just a bug in WebKit?
- Is there any way of removing "unsupported" headers such as
Priority
?
Any help or references are appreciated.
Edited: more specific description of the corner-case.