Avoid writing content-length twice in resource handling

Prior to this commit, the `ResourceHttpRequestHandler` would write the
resource size to the "Content-Length" response header.
This is already done by the underlying `ResourceHttpMessageConverter`
and `ResourceRegionHttpMessageConverter`.

This commit avoid this duplicate operation and delegates instead to the
converters.

See gh-26330
Closes gh-26340
This commit is contained in:
Paul Warren 2021-01-04 13:27:37 -08:00 committed by Brian Clozel
parent 5804db6479
commit efa360cff7
1 changed files with 0 additions and 8 deletions

View File

@ -759,14 +759,6 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
protected void setHeaders(HttpServletResponse response, Resource resource, @Nullable MediaType mediaType)
throws IOException {
long length = resource.contentLength();
if (length > Integer.MAX_VALUE) {
response.setContentLengthLong(length);
}
else {
response.setContentLength((int) length);
}
if (mediaType != null) {
response.setContentType(mediaType.toString());
}