Skip to content

Inconsistency: DNR modifyHeaders supported headers #372

@sammacbeth

Description

@sammacbeth

The DNR modifyHeaders rule action allows for request headers to be added, removed or modified. The current Chrome docs do not specify any limitation on which headers these rules can modify.

In fact, in Chrome and Firefox arbitrary header names are supported (apart from a list of forbidden header names) and can be modified by these rules. However, in Safari, only 'recognized' headers can specified in these rules. For example, take the following rule:

{
  id: 1,
  priority: 1,
  action: {
    type: "modifyHeaders",
    requestHeaders: [
      { header: "Sec-GPC", operation: "set", value: "1" },
    ],
  },
  condition: {
    urlFilter: "||global-privacy-control.glitch.me/",
    resourceTypes: ["main_frame", "sub_frame"],
  },
}

This rule is accepted and works as expected in Firefox and Chrome. However, in Safari, the following exception is thrown:

Invalid call to declarativeNetRequest.updateDynamicRules(). Error with rule at index 0: Rule with id 1 is invalid. The header `Sec-GPC` is not recognized.

This issue has also been submitted to Safari as Radar #FB12074761

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions