com.ning.http.client
Interface Response

All Known Implementing Classes:
ApacheResponse, JDKResponse, NettyResponse, WebDavResponse

public interface Response

Represents the asynchronous HTTP response callback for an AsyncCompletionHandler


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

Method Detail

getStatusCode

int getStatusCode()
Returns the status code for the request.

Returns:
The status code

getStatusText

java.lang.String getStatusText()
Returns the status text for the request.

Returns:
The status text

getResponseBodyAsStream

java.io.InputStream getResponseBodyAsStream()
                                            throws java.io.IOException
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:
java.io.IOException

getResponseBodyExcerpt

java.lang.String getResponseBodyExcerpt(int maxLength,
                                        java.lang.String charset)
                                        throws java.io.IOException
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:
java.io.IOException

getResponseBody

java.lang.String getResponseBody(java.lang.String charset)
                                 throws java.io.IOException
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:
java.io.IOException

getResponseBodyExcerpt

java.lang.String getResponseBodyExcerpt(int maxLength)
                                        throws java.io.IOException
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:
java.io.IOException

getResponseBody

java.lang.String getResponseBody()
                                 throws java.io.IOException
Return the entire response body as a String.

Returns:
the entire response body as a String.
Throws:
java.io.IOException

getUri

java.net.URI getUri()
                    throws java.net.MalformedURLException
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:
java.net.MalformedURLException

getContentType

java.lang.String getContentType()
Return the content-type header value.

Returns:
the content-type header value.

getHeader

java.lang.String getHeader(java.lang.String name)
Return the response header

Returns:
the response header

getHeaders

java.util.List<java.lang.String> getHeaders(java.lang.String name)
Return a List of the response header value.

Returns:
the response header

getHeaders

FluentCaseInsensitiveStringsMap getHeaders()

isRedirected

boolean isRedirected()
Return true if the response redirects to another object.

Returns:
True if the response redirects to another object.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
The textual representation

getCookies

java.util.List<Cookie> getCookies()
Return the list of Cookie.


hasResponseStatus

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

hasResponseHeaders

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

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

hasResponseBody

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

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


Copyright © 2012. All Rights Reserved.