Merge branch '5.1.x'
This commit is contained in:
@@ -36,7 +36,6 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.reactive.ClientHttpResponse;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.HttpMessageWriter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.reactive.function.BodyExtractor;
|
||||
|
||||
@@ -61,17 +60,17 @@ import org.springframework.web.reactive.function.BodyExtractor;
|
||||
public interface ClientResponse {
|
||||
|
||||
/**
|
||||
* Return the status code of this response.
|
||||
* @return the status as an HttpStatus enum value
|
||||
* Return the HTTP status code as an {@link HttpStatus} enum value.
|
||||
* @return the HTTP status as an HttpStatus enum value (never {@code null})
|
||||
* @throws IllegalArgumentException in case of an unknown HTTP status code
|
||||
* @see HttpStatus#resolve(int)
|
||||
* @since #getRawStatusCode()
|
||||
* @see HttpStatus#valueOf(int)
|
||||
*/
|
||||
@Nullable
|
||||
HttpStatus statusCode();
|
||||
|
||||
/**
|
||||
* Return the (potentially non-standard) status code of this response.
|
||||
* @return the status as an integer
|
||||
* @return the HTTP status as an integer value
|
||||
* @since 5.1
|
||||
* @see #statusCode()
|
||||
* @see HttpStatus#resolve(int)
|
||||
|
||||
@@ -203,7 +203,7 @@ final class DefaultClientResponseBuilder implements ClientResponse.Builder {
|
||||
|
||||
@Override
|
||||
public HttpStatus getStatusCode() {
|
||||
return HttpStatus.resolve(this.statusCode);
|
||||
return HttpStatus.valueOf(this.statusCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.reactive.function.client;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -31,18 +30,15 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class DefaultClientResponseBuilderTests {
|
||||
|
||||
private DataBufferFactory dataBufferFactory;
|
||||
private final DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
|
||||
|
||||
@Before
|
||||
public void createBufferFactory() {
|
||||
this.dataBufferFactory = new DefaultDataBufferFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void normal() {
|
||||
@@ -102,16 +98,11 @@ public class DefaultClientResponseBuilderTests {
|
||||
|
||||
@Test
|
||||
public void fromCustomStatus() {
|
||||
|
||||
ClientResponse other = ClientResponse.create(499, ExchangeStrategies.withDefaults())
|
||||
.build();
|
||||
|
||||
ClientResponse result = ClientResponse.from(other)
|
||||
.build();
|
||||
ClientResponse other = ClientResponse.create(499, ExchangeStrategies.withDefaults()).build();
|
||||
ClientResponse result = ClientResponse.from(other).build();
|
||||
|
||||
assertThat(result.rawStatusCode()).isEqualTo(499);
|
||||
assertThat(result.statusCode()).isNull();
|
||||
assertThatIllegalArgumentException().isThrownBy(result::statusCode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user