Open Bug 1877486 Opened 2 years ago Updated 5 months ago

[DNR] Rule condition to match on response headers

Categories

(WebExtensions :: Request Handling, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: robwu, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome, Whiteboard: [wecg][addons-jira])

API design discussions on the shape of the API are still ongoing in https://github.com/w3c/webextensions/issues/460 , but it is clear that DNR will have an API to match requests by response header. This is a deviation from before: previously all matched rules could be determined at the start of the request, now rules also need to be evaluated at the onHeadersReceived stage.

Chromium is working on their implementation at https://bugs.chromium.org/p/chromium/issues/detail?id=1141166

Chrome's implementation is now available on Chrome Canary, so I'd say it's near-stable.

I opened this corresponding bug with webkit: https://bugs.webkit.org/show_bug.cgi?id=275158

It appears that the proposal at https://github.com/w3c/webextensions/issues/460 is now basically settled. According to https://github.com/w3c/webextensions/blob/main/_minutes/2024-06-20-wecg.md, "ways of matching substrings" was "the last major thing to resolve", and there a thought that "globs would offer the balance between functionality and performance". Subsequently, Rob noted in https://github.com/w3c/webextensions/issues/460#issuecomment-2198661058 "Since the expected number of header matching rules is low, I don't expect a significant performance impact with the use of globs for matching headers." Since then, globs were added to Chromium's in-progress implementation, and more recently, response header matching was enabled on stable: https://issues.chromium.org/issues/40727004#comment66.

This is now feature-complete in Chromium: https://issues.chromium.org/issues/40727004#comment69

You can find the internal documentation on the new HeaderInfo dictionary here:

https://source.chromium.org/chromium/chromium/src/+/0e7b854de08540505da2688660ed40fe1dad990e:extensions/common/api/declarative_net_request.idl;l=173-191

The two new RuleCondition types are here, and they are optional arrays of HeaderInfo, named responseHeaders and excludedResponseHeaders: https://source.chromium.org/chromium/chromium/src/+/0e7b854de08540505da2688660ed40fe1dad990e:extensions/common/api/declarative_net_request.idl;l=363-371

You need to log in before you can comment on or make changes to this bug.