Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid return of 415 Unsupported Media Type when request body is empty #396

Merged
merged 1 commit into from Mar 28, 2019
Merged

Avoid return of 415 Unsupported Media Type when request body is empty #396

merged 1 commit into from Mar 28, 2019

Conversation

jaswdr
Copy link
Contributor

@jaswdr jaswdr commented Mar 28, 2019

In JSR-311 there is this sentence:

The media type of the request entity body (if any) is a supported input data format (see1section 3.5). If no methods support the media type of the request entity body an implemen-2tation MUST generate aWebApplicationExceptionwith an unsupported media type3response (HTTP 415 status) and no entity. The exception MUST be processed as described4in section 3.3.4.

The current implementation ignore the if any in parentheses, what happen is that if you make a POST request without body and without Content-Type header you receive a 415 - Unsupported Media Type, but looking at the specification it say that the body is optional, and need only to return 415 when the body is set.

With this PR status code 415 is received only when the ContentLength > 0

@emicklei emicklei merged commit b9bbc56 into emicklei:master Mar 28, 2019
@emicklei
Copy link
Owner

thank you for fixing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants