Details
-
Enhancement
-
Resolution: Obsolete
-
Minor
-
None
-
4.5.8.Final
-
None
-
None
-
Undefined
Description
There are two scenarios in which a bad Content-Type string in a multipart request causes an exception other than BadRequestException to be thrown. This causes a 500 internal server error instead of 400 bad request response code.
Case 1
The main Content-Type header of the request is "multipart/*", then it must be followed by a boundary parameter. Example: `multipart/related;boundary=abc` If RestEasy does not find the boundary parameter here, it throws this exception:
java.io.IOException: RESTEASY007550: Unable to get boundary for multipart
Case 2
An invalid media type in the Content-Type value inside the multipart request body is detected here, it causes the following exception (reproduced using a Content-Type value of "badcontenttype"):
java.lang.IllegalArgumentException: RESTEASY003340: Failure parsing MediaType string: badcontenttype
Note: An invalid media type in the main Content-Type header (as opposed to the one in the request body in Case 2) does throw NotSupportedException which generates a 415 response code.
Since the exceptions in cases 1 and 2 are caused by an invalid request, it would be standard for BadRequestException to be thrown instead of the above exceptions.
Attachments
Issue Links
- is cloned by
-
RESTEASY-2785 Throw BadRequestException if multipart request has invalid Content-Type string
- Closed