Skip to content

Commit

Permalink
Always return a 415 if the content type is mismatching, also if its v…
Browse files Browse the repository at this point in the history
…alue is empty (#2659)

* Always return a 415 if the content type is mismatching, also if its value isempty

* Update RouterTest to expect 415 for missing content type
  • Loading branch information
komape authored Oct 18, 2024
1 parent d48a6f6 commit b677460
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1096,11 +1096,7 @@ public int matches(RoutingContextImplBase context, String mountPoint, boolean fa
MIMEHeader contentType = context.parsedHeaders().contentType();
MIMEHeader consumal = contentType.findMatchedBy(consumes);
if (consumal == null && !(contentType.rawValue().isEmpty() && emptyBodyPermittedWithConsumes)) {
if (contentType.rawValue().isEmpty()) {
return 400;
} else {
return 415;
}
return 415;
}
}
if (!isEmpty(produces)) {
Expand Down
2 changes: 1 addition & 1 deletion vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ public void testConsumesCTParamsIgnored() throws Exception {
@Test
public void testConsumesNoContentType() throws Exception {
router.route().consumes("text/html").handler(rc -> rc.response().end());
testRequest(HttpMethod.GET, "/foo", HttpResponseStatus.BAD_REQUEST);
testRequest(HttpMethod.GET, "/foo", HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE);
}

@Test
Expand Down

0 comments on commit b677460

Please # to comment.