-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DNR] in contrast to webRequestBlocking
, declarativeNetRequest
rules are not applied if the request is redirected
#694
Comments
Firefox never sends the added header at the second request. |
webRequestBlocking
declarativeNetRequest
rules are not applied if the request is redirectedwebRequestBlocking
, declarativeNetRequest
rules are not applied if the request is redirected
webRequestBlocking
, declarativeNetRequest
rules are not applied if the request is redirectedwebRequestBlocking
, declarativeNetRequest
rules are not applied if the request is redirected
It appears Safari sends the added header to the second request with DNR. |
But the included test case doesn't reproduce that issue - because we limit the headers that can be modified, and that |
Seem like I need to add some more information after reading the meeting notes.
@Rob--W Yes,
@Rob--W "This header is stripped from cross-origin redirects" and should of course be stripped from DNR modified requests as well. I'm just asking for standard
@oliverdunk I think the above leads to the assumption that the webRequest API was right and it obviously worked fine for many years. ;-) Let me explain a little bit more Tampermonkey's use case. Userscripts want to add a header to So if your really want not-preserving headers as standard behavior, then please make is configurable. Thanks. |
I don't recall whether it did the right thing, but I know that I once experimented with using reference fragments for the purpose of tracking requests across redirects. Reference fragments are not sent to servers, but still part of the URL at the client. This enables you to match requests across redirects. Would that address your use case? I have a reverted proof of concept in one of my local repositories. It is not on my device that I carry at TPAC, but if you would like me to dig up my code, I can do that. |
Puhh. Interesting idea, but handling subsequent redirects requires more logic to add the fragment to all URLs, right? I need to check how that can be achieved. I also have to check what URL is seen by All in all this looks very hacky to me, while according to @b-weinstein the existing code just works in Safari. ;-) |
No, the point of the reference fragment being completely client-side is that the server cannot see it. If I append a reference fragment to your URL, the URL changes, but the reference fragment stays the same: example. The reference fragment may however be changed if the server includes a reference fragment in the redirect target, example. |
@Rob--W And that is a problem I thought I can somehow solve with another DNR rule, but the API doesn't seem to be advanced enough. So the problem remains: extensions in Chrome need an extension-wide lock to run only one request at a time, that wants to set headers that cannot be set via |
Another idea, untested: if the headers set by fetch()/XMLHttpRequest appear across redirects, can you then set a unique custom header and match this with DNR?
|
Tracking a request this way might indeed work, but are you sure Chrome added
throw an error:
when executing the following code:
|
My bad - I was thinking of responseHeaders. requestHeaders matching often comes up in the same discussions, but ultimately Chrome has only implemented responseHeaders support. Regardless of the current implementation state - I think that such a feature (generic request header support) would be preferable than implementing the original request here (automatically applying headers meant for one request to other requests that do not match the condition). Ultimately the real goal here is to apply DNR actions to a specific request / chain of requests. This is not uncommon, so I am supportive of a way to do so, but without introducing a footgun. Concrete proposals of feasibly implementable APIs are welcome. |
If a header is added to a request via
webRequest
then the redirected request also sends this header.This does not apply to
declarativeNetRequest
modifyHeaders
rules.Please specify the correct behavior. You can test both behaviors by loading the unpacked extensions attached and investigating the background contexts.
Using
webRequest
the request tohttps://httpbin.org/headers
sends aaaa
header while usingdeclarativeNetRequest
the request does not send abbb
header.From my point of view a redirect means to send the very same request to another URL, which includes extension based modifications which even might have caused the redirect.
t.zip
The text was updated successfully, but these errors were encountered: