Exception HttpResponseException (1.45.3)

public class HttpResponseException extends IOException

Exception thrown when an error status code is detected in an HTTP response.

Implementation is not thread safe.

Static Methods

computeMessageBuffer(HttpResponse response)

public static StringBuilder computeMessageBuffer(HttpResponse response)

Returns an exception message string builder to use for the given HTTP response.

Parameter
Name Description
response HttpResponse
Returns
Type Description
StringBuilder

Constructors

HttpResponseException(HttpResponse response)

public HttpResponseException(HttpResponse response)

Constructor that constructs a detail message from the given HTTP response that includes the status code, status message and HTTP response content.

Callers of this constructor should call HttpResponse#disconnect after HttpResponseException is instantiated. Example usage:

try { throw new HttpResponseException(response); } finally { response.disconnect(); }

Parameter
Name Description
response HttpResponse

HTTP response

HttpResponseException(HttpResponseException.Builder builder)

protected HttpResponseException(HttpResponseException.Builder builder)
Parameter
Name Description
builder HttpResponseException.Builder

builder

Methods

getAttemptCount()

public final int getAttemptCount()

Returns the attempt count

Returns
Type Description
int

getContent()

public final String getContent()

Returns the HTTP response content or null for none.

Returns
Type Description
String

getHeaders()

public HttpHeaders getHeaders()

Returns the HTTP response headers.

Returns
Type Description
HttpHeaders

getStatusCode()

public final int getStatusCode()

Returns the HTTP status code or 0 for none.

Returns
Type Description
int

getStatusMessage()

public final String getStatusMessage()

Returns the HTTP status message or null for none.

Returns
Type Description
String

isSuccessStatusCode()

public final boolean isSuccessStatusCode()

Returns whether received a successful HTTP status code >= 200 && < 300 (see #getStatusCode()).

Returns
Type Description
boolean