Fix null value support in ContentCachingResponseWrapper
Prior to this commit, calling `setHeader` on the response wrapper would have a separate code path for the "Content-Length" header. This did not support calls with `null` values and would result in an exception. This commit ensures that the cached content length value is reset in this case and that the call is forwarded properly to the superclass. Fixes gh-34460
This commit is contained in:
@@ -164,7 +164,13 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
|
||||
@Override
|
||||
public void setHeader(String name, String value) {
|
||||
if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) {
|
||||
this.contentLength = toContentLengthInt(Long.parseLong(value));
|
||||
if (value != null) {
|
||||
this.contentLength = toContentLengthInt(Long.parseLong(value));
|
||||
}
|
||||
else {
|
||||
this.contentLength = null;
|
||||
super.setHeader(name, null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.setHeader(name, value);
|
||||
|
||||
Reference in New Issue
Block a user