WebClientException should allow access to status code of the response

This commit changes the WebClient so that it now throws a
`WebClientResponseException` for `ResponseSpec.bodyTo`. This newly
introduces exception contains the status code, headers, and body of the
response message.

As a consequence of the above, we had to change `onStatus` so that the
`exceptionFunction` now returns a `Mono<Throwable>` rather than a
`Throwable`, which it was before. The Mono allows for asynchronous
operations, such as reading the contents of the body.

Issue: SPR-15824
This commit is contained in:
Arjen Poutsma
2017-08-02 10:19:05 +02:00
parent b6d1fd9d22
commit 5394cc0c63
6 changed files with 216 additions and 52 deletions

View File

@@ -73,6 +73,10 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
private static final long serialVersionUID = -8578554704772377436L;
/**
* The empty {@code HttpHeaders} instance (immutable).
*/
public static final HttpHeaders EMPTY = new HttpHeaders(new LinkedHashMap<>(0), true);
/**
* The HTTP {@code Accept} header field name.
* @see <a href="http://tools.ietf.org/html/rfc7231#section-5.3.2">Section 5.3.2 of RFC 7231</a>