diff --git a/spring-test/src/main/java/org/springframework/mock/http/client/reactive/MockClientHttpResponse.java b/spring-test/src/main/java/org/springframework/mock/http/client/reactive/MockClientHttpResponse.java
index d14abc1fb3e..ee0673c33bd 100644
--- a/spring-test/src/main/java/org/springframework/mock/http/client/reactive/MockClientHttpResponse.java
+++ b/spring-test/src/main/java/org/springframework/mock/http/client/reactive/MockClientHttpResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -40,6 +40,7 @@ import org.springframework.util.MultiValueMap;
/**
* Mock implementation of {@link ClientHttpResponse}.
+ *
* @author Brian Clozel
* @author Rossen Stoyanchev
* @since 5.0
@@ -68,6 +69,11 @@ public class MockClientHttpResponse implements ClientHttpResponse {
return this.status;
}
+ @Override
+ public int getRawStatusCode() {
+ return this.status.value();
+ }
+
@Override
public HttpHeaders getHeaders() {
String headerName = HttpHeaders.SET_COOKIE;
@@ -138,4 +144,4 @@ public class MockClientHttpResponse implements ClientHttpResponse {
return (charset != null ? charset : StandardCharsets.UTF_8);
}
-}
\ No newline at end of file
+}
diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponse.java
index df478d432ae..a9f2f7c063a 100644
--- a/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponse.java
+++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -31,10 +31,23 @@ import org.springframework.util.MultiValueMap;
public interface ClientHttpResponse extends ReactiveHttpInputMessage {
/**
- * Return the HTTP status as an {@link HttpStatus} enum value.
+ * Return the HTTP status code of the response.
+ * @return the HTTP status as an HttpStatus enum value
+ * @throws IllegalArgumentException in case of an unknown HTTP status code
+ * @see HttpStatus#valueOf(int)
*/
HttpStatus getStatusCode();
+ /**
+ * Return the HTTP status code (potentially non-standard and not
+ * resolvable through the {@link HttpStatus} enum) as an integer.
+ * @return the HTTP status as an integer
+ * @since 5.0.6
+ * @see #getStatusCode()
+ * @see HttpStatus#resolve(int)
+ */
+ int getRawStatusCode();
+
/**
* Return a read-only map of response cookies received from the server.
*/
diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponseDecorator.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponseDecorator.java
index 199a9495cff..2ca32e3de6d 100644
--- a/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponseDecorator.java
+++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponseDecorator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -55,6 +55,11 @@ public class ClientHttpResponseDecorator implements ClientHttpResponse {
return this.delegate.getStatusCode();
}
+ @Override
+ public int getRawStatusCode() {
+ return this.delegate.getRawStatusCode();
+ }
+
@Override
public HttpHeaders getHeaders() {
return this.delegate.getHeaders();
diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpResponse.java
index 54aea4ae730..adbf6b1b5f2 100644
--- a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpResponse.java
+++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -62,14 +62,18 @@ class ReactorClientHttpResponse implements ClientHttpResponse {
@Override
public HttpHeaders getHeaders() {
HttpHeaders headers = new HttpHeaders();
- this.response.responseHeaders().entries()
- .forEach(e -> headers.add(e.getKey(), e.getValue()));
+ this.response.responseHeaders().entries().forEach(e -> headers.add(e.getKey(), e.getValue()));
return headers;
}
@Override
public HttpStatus getStatusCode() {
- return HttpStatus.valueOf(this.response.status().code());
+ return HttpStatus.valueOf(getRawStatusCode());
+ }
+
+ @Override
+ public int getRawStatusCode() {
+ return this.response.status().code();
}
@Override
@@ -91,7 +95,7 @@ class ReactorClientHttpResponse implements ClientHttpResponse {
public String toString() {
return "ReactorClientHttpResponse{" +
"request=[" + this.response.method().name() + " " + this.response.uri() + "]," +
- "status=" + getStatusCode() + '}';
+ "status=" + getRawStatusCode() + '}';
}
}
diff --git a/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java b/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java
index 88554014e0c..8fc030bb242 100644
--- a/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java
+++ b/spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -40,6 +40,7 @@ import org.springframework.util.MultiValueMap;
/**
* Mock implementation of {@link ClientHttpResponse}.
+ *
* @author Brian Clozel
* @author Rossen Stoyanchev
* @since 5.0
@@ -68,6 +69,11 @@ public class MockClientHttpResponse implements ClientHttpResponse {
return this.status;
}
+ @Override
+ public int getRawStatusCode() {
+ return this.status.value();
+ }
+
@Override
public HttpHeaders getHeaders() {
String headerName = HttpHeaders.SET_COOKIE;
@@ -138,4 +144,4 @@ public class MockClientHttpResponse implements ClientHttpResponse {
return (charset != null ? charset : StandardCharsets.UTF_8);
}
-}
\ No newline at end of file
+}
diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java
index 9cc9d0c50a6..b9fb4a78bc5 100644
--- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java
+++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java
@@ -86,7 +86,6 @@ public interface ClientRequest {
}
}
-
/**
* Return the attributes of this request.
*/
@@ -222,8 +221,7 @@ public interface ClientRequest {
* @param
the type of the {@code Publisher}
* @return the built request
*/
- > Builder body(P publisher,
- ParameterizedTypeReference typeReference);
+ > Builder body(P publisher, ParameterizedTypeReference typeReference);
/**
* Set the attribute with the given name to the given value.
@@ -243,8 +241,7 @@ public interface ClientRequest {
Builder attributes(Consumer