|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
33 | 33 | import org.springframework.http.HttpEntity;
|
34 | 34 | import org.springframework.http.HttpHeaders;
|
35 | 35 | import org.springframework.http.HttpMethod;
|
| 36 | +import org.springframework.http.HttpStatus; |
| 37 | +import org.springframework.http.HttpStatusCode; |
36 | 38 | import org.springframework.http.ProblemDetail;
|
37 | 39 | import org.springframework.http.RequestEntity;
|
38 | 40 | import org.springframework.http.ResponseEntity;
|
@@ -239,18 +241,18 @@ else if (returnValue instanceof ProblemDetail detail) {
|
239 | 241 | }
|
240 | 242 |
|
241 | 243 | if (httpEntity instanceof ResponseEntity<?> responseEntity) {
|
242 |
| - int returnStatus = responseEntity.getStatusCode().value(); |
243 |
| - outputMessage.getServletResponse().setStatus(returnStatus); |
244 |
| - if (returnStatus == 200) { |
| 244 | + HttpStatusCode returnStatus = responseEntity.getStatusCode(); |
| 245 | + outputMessage.getServletResponse().setStatus(returnStatus.value()); |
| 246 | + if (returnStatus.value() == HttpStatus.OK.value()) { |
245 | 247 | HttpMethod method = inputMessage.getMethod();
|
246 | 248 | if ((HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method))
|
247 | 249 | && isResourceNotModified(inputMessage, outputMessage)) {
|
248 | 250 | outputMessage.flush();
|
249 | 251 | return;
|
250 | 252 | }
|
251 | 253 | }
|
252 |
| - else if (returnStatus / 100 == 3) { |
253 |
| - String location = outputHeaders.getFirst("location"); |
| 254 | + else if (returnStatus.is3xxRedirection()) { |
| 255 | + String location = outputHeaders.getFirst(HttpHeaders.LOCATION); |
254 | 256 | if (location != null) {
|
255 | 257 | saveFlashAttributes(mavContainer, webRequest, location);
|
256 | 258 | }
|
|
0 commit comments