File tree 1 file changed +6
-5
lines changed
spring-web/src/main/java/org/springframework/http/server
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -120,12 +120,13 @@ private void writeHeaders() {
120
120
}
121
121
});
122
122
// HttpServletResponse exposes some headers as properties: we should include those if not already present
123
- if (this .servletResponse .getContentType () == null && this .headers .getContentType () != null ) {
124
- this .servletResponse .setContentType (this .headers .getContentType ().toString ());
123
+ MediaType contentTypeHeader = this .headers .getContentType ();
124
+ if (this .servletResponse .getContentType () == null && contentTypeHeader != null ) {
125
+ this .servletResponse .setContentType (contentTypeHeader .toString ());
125
126
}
126
- if (this .servletResponse .getCharacterEncoding () == null && this . headers . getContentType () != null &&
127
- this . headers . getContentType () .getCharset () != null ) {
128
- this .servletResponse .setCharacterEncoding (this . headers . getContentType () .getCharset ().name ());
127
+ if (this .servletResponse .getCharacterEncoding () == null && contentTypeHeader != null &&
128
+ contentTypeHeader .getCharset () != null ) {
129
+ this .servletResponse .setCharacterEncoding (contentTypeHeader .getCharset ().name ());
129
130
}
130
131
long contentLength = getHeaders ().getContentLength ();
131
132
if (contentLength != -1 ) {
You can’t perform that action at this time.
0 commit comments