Improve handling of unknown status codes by WebClient [SPR-16819] #21359
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Denys Ivano opened SPR-16819 and commented
Currently, there are some issues with using
WebClient
for calling HTTP services which return unknown status codes (couldn't be resolved throughHttpStatus
enum).ClientResponse
interface doesn't provide an opportunity to obtain status code value asint
. Usingexchange()
method is safe with unknown status codes, but the raw status code value couldn't be obtained without reflexion. In 5.0.6 the methodgetRawStatusCode()
was introduced inClientHttpResponse
(see No support for non-standard HTTP status codes in reactive ClientHttpResponse [SPR-16748] #21289).DefaultClientResponse
(default implementation ofClientResponse
) wrapsClientHttpResponse
, so the status code can be obtained by introducing new method in reactiveClientResponse
interface.It's not possible to use
retrieve()
with unknown status codes because it always throwsIllegalArgumentException
:That's because the default implementation uses error handling based on
HttpStatus
enum value. It would be a good idea to use raw status value instead and provide an opportunity to register error handlers based on raw status code value.I've submited PR 1829 which is going to resolve these issues.
Affects: 5.0.6
Issue Links:
Referenced from: pull request #1829, and commits 038af9a
The text was updated successfully, but these errors were encountered: