Skip to content

Commit efa360c

Browse files
paulcwarrenbclozel
authored andcommitted
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
1 parent 5804db6 commit efa360c

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -759,14 +759,6 @@ protected MediaType getMediaType(HttpServletRequest request, Resource resource)
759759
protected void setHeaders(HttpServletResponse response, Resource resource, @Nullable MediaType mediaType)
760760
throws IOException {
761761

762-
long length = resource.contentLength();
763-
if (length > Integer.MAX_VALUE) {
764-
response.setContentLengthLong(length);
765-
}
766-
else {
767-
response.setContentLength((int) length);
768-
}
769-
770762
if (mediaType != null) {
771763
response.setContentType(mediaType.toString());
772764
}

0 commit comments

Comments
 (0)