Skip to content

500 response for ResourceHttpRequestHandler when requested range is not satisfied #34490

Open
@NielsCW

Description

@NielsCW

When sending a request to a resource with an invalid range, the server responds with a 500 Internal server error instead of 416 Requested range not satisfiable.

When the ResourceHttpRequestHandler is executed with an invalid range then it will call the HttpServletResponse.sendError(HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE) method:

catch (IllegalArgumentException ex) {
response.setHeader(HttpHeaders.CONTENT_RANGE, "bytes */" + resource.contentLength());
response.sendError(HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
}
Further down the processing line this will not result in a ProblemDetail body response, so the writeWithMessageConverters method in AbstractMessageConverterMethodProcessor will throw a HttpMessageNotWritableException from:
if (isContentTypePreset || !CollectionUtils.isEmpty(producibleMediaTypes)) {
throw new HttpMessageNotWritableException(
"No converter for [" + valueType + "] with preset Content-Type '" + contentType + "'");
}
(Where valueType is java.util.LinkedHashMap and contentType is multipart/form-data)

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: feedback-providedFeedback has been providedstatus: waiting-for-triageAn issue we've not yet triaged or decided on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions