46
46
import org .springframework .web .context .request .NativeWebRequest ;
47
47
import org .springframework .web .method .support .ModelAndViewContainer ;
48
48
49
- import static org .springframework .http .HttpHeaders .VARY ;
50
-
51
49
/**
52
50
* Resolves {@link HttpEntity} and {@link RequestEntity} method argument values
53
51
* and also handles {@link HttpEntity} and {@link ResponseEntity} return values.
@@ -172,15 +170,17 @@ public void handleReturnValue(Object returnValue, MethodParameter returnType,
172
170
173
171
HttpHeaders outputHeaders = outputMessage .getHeaders ();
174
172
HttpHeaders entityHeaders = responseEntity .getHeaders ();
175
- if (outputHeaders .containsKey (VARY ) && entityHeaders .containsKey (VARY )) {
173
+ if (outputHeaders .containsKey (HttpHeaders . VARY ) && entityHeaders .containsKey (HttpHeaders . VARY )) {
176
174
List <String > values = getVaryRequestHeadersToAdd (outputHeaders , entityHeaders );
177
175
if (!values .isEmpty ()) {
178
176
outputHeaders .setVary (values );
179
177
}
180
178
}
181
179
if (!entityHeaders .isEmpty ()) {
182
180
for (Map .Entry <String , List <String >> entry : entityHeaders .entrySet ()) {
183
- outputHeaders .putIfAbsent (entry .getKey (), entry .getValue ());
181
+ if (!outputHeaders .containsKey (entry .getKey ())) {
182
+ outputHeaders .put (entry .getKey (), entry .getValue ());
183
+ }
184
184
}
185
185
}
186
186
@@ -197,14 +197,15 @@ public void handleReturnValue(Object returnValue, MethodParameter returnType,
197
197
return ;
198
198
}
199
199
}
200
- if (inputMessage .getHeaders ().containsKey (HttpHeaders .RANGE ) &&
200
+ if (inputMessage .getHeaders ().containsKey (HttpHeaders .RANGE ) &&
201
201
Resource .class .isAssignableFrom (body .getClass ())) {
202
202
try {
203
203
List <HttpRange > httpRanges = inputMessage .getHeaders ().getRange ();
204
204
Resource bodyResource = (Resource ) body ;
205
205
body = new HttpRangeResource (httpRanges , bodyResource );
206
206
outputMessage .setStatusCode (HttpStatus .PARTIAL_CONTENT );
207
- } catch (IllegalArgumentException exc ) {
207
+ }
208
+ catch (IllegalArgumentException ex ) {
208
209
outputMessage .setStatusCode (HttpStatus .REQUESTED_RANGE_NOT_SATISFIABLE );
209
210
outputMessage .flush ();
210
211
return ;
0 commit comments