Closed Bug 1797404 Opened 2 years ago Closed 1 year ago

[DNR] Implement modifyHeaders action

Categories

(WebExtensions :: Request Handling, enhancement, P2)

enhancement
Points:
1

Tracking

(firefox109 fixed)

RESOLVED FIXED
109 Branch
Tracking Status
firefox109 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

Details

(Whiteboard: [addons-jira])

Attachments

(2 files)

Implement the following DNR action: modifyHeaders

Note, the current modifyHeaders action does not permit the "append" operation for request headers.
This is because it was documented to not be allowed at https://source.chromium.org/chromium/chromium/src/+/main:extensions/common/api/declarative_net_request.idl;l=54-55;drc=60039d4d4bd70512e21a2dfe586602aca1d9d35e:

   // This describes the possible operations for a "modifyHeaders" rule.
  enum HeaderOperation {
    // Adds a new entry for the specified header. This operation is not
    // supported for request headers.
    append,

While most of Chromium's IDL is usually rendered in auto-generated documentation, the comments in that highlighted section are not.

It is not clear why it is unsupported, so if feasible we should just support "append" (along with "set" and "remove").

There is demand for this feature, e.g. as seen at https://crbug.com/1270273

Assignee: nobody → rob
Status: NEW → ASSIGNED

I just checked again, and it looks like Chrome does now support "append" for some headers (based on an allowlist). I linked the details from https://crbug.com/1117475#c7 . In the patch above I enabled "append" for any header, without restricting which headers can be appended to, since any limitation would be somewhat arbitrary.

(In reply to Rob Wu [:robwu] from comment #4)

I just checked again, and it looks like Chrome does now support "append" for some headers (based on an allowlist). I linked the details from https://crbug.com/1117475#c7 . In the patch above I enabled "append" for any header, without restricting which headers can be appended to, since any limitation would be somewhat arbitrary.

I see, that clarify a bit the possible motivation for not supporting it first and then supporting it only on specific headers, would you mind to file a bug to remind us to reconsider if we should do something similar (I'd like us to also confirm what happens for other vendors, e.g. if and in which form Safari supports or intend to support this particular corner case).

Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/7703f8e13f31
Implement DNR modifyHeaders action r=rpl
https://hg.mozilla.org/integration/autoland/rev/8d4ff6d7ca86
Allow "append" operation to be used with requestHeaders r=rpl
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: