Skip to content

Set Allow header to "GET" for 405 responses in `StaticFileHandler' - #111

Merged
codebyNorthsteep merged 1 commit into
103-add-request-handler-last-in-filterchainfrom
add-allow-header-for-405-response
Feb 27, 2026
Merged

Set Allow header to "GET" for 405 responses in `StaticFileHandler'#111
codebyNorthsteep merged 1 commit into
103-add-request-handler-last-in-filterchainfrom
add-allow-header-for-405-response

Conversation

@codebyNorthsteep

@codebyNorthsteep codebyNorthsteep commented Feb 27, 2026

Copy link
Copy Markdown

Summary

Add Allow: GET to 405 (Method Not Allowed) responses for non-GET requests.

Why

When returning HTTP 405, the server should indicate which methods are allowed. This makes the response more HTTP-compliant and clearer for clients.

Changes

  • Set Allow: GET header when rejecting non-GET requests with 405.
  • Update the existing unit test to assert that the Allow header is present and correct.

Testing

  • updated mvn test
  • (Optional) Manual check: send a POST request to any static resource and verify status 405 + Allow: GET.
    Example, I checked this in Insomnia.
Skärmbild 2026-02-27 011054

@coderabbitai

coderabbitai Bot commented Feb 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-allow-header-for-405-response

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fredrikmohlen fredrikmohlen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You have addressed the issue by adding the Allow: GET header to the response. You have also updated the corresponding tests to reflect and verify this change.

@codebyNorthsteep
codebyNorthsteep merged commit d7a5dab into 103-add-request-handler-last-in-filterchain Feb 27, 2026
2 checks passed
kappsegla added a commit that referenced this pull request Mar 5, 2026
#107)

* Refactor StaticFileHandler and test suite to use HttpRequest and HttpResponseBuilder.

* Refactor test cases to use HttpResponseBuilder assertions and enhance URI normalization in StaticFileHandler.

* Add support for 405 responses to non-GET methods in StaticFileHandler and tests.

* Set `Allow` header to "GET" for 405 responses in `StaticFileHandler`, update test coverage (#111)

* Comprehensive Unit Tests for FilterChainImpl after implemented TerminalHandler (#113)

* Add unit test for `FilterChainImpl` to verify terminal handler invocation without filters

* Test confirms that chain.doFilter() correctly triggers the next filter in sequence and terminates at the handler.

* Test ensures TerminalHandler is bypassed when a filter blocks the chain

---------

Co-authored-by: Caroline Nordbrandt <caroline_nordbradt@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Allow header for 405 response

2 participants