com.ning.http.client.providers.netty
Class NettyResponse

java.lang.Object
  extended by com.ning.http.client.providers.netty.NettyResponse
All Implemented Interfaces:
Response

public class NettyResponse
extends Object
implements Response

Wrapper around the Response API.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ning.http.client.Response
Response.ResponseBuilder
 
Constructor Summary
NettyResponse(HttpResponseStatus status, HttpResponseHeaders headers, Collection<HttpResponseBodyPart> bodyParts)
           
 
Method Summary
 String getContentType()
          Return the content-type header value.
 List<Cookie> getCookies()
          Return the list of Cookie.
 String getHeader(String name)
          Return the response header
 FluentCaseInsensitiveStringsMap getHeaders()
           
 List<String> getHeaders(String name)
          Return a List of the response header value.
 String getResponseBody()
          Return the entire response body as a String.
 String getResponseBody(String charset)
          Return the entire response body as a String.
 byte[] getResponseBodyAsBytes()
          Return the entire response body as a byte[].
 InputStream getResponseBodyAsStream()
          Returns an input stream for the response body.
 String getResponseBodyExcerpt(int maxLength)
          Returns the first maxLength bytes of the response body as a string.
 String getResponseBodyExcerpt(int maxLength, String charset)
          Returns the first maxLength bytes of the response body as a string.
 int getStatusCode()
          Returns the status code for the request.
 String getStatusText()
          Returns the status text for the request.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ning.http.client.Response
toString
 

Constructor Detail

NettyResponse

public NettyResponse(HttpResponseStatus status,
                     HttpResponseHeaders headers,
                     Collection<HttpResponseBodyPart> bodyParts)
Method Detail

getStatusCode

public int getStatusCode()
Description copied from interface: Response
Returns the status code for the request.

Specified by:
getStatusCode in interface Response
Returns:
The status code

getStatusText

public String getStatusText()
Description copied from interface: Response
Returns the status text for the request.

Specified by:
getStatusText in interface Response
Returns:
The status text

getResponseBodyAsBytes

public byte[] getResponseBodyAsBytes()
                              throws IOException
Description copied from interface: Response
Return the entire response body as a byte[].

Specified by:
getResponseBodyAsBytes in interface Response
Returns:
the entire response body as a byte[].
Throws:
IOException

getResponseBody

public String getResponseBody()
                       throws IOException
Description copied from interface: Response
Return the entire response body as a String.

Specified by:
getResponseBody in interface Response
Returns:
the entire response body as a String.
Throws:
IOException

getResponseBody

public String getResponseBody(String charset)
                       throws IOException
Description copied from interface: Response
Return the entire response body as a String.

Specified by:
getResponseBody in interface Response
Parameters:
charset - the charset to use when decoding the stream
Returns:
the entire response body as a String.
Throws:
IOException

getResponseBodyAsStream

public InputStream getResponseBodyAsStream()
                                    throws IOException
Description copied from interface: Response
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.

Specified by:
getResponseBodyAsStream in interface Response
Returns:
The input stream
Throws:
IOException

getResponseBodyExcerpt

public String getResponseBodyExcerpt(int maxLength)
                              throws IOException
Description copied from interface: Response
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.

Specified by:
getResponseBodyExcerpt in interface Response
Parameters:
maxLength - The maximum number of bytes to read
Returns:
The response body
Throws:
IOException

getResponseBodyExcerpt

public String getResponseBodyExcerpt(int maxLength,
                                     String charset)
                              throws IOException
Description copied from interface: Response
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.

Specified by:
getResponseBodyExcerpt in interface Response
Parameters:
maxLength - The maximum number of bytes to read
charset - the charset to use when decoding the stream
Returns:
The response body
Throws:
IOException

getUri

public URI getUri()
           throws MalformedURLException
Description copied from interface: Response
Return the request URI. Note that if the request got redirected, the value of the URI will be the last valid redirect url.

Specified by:
getUri in interface Response
Returns:
the request URI.
Throws:
MalformedURLException

getContentType

public String getContentType()
Description copied from interface: Response
Return the content-type header value.

Specified by:
getContentType in interface Response
Returns:
the content-type header value.

getHeader

public String getHeader(String name)
Description copied from interface: Response
Return the response header

Specified by:
getHeader in interface Response
Returns:
the response header

getHeaders

public List<String> getHeaders(String name)
Description copied from interface: Response
Return a List of the response header value.

Specified by:
getHeaders in interface Response
Returns:
the response header

getHeaders

public FluentCaseInsensitiveStringsMap getHeaders()
Specified by:
getHeaders in interface Response

isRedirected

public boolean isRedirected()
Description copied from interface: Response
Return true if the response redirects to another object.

Specified by:
isRedirected in interface Response
Returns:
True if the response redirects to another object.

getCookies

public List<Cookie> getCookies()
Description copied from interface: Response
Return the list of Cookie.

Specified by:
getCookies in interface Response

hasResponseStatus

public boolean hasResponseStatus()
Return true if the response's status has been computed by an AsyncHandler

Specified by:
hasResponseStatus in interface Response
Returns:
true if the response's status has been computed by an AsyncHandler

hasResponseHeaders

public 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

Specified by:
hasResponseHeaders in interface Response
Returns:
true if the response's headers has been computed by an AsyncHandler

hasResponseBody

public 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

Specified by:
hasResponseBody in interface Response
Returns:
true if the response's body has been computed by an AsyncHandler


Copyright © 2011. All Rights Reserved.