declarativeNetRequest.ModifyHeaderInfo

The request or response header to modify for a request, declared in the rule.action.requestHeaders array or rule.action.responseHeaders array for rules whose rule.action.type is "modifyHeaders".

Each object describes one header modification. To modify multiple headers, multiple objects can be specified in these arrays, or across multiple rules.

Matching modifyHeaders rules are applied in the order described at Matching precedents. Within each extension, all modifyHeaders rules with a priority lower than or equal to matching allow or allowAllRequests rules are ignored.

If multiple modifyHeaders rules specify the same header, the resulting modification for the header is determined based on the priority of each rule and the operations specified:

  • If a rule has been appended to a header, then lower-priority rules can only append to that header. set and remove operations are not permitted.
  • If a rule has set a header, lower priority rules cannot modify the header except for append rules from the same extension.
  • If a rule has removed a header, lower priority rules cannot modify the header.

Type

Values of this type are objects. They contain these properties:

A string. The name of the header to be modified.

operation

A string. The operation to be performed on a header. Possible values are "append", "set", and "remove".

value Optional

A string. The new value for the header. Must be specified for append and set operations. Not allowed for the "remove" operation.

Header limits

In Chrome, "append" is supported for the following request headers:

  • Accept
  • Accept-Encoding
  • Accept-Language
  • Access-Control-Request-Headers
  • Cache-Control
  • Connection
  • Content-Language
  • Cookie
  • Forwarded
  • If-Match
  • If-None-Match
  • Keep-Alive
  • Range
  • Te
  • Trailer
  • Transfer-Encoding
  • Upgrade
  • Via
  • Want-Digest
  • X-Forwarded-For

In Firefox, the extension needs host permissions for the new value of the Host header.

Browser compatibility

webextensions.api.declarativeNetRequest.RuleAction.requestHeaders

BCD tables only load in the browser

webextensions.api.declarativeNetRequest.RuleAction.responseHeaders

BCD tables only load in the browser