Package org.springframework.web.client
Class UnknownContentTypeException
- java.lang.Object
- java.lang.Throwable
- java.lang.Exception
- java.lang.RuntimeException
- org.springframework.core.NestedRuntimeException
- org.springframework.web.client.RestClientException
- org.springframework.web.client.UnknownContentTypeException
- All Implemented Interfaces:
Serializable
public class UnknownContentTypeException extends RestClientException
Raised when no suitableHttpMessageConverter
could be found to extract the response.- Since:
- 5.2.7
- Author:
- Rossen Stoyanchev
- See Also:
- Serialized Form
Constructor Summary
Constructors Constructor Description UnknownContentTypeException(Type targetType, MediaType contentType, int statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody)
Construct a new instance of with the given response data.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MediaType
getContentType()
Return the content type of the response, or "application/octet-stream".int
getRawStatusCode()
Return the raw HTTP status code value.byte[]
getResponseBody()
Return the response body as a byte array.String
getResponseBodyAsString()
Return the response body converted to String using the charset from the response "Content-Type" or"UTF-8"
otherwise.HttpHeaders
getResponseHeaders()
Return the HTTP response headers.String
getStatusText()
Return the HTTP status text.Type
getTargetType()
Return the target type expected for the response.Methods inherited from class org.springframework.core.NestedRuntimeException
contains, getMessage, getMostSpecificCause, getRootCause
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Constructor Detail
UnknownContentTypeException
public UnknownContentTypeException(Type targetType, MediaType contentType, int statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody)
Construct a new instance of with the given response data.- Parameters:
targetType
- the expected target typecontentType
- the content type of the responsestatusCode
- the raw status code valuestatusText
- the status textresponseHeaders
- the response headers (may benull
)responseBody
- the response body content (may benull
)
Method Detail
getTargetType
public Type getTargetType()
Return the target type expected for the response.
getContentType
public MediaType getContentType()
Return the content type of the response, or "application/octet-stream".
getRawStatusCode
public int getRawStatusCode()
Return the raw HTTP status code value.
getStatusText
public String getStatusText()
Return the HTTP status text.
getResponseHeaders
@Nullable public HttpHeaders getResponseHeaders()
Return the HTTP response headers.
getResponseBody
public byte[] getResponseBody()
Return the response body as a byte array.
getResponseBodyAsString
public String getResponseBodyAsString()
Return the response body converted to String using the charset from the response "Content-Type" or"UTF-8"
otherwise.