[Declarative Net Request] Header modification available on Stable in M85

1,131 views
Skip to first unread message

Kelvin Jiang

unread,
Aug 10, 2020, 7:44:12 PM8/10/20
to Chromium Extensions

Hi,


Header modification support has been added to the declarativeNetRequest API starting in M85 (also currently available in Beta/Dev/Canary). This change allows extensions to add/set/remove request and response headers.


Example rule:

{

  "id": 10,

  "priority": 2,

  "action": {

    "type": "modifyHeaders",

      "requestHeaders": [

        {"header": "referer", "operation": "remove"},

      ],

      "responseHeaders": [

        {"header": "h1", "operation": "remove"},

        {"header": "h2", "operation": "set", "value": "v2"},

        {"header": "h3", "operation": "append", "value": "v3"}

      ]

    },

    "condition": {

      "urlFilter": "headers.com/123",

      "resourceTypes": ["main_frame"]

    }

  }

}


Documentation is available at https://developer.chrome.com/extensions/declarativeNetRequest#type-ModifyHeaderInfo with more examples. Please try out this functionality for yourself and let us know what you think by filing bugs feature requests.


Thanks,

Kelvin


Note: Currently, the documentation incorrectly lists the availability of ModifyheaderInfo as M86. ModifyHeaderInfo will be available on M85 Stable.


Kelvin Jiang

unread,
Aug 10, 2020, 10:44:30 PM8/10/20
to Chromium Extensions

Dave Vandyke

unread,
Aug 14, 2020, 12:16:15 PM8/14/20
to Chromium Extensions, kelvi...@chromium.org
I gave it a quick go, but I found that appended CSP headers weren't enforced properly. I've filed a bug https://bugs.chromium.org/p/chromium/issues/detail?id=1116487

Cheers, Dave.

Dave Vandyke

unread,
Aug 18, 2020, 9:19:10 AM8/18/20
to Chromium Extensions, Dave Vandyke, kelvi...@chromium.org
Reply all
Reply to author
Forward
0 new messages