Skip to content
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

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

pbhenson
Copy link
Contributor

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...

@sbordet sbordet self-requested a review August 21, 2024 11:51
*/
public class ResponseHeaderRule extends HeaderRule
{
private int _code;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"code" -> "status".

Comment on lines 73 to 74
if (getCode() < HttpStatus.CONTINUE_100)
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move check to setStatus().

Comment on lines 81 to 90
String message = getMessage();
if (StringUtil.isBlank(message))
{
response.setStatus(getCode());
callback.succeeded();
}
else
{
Response.writeError(this, response, callback, getCode(), message);
}
Copy link
Contributor

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.

@pbhenson
Copy link
Contributor Author

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?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:testCompile (default-test
Compile) on project jetty-slf4j-impl: Compilation failure: Compilation failure:
[ERROR] /home/henson/projects/jetty/jetty.project/jetty-core/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/
logging/JettyLoggerTest.java:[655,30] cannot find symbol
[ERROR]   symbol:   class JettyLogger
[ERROR]   location: class org.eclipse.jetty.logging.JettyLoggerTest
[ERROR] /home/henson/projects/jetty/jetty.project/jetty-core/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/
logging/JettyLoggerTest.java:[655,47] cannot find symbol

Is there something extra I need to do for this?

Thanks...

@pbhenson pbhenson changed the title Add two new rewrite rules to return status code based on matching headers Add new rewrite rule to return response status code based on matching headers Aug 23, 2024
@sbordet sbordet self-requested a review August 23, 2024 09:52
@sbordet
Copy link
Contributor

sbordet commented Aug 23, 2024

Don't worry about the JettyLoggerTest, it's probably just some transient glitch.
All compiles and works fine for me.

@sbordet sbordet merged commit d4dbece into jetty:jetty-12.0.x Aug 23, 2024
1 of 3 checks passed
@sbordet
Copy link
Contributor

sbordet commented Aug 23, 2024

@pbhenson thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants