Send error signal also for empty server responses

Prior to that commit, the `ResponseSpec` `WebClient` would process error
responses (4xx, 5xx HTTP status) and transform those into error signals
with a `WebClientResponseException`. But this would only work if the
HTTP response would have a non-empty response body.

An empty error response would not send an error signal and only
translate in an `onComplete` signal.

This commit fixes this behavior and makes sure that this error signal is
sent in all cases.

Issue: SPR-15946
This commit is contained in:
Brian Clozel
2017-09-13 10:56:57 +02:00
parent aa19912e00
commit 98b6491f0c
2 changed files with 23 additions and 4 deletions

View File

@@ -483,6 +483,7 @@ class DefaultWebClient implements WebClient {
DataBufferUtils.release(dataBuffer);
return bytes;
})
.defaultIfEmpty(new byte[0])
.map(bodyBytes -> {
String msg = String.format("ClientResponse has erroneous status code: %d %s", response.statusCode().value(),
response.statusCode().getReasonPhrase());