While trying to access the http status from an interceptor on the RestTemplate I'm getting the following exception:
No matching constant for [521] at
org.springframework.http.HttpStatus.valueOf(HttpStatus.java:538) at
org.springframework.http.client.AbstractClientHttpResponse.getStatusCode(AbstractClientHttpResponse.java:33) at
org.springframework.http.client.BufferingClientHttpResponseWrapper.getStatusCode(BufferingClientHttpResponseWrapper.java:50)
It seems that 521 (Web server is down) isn't a valid value for org.springframework.http.HttpStatus. I can just get the raw number but does it make sense to support it from Spring side?
Comment From: sbrannen
According to this Wikipedia article:
Cloudflare's reverse proxy service expands the 5xx series of errors space to signal issues with the origin server.
Since 521 is specific to Cloudfare and since HttpStatus does not currently define any enum constants specific to Cloudfare, we generally recommend that you access the raw status code for such use cases.
Comment From: rstoyanchev
You should be able to access that via ClientHttpResponse#getRawStatusCode().
Comment From: rstoyanchev
Ignore my comment. What @sbrannen said.