-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
RewriteHandler with multiple HeaderPatternRules #10482
Comments
@janitza-bjag I am unsure what you are trying to achieve with a pattern of The pattern should be a Servlet pattern as defined in the Servlet specification here: Your mapping of Please fix your patterns depending on your logic and report back if this issue is fixed. |
@sbordet Thanks for your reply. We had the above code working with Jetty 10.0.15 Is there another preferred way to do so? |
@janitza-bjag If you want to make the rules trigger for every request for every request path, use the It feels like a bug that |
@sbordet If I use the /* pattern in the above code only the last rule "CONTENT_TYPE_OPTIONS" applied. All other headers are not set ... really weird |
Probably no surprise, but the same situation when configuring multiple rules via $JETTY_BASE/etc/jetty-rewrite-rules.xml. Only the last addRule is applied. |
Confirmed that there is a bug, we do not process the rules properly in 12. I still recommend that you use |
Reviewed the implementation of RewriteHandler, that was broken for those rules that were overriding `Rule.Handler.handle()`. The problem was that the handling was not forwarded along the chain of rules, so only the last one was applied. Removed (a breaking change) `Rule.Handler.handle(Response, Callback)` because it is necessary that the outermost request wrapper is passed to the `RewriteHandler` child `Handler`. Updated implementations to override `handle(Request, Response, Callback)` instead, so that the request parameter is preserved along the chain. Signed-off-by: Simone Bordet <[email protected]>
@janitza-bjag @made-in-nz are you able to try out PR #10572 and report whether the issue is fixed for you? Thanks! |
@sbordet Yes, I can confirm this fixes it. Thank you! |
The PR fixes it, thanks! |
Updated the implementation after review. Restored the `Rule.Handler.handle(Response, Callback)` method so that existing code won't break. Now the wrapping at the constructor produces RH3(RH2(RH1(Request))), but the handling is performed from the innermost towards the outermost. In this way, the order of rules is respected, both in the wrapping at rule application, and in the `Rule.Handler` handling. Signed-off-by: Simone Bordet <[email protected]>
Reviewed the implementation of RewriteHandler, that was broken for those rules that were overriding `Rule.Handler.handle()`. The problem was that the handling was not forwarded along the chain of rules, so only the last one was applied. Now the wrapping at the constructor produces RH3(RH2(RH1(Request))), but the handling is performed from the innermost towards the outermost. In this way, the order of rules is respected, both in the wrapping at rule application, and in the `Rule.Handler` handling. Signed-off-by: Simone Bordet <[email protected]>
Jetty Version
12.0.1
Jetty Environment
core, ee8
Java Version
17.0.8
Question
I added some HeaderPatternRules to a RewriteHandler, but only the last rule applies. What I am doing wrong? I assumed that all matching rules will apply...
The text was updated successfully, but these errors were encountered: