-
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
Add new rewrite rule to return response status code based on matching headers #12182
Conversation
...e/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ResponseHeaderRegexRule.java
Outdated
Show resolved
Hide resolved
...e/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ResponseHeaderRegexRule.java
Outdated
Show resolved
Hide resolved
...e/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ResponseHeaderRegexRule.java
Outdated
Show resolved
Hide resolved
...e/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ResponseHeaderRegexRule.java
Outdated
Show resolved
Hide resolved
...e/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ResponseHeaderRegexRule.java
Outdated
Show resolved
Hide resolved
...y-core/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ResponseHeaderRule.java
Outdated
Show resolved
Hide resolved
*/ | ||
public class ResponseHeaderRule extends HeaderRule | ||
{ | ||
private int _code; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"code" -> "status".
if (getCode() < HttpStatus.CONTINUE_100) | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move check to setStatus()
.
String message = getMessage(); | ||
if (StringUtil.isBlank(message)) | ||
{ | ||
response.setStatus(getCode()); | ||
callback.succeeded(); | ||
} | ||
else | ||
{ | ||
Response.writeError(this, response, callback, getCode(), message); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Collapse as explained for the other rule.
612cfeb
to
d4dbece
Compare
I pushed an update including the changes you requested that are marked resolved and an initial attempt at the unit test. When I try to run the unit tests via maven at the cli I get errors?
Is there something extra I need to do for this? Thanks... |
Don't worry about the |
@pbhenson thanks! |
These are two rewrite rules, both of which return a status code based on a header match, the first matches on exact string, the second matches on a regex.
I'd like some initial feedback on whether these are acceptable to be added and if the approach is ok. If so, I will follow up with cleaning up the javadoc and adding appropriate tests.
Thanks...