Match path before Content-Type in GraphQlRequestPredicates - #1531
Closed
kalayciburak wants to merge 1 commit into
Closed
kalayciburak wants to merge 1 commit into
kalayciburak wants to merge 1 commit into
Conversation
GraphQlRequestPredicates evaluated Content-Type before the request path. Since spring-projects#1145, an unparseable Content-Type throws 415 during handler lookup, so any POST in the application with a malformed header was rejected even when it did not target the GraphQL endpoint. Evaluate the path first so only GraphQL routes apply that check. The 415 for invalid Content-Type on the GraphQL path is unchanged. Fixes spring-projects#1485 Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
Member
|
Thanks for the proposal but I went in a different direction. |
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 #1485
GraphQlRequestPredicatesevaluated Content-Type (and Accept) before the request path. Since #1145,contentTypeMatchthrowsUnsupportedMediaTypeStatusExceptionfor an unparseable Content-Type.RouterFunctionMappingruns that predicate during handler lookup for every request, so any POST in the application with a malformed header was answered 415 even when it did not target the GraphQL endpoint.This change evaluates
pathMatchfirst in both the WebMVC and WebFlux predicates. Requests to other paths are unaffected. The deliberate 415 from #1145 is unchanged for requests aimed at the GraphQL path (shouldRejectRequestWithInvalidContentTypestill expectsUnsupportedMediaTypeStatusException).Test plan
Executed:
./gradlew :spring-graphql:test --tests org.springframework.graphql.server.webmvc.GraphQlRequestPredicatesTests --tests org.springframework.graphql.server.webflux.GraphQlRequestPredicatesTests→ 56/0