Skip to content

Commit

Permalink
Merge pull request #34223 from remeio
Browse files Browse the repository at this point in the history
* pr/34223:
  Polish contribution
  Polish HttpEntityMethodProcessor

Closes gh-34223
  • Loading branch information
snicoll committed Jan 14, 2025
2 parents cd1aefa + 24fa9ea commit e08a7ec
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,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 @@ -239,18 +241,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 returnStatus = responseEntity.getStatusCode();
outputMessage.getServletResponse().setStatus(returnStatus.value());
if (returnStatus.value() == HttpStatus.OK.value()) {
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 (returnStatus.is3xxRedirection()) {
String location = outputHeaders.getFirst(HttpHeaders.LOCATION);
if (location != null) {
saveFlashAttributes(mavContainer, webRequest, location);
}
Expand Down

0 comments on commit e08a7ec

Please sign in to comment.