vertx-web
vertx-web copied to clipboard
Add `Accept` header to 415 reponses
Describe the feature
If the content type of a request is not matching the accepted content types, a 415 Unsupported Media Type status is returned. According to the mdn web docs for the HTTP status 415 and the RFC 9110 for HTTP semantics, an Accept header with the accepted content types should be returned as well. This is currently missing and should be added.
For example, this endpoint accepts JSON and CSV:
router.route()
.consumes("application/json")
.consumes("text/csv")
.handler(ctx -> {
// handle request
});
In case, the client does not provide any content type or a wrong one, for example text/plain, the response should be as follows:
HTTP/1.1 415 Unsupported Media Type
# other fields
Accept: application/json, text/csv
Content-Length: 0
This is a follow up from #2656.
Use cases
This feature fulfills the offical semantics for a 415 status.
Additionally, the client gets to know what type of content is accepted without looking for documentation.
Contribution
I would like to do it but I cannot say until when.
When is v5.0.0 supposed to be released?