Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ private static class GraphQlHttpRequestPredicate implements RequestPredicate {

@Override
public boolean test(ServerRequest request) {
return httpMethodMatch(request, HttpMethod.POST)
return pathMatch(request, this.pattern)
&& httpMethodMatch(request, HttpMethod.POST)
&& contentTypeMatch(request, this.contentTypes)
&& acceptMatch(request, this.acceptedMediaTypes)
&& pathMatch(request, this.pattern);
&& acceptMatch(request, this.acceptedMediaTypes);
}

private static boolean httpMethodMatch(ServerRequest request, HttpMethod expected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ private static class GraphQlHttpRequestPredicate implements RequestPredicate {

@Override
public boolean test(ServerRequest request) {
return httpMethodMatch(request, HttpMethod.POST)
return pathMatch(request, this.pattern)
&& httpMethodMatch(request, HttpMethod.POST)
&& contentTypeMatch(request, this.contentTypes)
&& acceptMatch(request, this.acceptedMediaTypes)
&& pathMatch(request, this.pattern);
&& acceptMatch(request, this.acceptedMediaTypes);
}

private static boolean httpMethodMatch(ServerRequest request, HttpMethod expected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ void shouldRejectRequestWithIncompatibleContentType() {
assertThat(httpPredicate.test(serverRequest)).isFalse();
}

@Test // gh-1485
void shouldNotRejectRequestWithInvalidContentTypeOnDifferentPath() {
MockServerHttpRequest request = MockServerHttpRequest.post("/invalid")
.header(HttpHeaders.CONTENT_TYPE, "bogus")
.accept(MediaType.APPLICATION_JSON, MediaTypes.APPLICATION_GRAPHQL_RESPONSE)
.build();
ServerRequest serverRequest = ServerRequest.create(MockServerWebExchange.from(request), Collections.emptyList());
assertThat(httpPredicate.test(serverRequest)).isFalse();
}

@Test
void shouldRejectRequestWithInvalidContentType() {
ServerWebExchange exchange = createMatchingHttpExchange()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ void shouldRejectRequestWithInvalidContentType() {
assertThatThrownBy(() -> httpPredicate.test(request)).isInstanceOf(UnsupportedMediaTypeStatusException.class);
}

@Test // gh-1485
void shouldNotRejectRequestWithInvalidContentTypeOnDifferentPath() {
MockHttpServletRequest servletRequest = createMatchingHttpRequest();
servletRequest.setRequestURI("/invalid");
servletRequest.setContentType("bogus");
ServerRequest request = ServerRequest.create(servletRequest, List.of());
assertThat(httpPredicate.test(request)).isFalse();
}

@Test
void shouldRejectRequestWithIncompatibleAccept() {
MockHttpServletRequest request = createMatchingHttpRequest();
Expand Down