Honor Content-[Type|Length] headers from wrapped response again
Commit 375e0e6827 introduced a regression in
ContentCachingResponseWrapper (CCRW). Specifically, CCRW no longer
honors Content-Type and Content-Length headers that have been set on
the wrapped response and returns null for those header values if they
have not been set directly on the CCRW.
This commit fixes this regression as follows.
- The Content-Type and Content-Length headers set in the wrapped
response are honored in getContentType(), containsHeader(),
getHeader(), and getHeaders() unless those headers have been set
directly on the CCRW.
- In copyBodyToResponse(), the Content-Type in the wrapped response is
only overridden if the Content-Type has been set directly on the CCRW.
See gh-32039
Closes gh-32317
@ -157,16 +158,19 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
@@ -157,16 +158,19 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
@ -222,10 +226,10 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
@@ -222,10 +226,10 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
@ -235,12 +239,11 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
@@ -235,12 +239,11 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
@ -330,7 +333,7 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
@@ -330,7 +333,7 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {