Repository navigation
Send an Allow header with the 405 response from HttpServlet - #1103
Merged
Merged
Conversation
Section 15.5.6 of RFC 9110 requires an origin server to generate an Allow header field in a 405 response that lists the methods supported by the target resource. The 405 response sent for a method the servlet does not implement did not include one. Use the value that the default OPTIONS handling generates.
Contributor
|
There is some-follow up work required. Commit to follow shortly and then I'll back-port. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Section 15.5.6 of RFC 9110 requires an origin server to generate an
Allowheader field in a 405 response, listing the methods supported by the target resource. The 405 sent byHttpServletfor a method the servlet does not implement did not include one, unlike the 405 sent byDefaultServlet, theTRACEhandling and JSP pages.HttpServletnow setsAllowbefore sending the 405, using the same value as the defaultdoOptions(), which includesTRACEwhen the connector allows it. The calculation is moved to a private method that both use. The HTTP/1.0 and HTTP/0.9 case, which answers 400, is unchanged.TestHttpServlethas two new tests that send an unsupported method to a servlet that implementsdoGet()and to one that implementsdoGet()anddoPost(). Without the change they fail because there is noAllowheader. With it they pass and the header matches what OPTIONS returns for the same servlet. The related tests pass (TestDefaultServletOptions,TestWebdavServlet,TestConnector,TestJspServlet,TestStandardWrapper,TestHttpServletResponseSendErrorand the HTTP/2TestHttpServlet) and Checkstyle reports nothing for the changed files.CGIServletalso sends a 405 withoutAllow. I have not changed it here because it needs a CGI test set-up.