Package com.helger.httpclient.response
Class ExtendedHttpResponseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
org.apache.hc.client5.http.ClientProtocolException
org.apache.hc.client5.http.HttpResponseException
com.helger.httpclient.response.ExtendedHttpResponseException
- All Implemented Interfaces:
Serializable
public class ExtendedHttpResponseException
extends org.apache.hc.client5.http.HttpResponseException
A specialized version of
HttpResponseException that has access to all the fields in a
structured way.- Since:
- 8.8.1
- Author:
- Philip Helger
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionExtendedHttpResponseException(org.apache.hc.core5.http.message.StatusLine aStatusLine, org.apache.hc.core5.http.HttpResponse aHttpResponse, byte[] aResponseBody, Charset aCharset) -
Method Summary
Modifier and TypeMethodDescriptioncreate(org.apache.hc.core5.http.ClassicHttpResponse aHttpResponse) create(org.apache.hc.core5.http.message.StatusLine aStatusLine, org.apache.hc.core5.http.HttpResponse aHttpResponse, org.apache.hc.core5.http.HttpEntity aEntity) final byte[]final org.apache.hc.core5.http.HttpResponsefinal byte[]final Stringfinal StringgetResponseBodyAsString(Charset aCharset) Get the response body as a string in the provided charset.final Charsetfinal org.apache.hc.core5.http.message.StatusLinefinal booleanMethods inherited from class org.apache.hc.client5.http.HttpResponseException
getContentBytes, getContentType, getReasonPhrase, getStatusCodeMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ExtendedHttpResponseException
public ExtendedHttpResponseException(@Nonnull org.apache.hc.core5.http.message.StatusLine aStatusLine, @Nonnull org.apache.hc.core5.http.HttpResponse aHttpResponse, @Nullable byte[] aResponseBody, @Nonnull Charset aCharset)
-
-
Method Details
-
getStatusLine
@Nonnull public final org.apache.hc.core5.http.message.StatusLine getStatusLine()- Returns:
- The status line received. Never
null.
-
getHttpResponse
@Nonnull public final org.apache.hc.core5.http.HttpResponse getHttpResponse()- Returns:
- The HTTP response object that triggered the exception. May not be
null. May be used to determine the headers of the response.
-
directGetResponseBody
@Nullable @ReturnsMutableObject public final byte[] directGetResponseBody()- Returns:
- The response body bytes. May be
null.
-
getResponseBody
@Nullable @ReturnsMutableCopy public final byte[] getResponseBody()- Returns:
- A copy of the response body bytes. May be
null.
-
hasResponseBody
public final boolean hasResponseBody()- Returns:
trueif a response body is present,falseotherwise.
-
getResponseCharset
- Returns:
- The response charset. Never
null.
-
getResponseBodyAsString
- Returns:
- The response body as a string in the response charset. May be
nullif no response body is present. - See Also:
-
getResponseBodyAsString
Get the response body as a string in the provided charset.- Parameters:
aCharset- The charset to use. May not benull.- Returns:
nullif no response body is present.
-
getMessagePartStatusLine
-
getMessagePartHeaders
-
getMessagePartResponseBody
-
getMessage
- Overrides:
getMessagein classThrowable
-
create
@Nonnull public static ExtendedHttpResponseException create(@Nonnull org.apache.hc.core5.http.ClassicHttpResponse aHttpResponse) throws IOException - Throws:
IOException
-
create
@Nonnull public static ExtendedHttpResponseException create(@Nonnull org.apache.hc.core5.http.message.StatusLine aStatusLine, @Nonnull org.apache.hc.core5.http.HttpResponse aHttpResponse, @Nonnull org.apache.hc.core5.http.HttpEntity aEntity) throws IOException - Throws:
IOException
-