diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java index 0f9f9acedb..85257bf685 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java @@ -158,7 +158,7 @@ public class GzipResourceResolver extends AbstractResourceResolver { @Override public HttpHeaders getResponseHeaders() { HttpHeaders headers; - if(this.original instanceof HttpResource) { + if (this.original instanceof HttpResource) { headers = ((HttpResource) this.original).getResponseHeaders(); } else { @@ -167,7 +167,6 @@ public class GzipResourceResolver extends AbstractResourceResolver { headers.add(HttpHeaders.CONTENT_ENCODING, "gzip"); return headers; } - } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java index 6f8e3deb72..320df25feb 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java @@ -493,8 +493,8 @@ public class ResourceHttpRequestHandler extends WebContentGenerator try { List httpRanges = inputMessage.getHeaders().getRange(); response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); - this.resourceRegionHttpMessageConverter.write( - HttpRange.toResourceRegions(httpRanges, resource), mediaType, outputMessage); + this.resourceRegionHttpMessageConverter.write( + HttpRange.toResourceRegions(httpRanges, resource), mediaType, outputMessage); } catch (IllegalArgumentException ex) { response.setHeader("Content-Range", "bytes */" + resource.contentLength()); @@ -654,8 +654,19 @@ public class ResourceHttpRequestHandler extends WebContentGenerator } if (resource instanceof HttpResource) { HttpHeaders resourceHeaders = ((HttpResource) resource).getResponseHeaders(); - resourceHeaders.toSingleValueMap().entrySet() - .stream().forEach(entry -> response.setHeader(entry.getKey(), entry.getValue())); + for (Map.Entry> entry : resourceHeaders.entrySet()) { + String headerName = entry.getKey(); + boolean first = true; + for (String headerValue : entry.getValue()) { + if (first) { + response.setHeader(headerName, headerValue); + } + else { + response.addHeader(headerName, headerValue); + } + first = false; + } + } } response.setHeader(HttpHeaders.ACCEPT_RANGES, "bytes"); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java index b0c003dc94..60286103ce 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java @@ -328,7 +328,7 @@ public class VersionResourceResolver extends AbstractResourceResolver { @Override public HttpHeaders getResponseHeaders() { HttpHeaders headers; - if(this.original instanceof HttpResource) { + if (this.original instanceof HttpResource) { headers = ((HttpResource) this.original).getResponseHeaders(); } else { @@ -337,7 +337,6 @@ public class VersionResourceResolver extends AbstractResourceResolver { headers.setETag("\"" + this.version + "\""); return headers; } - } }