public class WebClientResponseException extends WebClientException
| Constructor and Description |
|---|
WebClientResponseException(int statusCode,
String statusText,
HttpHeaders headers,
byte[] body,
Charset charset)
Constructor with response data only, and a default message.
|
WebClientResponseException(int status,
String reasonPhrase,
HttpHeaders headers,
byte[] body,
Charset charset,
HttpRequest request)
Constructor with response data only, and a default message.
|
WebClientResponseException(String message,
int statusCode,
String statusText,
HttpHeaders headers,
byte[] responseBody,
Charset charset)
Constructor with a prepared message.
|
WebClientResponseException(String message,
int statusCode,
String statusText,
HttpHeaders headers,
byte[] responseBody,
Charset charset,
HttpRequest request)
Constructor with a prepared message.
|
| Modifier and Type | Method and Description |
|---|---|
static WebClientResponseException |
create(int statusCode,
String statusText,
HttpHeaders headers,
byte[] body,
Charset charset)
Create
WebClientResponseException or an HTTP status specific subclass. |
static WebClientResponseException |
create(int statusCode,
String statusText,
HttpHeaders headers,
byte[] body,
Charset charset,
HttpRequest request)
Create
WebClientResponseException or an HTTP status specific subclass. |
HttpHeaders |
getHeaders()
Return the HTTP response headers.
|
int |
getRawStatusCode()
Return the raw HTTP status code value.
|
HttpRequest |
getRequest()
Return the corresponding request.
|
byte[] |
getResponseBodyAsByteArray()
Return the response body as a byte array.
|
String |
getResponseBodyAsString()
Return the response content as a String using the charset of media type
for the response, if available, or otherwise falling back on
ISO-8859-1.
|
String |
getResponseBodyAsString(Charset defaultCharset)
Variant of
getResponseBodyAsString() that allows specifying the
charset to fall back on, if a charset is not available from the media
type for the response. |
HttpStatus |
getStatusCode()
Return the HTTP status code value.
|
String |
getStatusText()
Return the HTTP status text.
|
contains, getMessage, getMostSpecificCause, getRootCauseaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic WebClientResponseException(int statusCode,
String statusText,
@Nullable
HttpHeaders headers,
@Nullable
byte[] body,
@Nullable
Charset charset)
public WebClientResponseException(int status,
String reasonPhrase,
@Nullable
HttpHeaders headers,
@Nullable
byte[] body,
@Nullable
Charset charset,
@Nullable
HttpRequest request)
public WebClientResponseException(String message, int statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset charset)
public WebClientResponseException(String message, int statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset charset, @Nullable HttpRequest request)
public HttpStatus getStatusCode()
IllegalArgumentException - in case of an unknown HTTP status codepublic int getRawStatusCode()
public String getStatusText()
public HttpHeaders getHeaders()
public byte[] getResponseBodyAsByteArray()
public String getResponseBodyAsString()
getResponseBodyAsString(Charset) if
you want to fall back on a different, default charset.public String getResponseBodyAsString(Charset defaultCharset)
getResponseBodyAsString() that allows specifying the
charset to fall back on, if a charset is not available from the media
type for the response.defaultCharset - the charset to use if the Content-Type
of the response does not specify one.@Nullable public HttpRequest getRequest()
public static WebClientResponseException create(int statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset)
WebClientResponseException or an HTTP status specific subclass.public static WebClientResponseException create(int statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, @Nullable HttpRequest request)
WebClientResponseException or an HTTP status specific subclass.