Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Use HttpStatusCode instead of magic value 200. #34223

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ProblemDetail;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -237,18 +239,18 @@ else if (returnValue instanceof ProblemDetail detail) {
}

if (httpEntity instanceof ResponseEntity<?> responseEntity) {
int returnStatus = responseEntity.getStatusCode().value();
outputMessage.getServletResponse().setStatus(returnStatus);
if (returnStatus == 200) {
HttpStatusCode httpStatusCode = responseEntity.getStatusCode();
outputMessage.getServletResponse().setStatus(httpStatusCode.value());
if (HttpStatus.OK.value() == httpStatusCode.value()) {
remeio marked this conversation as resolved.
Show resolved Hide resolved
HttpMethod method = inputMessage.getMethod();
if ((HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method))
&& isResourceNotModified(inputMessage, outputMessage)) {
outputMessage.flush();
return;
}
}
else if (returnStatus / 100 == 3) {
String location = outputHeaders.getFirst("location");
else if (httpStatusCode.is3xxRedirection()) {
String location = outputHeaders.getFirst(HttpHeaders.LOCATION);
if (location != null) {
saveFlashAttributes(mavContainer, webRequest, location);
}
Expand Down
Loading