Use ServletResponse#getContentType in ServletServerHttpResponse

This commit updates ServletServerHttpResponse.ServletResponseHttpHeaders
in order to use ServletResponse#getContentType instead of
ServletResponse#getHeader.

It allows to have a consistent behavior between Tomcat (which sets only
the former) and Undertow/Jetty (which set both).

Closes gh-32339
This commit is contained in:
Sébastien Deleuze
2024-03-04 15:32:32 +01:00
parent 4ce2559980
commit 138e7a0e07

View File

@@ -162,7 +162,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
if (headerName.equalsIgnoreCase(CONTENT_TYPE)) {
// Content-Type is written as an override so check super first
String value = super.getFirst(headerName);
return (value != null ? value : servletResponse.getHeader(headerName));
return (value != null ? value : servletResponse.getContentType());
}
else {
String value = servletResponse.getHeader(headerName);