public interface

Response

com.ning.http.client.Response
Known Indirect Subclasses

Class Overview

Represents the asynchronous HTTP response callback for an AsyncCompletionHandler

Summary

Nested Classes
class Response.ResponseBuilder  
Public Methods
abstract String getContentType()
Return the content-type header value.
abstract List<Cookie> getCookies()
Return the list of Cookie.
abstract String getHeader(String name)
Return the response header
abstract FluentCaseInsensitiveStringsMap getHeaders()
abstract List<String> getHeaders(String name)
Return a List of the response header value.
abstract String getResponseBody()
Return the entire response body as a String.
abstract String getResponseBody(String charset)
Return the entire response body as a String.
abstract byte[] getResponseBodyAsBytes()
Return the entire response body as a byte[].
abstract InputStream getResponseBodyAsStream()
Returns an input stream for the response body.
abstract String getResponseBodyExcerpt(int maxLength)
Returns the first maxLength bytes of the response body as a string.
abstract String getResponseBodyExcerpt(int maxLength, String charset)
Returns the first maxLength bytes of the response body as a string.
abstract int getStatusCode()
Returns the status code for the request.
abstract String getStatusText()
Returns the status text for the request.
abstract URI getUri()
Return the request URI.
abstract boolean hasResponseBody()
Return true if the response's body has been computed by an AsyncHandler.
abstract boolean hasResponseHeaders()
Return true if the response's headers has been computed by an AsyncHandler It will return false if the either onStatusReceived(HttpResponseStatus) or onHeadersReceived(HttpResponseHeaders) returned ABORT
abstract boolean hasResponseStatus()
Return true if the response's status has been computed by an AsyncHandler
abstract boolean isRedirected()
Return true if the response redirects to another object.
abstract String toString()
Subclasses SHOULD implement toString() in a way that identifies the request for logging.

Public Methods

public abstract String getContentType ()

Return the content-type header value.

Returns
  • the content-type header value.

public abstract List<Cookie> getCookies ()

Return the list of Cookie.

public abstract String getHeader (String name)

Return the response header

Returns
  • the response header

public abstract FluentCaseInsensitiveStringsMap getHeaders ()

public abstract List<String> getHeaders (String name)

Return a List of the response header value.

Returns
  • the response header

public abstract String getResponseBody ()

Return the entire response body as a String.

Returns
  • the entire response body as a String.
Throws
IOException

public abstract String getResponseBody (String charset)

Return the entire response body as a String.

Parameters
charset the charset to use when decoding the stream
Returns
  • the entire response body as a String.
Throws
IOException

public abstract byte[] getResponseBodyAsBytes ()

Return the entire response body as a byte[].

Returns
  • the entire response body as a byte[].
Throws
IOException

public abstract InputStream getResponseBodyAsStream ()

Returns an input stream for the response body. Note that you should not try to get this more than once, and that you should not close the stream.

Returns
  • The input stream
Throws
IOException

public abstract String getResponseBodyExcerpt (int maxLength)

Returns the first maxLength bytes of the response body as a string. Note that this does not check whether the content type is actually a textual one, but it will use the charset if present in the content type header.

Parameters
maxLength The maximum number of bytes to read
Returns
  • The response body
Throws
IOException

public abstract String getResponseBodyExcerpt (int maxLength, String charset)

Returns the first maxLength bytes of the response body as a string. Note that this does not check whether the content type is actually a textual one, but it will use the charset if present in the content type header.

Parameters
maxLength The maximum number of bytes to read
charset the charset to use when decoding the stream
Returns
  • The response body
Throws
IOException

public abstract int getStatusCode ()

Returns the status code for the request.

Returns
  • The status code

public abstract String getStatusText ()

Returns the status text for the request.

Returns
  • The status text

public abstract URI getUri ()

Return the request URI. Note that if the request got redirected, the value of the URI will be the last valid redirect url.

Returns
  • the request URI.
Throws
MalformedURLException

public abstract boolean hasResponseBody ()

Return true if the response's body has been computed by an AsyncHandler. It will return false if the either onStatusReceived(HttpResponseStatus) or onHeadersReceived(HttpResponseHeaders) returned ABORT

Returns
  • true if the response's body has been computed by an AsyncHandler

public abstract boolean hasResponseHeaders ()

Return true if the response's headers has been computed by an AsyncHandler It will return false if the either onStatusReceived(HttpResponseStatus) or onHeadersReceived(HttpResponseHeaders) returned ABORT

Returns
  • true if the response's headers has been computed by an AsyncHandler

public abstract boolean hasResponseStatus ()

Return true if the response's status has been computed by an AsyncHandler

Returns
  • true if the response's status has been computed by an AsyncHandler

public abstract boolean isRedirected ()

Return true if the response redirects to another object.

Returns
  • True if the response redirects to another object.

public abstract String toString ()

Subclasses SHOULD implement toString() in a way that identifies the request for logging.

Returns
  • The textual representation