32
32
import javax .servlet .http .HttpServletResponse ;
33
33
import javax .servlet .http .HttpSession ;
34
34
35
+ import org .springframework .http .HttpHeaders ;
35
36
import org .springframework .http .HttpMethod ;
36
37
import org .springframework .http .HttpStatus ;
37
38
import org .springframework .lang .Nullable ;
50
51
*/
51
52
public class ServletWebRequest extends ServletRequestAttributes implements NativeWebRequest {
52
53
53
- private static final String ETAG = "ETag" ;
54
-
55
- private static final String IF_MODIFIED_SINCE = "If-Modified-Since" ;
56
-
57
- private static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since" ;
58
-
59
- private static final String IF_NONE_MATCH = "If-None-Match" ;
60
-
61
- private static final String LAST_MODIFIED = "Last-Modified" ;
62
-
63
54
private static final List <String > SAFE_METHODS = Arrays .asList ("GET" , "HEAD" );
64
55
65
56
/**
@@ -244,11 +235,11 @@ public boolean checkNotModified(@Nullable String etag, long lastModifiedTimestam
244
235
HttpStatus .NOT_MODIFIED .value () : HttpStatus .PRECONDITION_FAILED .value ());
245
236
}
246
237
if (isHttpGetOrHead ) {
247
- if (lastModifiedTimestamp > 0 && parseDateValue (response .getHeader (LAST_MODIFIED )) == -1 ) {
248
- response .setDateHeader (LAST_MODIFIED , lastModifiedTimestamp );
238
+ if (lastModifiedTimestamp > 0 && parseDateValue (response .getHeader (HttpHeaders . LAST_MODIFIED )) == -1 ) {
239
+ response .setDateHeader (HttpHeaders . LAST_MODIFIED , lastModifiedTimestamp );
249
240
}
250
- if (StringUtils .hasLength (etag ) && response .getHeader (ETAG ) == null ) {
251
- response .setHeader (ETAG , padEtagIfNecessary (etag ));
241
+ if (StringUtils .hasLength (etag ) && response .getHeader (HttpHeaders . ETAG ) == null ) {
242
+ response .setHeader (HttpHeaders . ETAG , padEtagIfNecessary (etag ));
252
243
}
253
244
}
254
245
}
@@ -260,7 +251,7 @@ private boolean validateIfUnmodifiedSince(long lastModifiedTimestamp) {
260
251
if (lastModifiedTimestamp < 0 ) {
261
252
return false ;
262
253
}
263
- long ifUnmodifiedSince = parseDateHeader (IF_UNMODIFIED_SINCE );
254
+ long ifUnmodifiedSince = parseDateHeader (HttpHeaders . IF_UNMODIFIED_SINCE );
264
255
if (ifUnmodifiedSince == -1 ) {
265
256
return false ;
266
257
}
@@ -276,7 +267,7 @@ private boolean validateIfNoneMatch(@Nullable String etag) {
276
267
277
268
Enumeration <String > ifNoneMatch ;
278
269
try {
279
- ifNoneMatch = getRequest ().getHeaders (IF_NONE_MATCH );
270
+ ifNoneMatch = getRequest ().getHeaders (HttpHeaders . IF_NONE_MATCH );
280
271
}
281
272
catch (IllegalArgumentException ex ) {
282
273
return false ;
@@ -319,7 +310,7 @@ private boolean validateIfModifiedSince(long lastModifiedTimestamp) {
319
310
if (lastModifiedTimestamp < 0 ) {
320
311
return false ;
321
312
}
322
- long ifModifiedSince = parseDateHeader (IF_MODIFIED_SINCE );
313
+ long ifModifiedSince = parseDateHeader (HttpHeaders . IF_MODIFIED_SINCE );
323
314
if (ifModifiedSince == -1 ) {
324
315
return false ;
325
316
}
0 commit comments