Repository navigation
Answer 405 instead of 412 to a failing precondition on an unsupported method (#1752) - #1755
Merged
Merged
Conversation
… method (#1752) RFC 9110 section 13.2.1: a server ignores the preconditions when the response without them would be neither a success nor a 412, and the failures that do not depend on them take precedence. ServerResource evaluated the preconditions first, so a conditional PUT, DELETE, POST or PATCH to a resource that does not support the method got a 412 (or the 428 of the documented recipe) instead of a 405, and a client re-reading and retrying looped on a write that could never succeed. When the preconditions yield an error and the resource declares its supported methods (updateAllowedMethods(), the annotated methods by default) without the method of the request, the answer is now 405 with the Allow header. A resource that declares nothing, such as one that overrides the methods without annotating them, is not changed: the framework does not guess at overridden methods. The evaluation is unchanged otherwise, so a wrong declaration can never skip a precondition. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 29, 2026
|
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.



Fixes #1752
RFC 9110 section 13.2.1: a server ignores the preconditions when the response without them would be neither a success nor a 412, and the failures that do not depend on them take precedence.
ServerResourceevaluated the preconditions first, so a conditionalPUT,DELETE,POSTorPATCHto a resource that does not support the method got a 412 (or the 428 of the documented recipe) instead of a 405. A client that re-reads and retries on 412 looped on a write that could never succeed.updateAllowedMethods(), the annotated methods by default) without the method of the request, the answer is now 405 with theAllowheader.put()without annotating it) is not changed: the framework does not guess at overridden methods. Such a resource can overrideupdateAllowedMethods()to declare them (said in the Javadoc ofupdateAllowedMethodsandgetPreconditionStatus).Allowheader.get()).ServerResourceMethodNotAllowedTestCase(unit, with guards) and the wire-levelMethodNotAllowedWireTestCase.Same fix on the other maintained versions: 3.0: #1754, 2.6: #1756
🤖 Generated with Claude Code