public class

ApacheResponse

extends Object
implements Response
java.lang.Object
   ↳ com.ning.http.client.providers.apache.ApacheResponse

Summary

Public Constructors
ApacheResponse(HttpResponseStatus status, HttpResponseHeaders headers, Collection<HttpResponseBodyPart> bodyParts)
Public Methods
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 onStatusReceived(HttpResponseStatus) or onHeadersReceived(HttpResponseHeaders) returned 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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.ning.http.client.Response

Public Constructors

public ApacheResponse (HttpResponseStatus status, HttpResponseHeaders headers, Collection<HttpResponseBodyPart> bodyParts)

Public Methods

public String getContentType ()

Return the content-type header value.

Returns
  • the content-type header value.

public List<Cookie> getCookies ()

Return the list of Cookie.

public String getHeader (String name)

Return the response header

Returns
  • the response header

public FluentCaseInsensitiveStringsMap getHeaders ()

public List<String> getHeaders (String name)

Return a List of the response header value.

Returns
  • the response header

public String getResponseBody ()

Return the entire response body as a String.

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

public 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 byte[] getResponseBodyAsBytes ()

Return the entire response body as a byte[].

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

public 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 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 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 int getStatusCode ()

Returns the status code for the request.

Returns
  • The status code

public String getStatusText ()

Returns the status text for the request.

Returns
  • The status text

public 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 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 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 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 boolean isRedirected ()

Return true if the response redirects to another object.

Returns
  • True if the response redirects to another object.