@@ -86,8 +86,7 @@ class DefaultServerRequest implements ServerRequest {
86
86
private final Map <String , Object > attributes ;
87
87
88
88
89
- public DefaultServerRequest (HttpServletRequest servletRequest ,
90
- List <HttpMessageConverter <?>> messageConverters ) {
89
+ public DefaultServerRequest (HttpServletRequest servletRequest , List <HttpMessageConverter <?>> messageConverters ) {
91
90
this .serverHttpRequest = new ServletServerHttpRequest (servletRequest );
92
91
this .messageConverters = Collections .unmodifiableList (new ArrayList <>(messageConverters ));
93
92
this .allSupportedMediaTypes = allSupportedMediaTypes (messageConverters );
@@ -104,6 +103,7 @@ private static List<MediaType> allSupportedMediaTypes(List<HttpMessageConverter<
104
103
.collect (Collectors .toList ());
105
104
}
106
105
106
+
107
107
@ Override
108
108
public String methodName () {
109
109
return servletRequest ().getMethod ();
@@ -187,11 +187,8 @@ static Class<?> bodyClass(Type type) {
187
187
}
188
188
189
189
@ SuppressWarnings ("unchecked" )
190
- private <T > T bodyInternal (Type bodyType , Class <?> bodyClass )
191
- throws ServletException , IOException {
192
-
193
- MediaType contentType =
194
- this .headers .contentType ().orElse (MediaType .APPLICATION_OCTET_STREAM );
190
+ private <T > T bodyInternal (Type bodyType , Class <?> bodyClass ) throws ServletException , IOException {
191
+ MediaType contentType = this .headers .contentType ().orElse (MediaType .APPLICATION_OCTET_STREAM );
195
192
196
193
for (HttpMessageConverter <?> messageConverter : this .messageConverters ) {
197
194
if (messageConverter instanceof GenericHttpMessageConverter ) {
@@ -232,10 +229,10 @@ public MultiValueMap<String, String> params() {
232
229
}
233
230
234
231
@ Override
232
+ @ SuppressWarnings ("unchecked" )
235
233
public Map <String , String > pathVariables () {
236
- @ SuppressWarnings ("unchecked" )
237
- Map <String , String > pathVariables = (Map <String , String >) servletRequest ()
238
- .getAttribute (RouterFunctions .URI_TEMPLATE_VARIABLES_ATTRIBUTE );
234
+ Map <String , String > pathVariables = (Map <String , String >)
235
+ servletRequest ().getAttribute (RouterFunctions .URI_TEMPLATE_VARIABLES_ATTRIBUTE );
239
236
if (pathVariables != null ) {
240
237
return pathVariables ;
241
238
}
@@ -254,8 +251,9 @@ public Optional<Principal> principal() {
254
251
return Optional .ofNullable (this .serverHttpRequest .getPrincipal ());
255
252
}
256
253
257
- static Optional <ServerResponse > checkNotModified (HttpServletRequest servletRequest , @ Nullable Instant lastModified ,
258
- @ Nullable String etag ) {
254
+
255
+ static Optional <ServerResponse > checkNotModified (
256
+ HttpServletRequest servletRequest , @ Nullable Instant lastModified , @ Nullable String etag ) {
259
257
260
258
long lastModifiedTimestamp = -1 ;
261
259
if (lastModified != null && lastModified .isAfter (Instant .EPOCH )) {
@@ -274,14 +272,14 @@ static Optional<ServerResponse> checkNotModified(HttpServletRequest servletReque
274
272
}
275
273
}
276
274
275
+
277
276
/**
278
277
* Default implementation of {@link Headers}.
279
278
*/
280
279
static class DefaultRequestHeaders implements Headers {
281
280
282
281
private final HttpHeaders delegate ;
283
282
284
-
285
283
public DefaultRequestHeaders (HttpHeaders delegate ) {
286
284
this .delegate = delegate ;
287
285
}
@@ -339,11 +337,11 @@ public String toString() {
339
337
}
340
338
}
341
339
340
+
342
341
private static final class ServletParametersMap extends AbstractMap <String , List <String >> {
343
342
344
343
private final HttpServletRequest servletRequest ;
345
344
346
-
347
345
private ServletParametersMap (HttpServletRequest servletRequest ) {
348
346
this .servletRequest = servletRequest ;
349
347
}
@@ -389,7 +387,6 @@ public List<String> remove(Object key) {
389
387
public void clear () {
390
388
throw new UnsupportedOperationException ();
391
389
}
392
-
393
390
}
394
391
395
392
@@ -443,17 +440,15 @@ public Object remove(Object key) {
443
440
this .servletRequest .removeAttribute (name );
444
441
return value ;
445
442
}
446
-
447
-
448
443
}
449
444
445
+
450
446
/**
451
447
* Simple implementation of {@link HttpServletResponse} used by
452
448
* {@link #checkNotModified(HttpServletRequest, Instant, String)} to record status and headers set by
453
449
* {@link ServletWebRequest#checkNotModified(String, long)}. Throws an {@code UnsupportedOperationException}
454
450
* for other methods.
455
451
*/
456
- @ SuppressWarnings ("deprecation" )
457
452
private static final class CheckNotModifiedResponse implements HttpServletResponse {
458
453
459
454
private final HttpHeaders headers = new HttpHeaders ();
@@ -486,6 +481,7 @@ public void setStatus(int sc) {
486
481
}
487
482
488
483
@ Override
484
+ @ Deprecated
489
485
public void setStatus (int sc , String sm ) {
490
486
this .status = sc ;
491
487
}
@@ -496,14 +492,15 @@ public int getStatus() {
496
492
}
497
493
498
494
@ Override
495
+ @ Nullable
499
496
public String getHeader (String name ) {
500
497
return this .headers .getFirst (name );
501
498
}
502
499
503
500
@ Override
504
501
public Collection <String > getHeaders (String name ) {
505
502
List <String > result = this .headers .get (name );
506
- return result != null ? result : Collections .emptyList ();
503
+ return ( result != null ? result : Collections .emptyList () );
507
504
}
508
505
509
506
@ Override
@@ -513,6 +510,7 @@ public Collection<String> getHeaderNames() {
513
510
514
511
515
512
// Unsupported
513
+
516
514
@ Override
517
515
public void addCookie (Cookie cookie ) {
518
516
throw new UnsupportedOperationException ();
@@ -529,11 +527,13 @@ public String encodeRedirectURL(String url) {
529
527
}
530
528
531
529
@ Override
530
+ @ Deprecated
532
531
public String encodeUrl (String url ) {
533
532
throw new UnsupportedOperationException ();
534
533
}
535
534
536
535
@ Override
536
+ @ Deprecated
537
537
public String encodeRedirectUrl (String url ) {
538
538
throw new UnsupportedOperationException ();
539
539
}
0 commit comments