Package com.ning.http.client
Interface Response
- All Known Implementing Classes:
GrizzlyResponse,ResponseBase,WebDavResponse
public interface Response
Represents the asynchronous HTTP response callback for an
AsyncCompletionHandler-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionReturn the content-type header value.Return the list ofCookie.Return the response headergetHeaders(String name) Return aListof the response header value.Return the entire response body as a String.getResponseBody(String charset) Return the entire response body as a String.Return the entire response body as a ByteBuffer.byte[]Return the entire response body as a byte[].Returns an input stream for the response body.getResponseBodyExcerpt(int maxLength) Returns the first maxLength bytes of the response body as a string.getResponseBodyExcerpt(int maxLength, String charset) Returns the first maxLength bytes of the response body as a string.intReturns the status code for the request.Returns the status text for the request.getUri()Return the requestUri.booleanReturn true if the response's body has been computed by anAsyncHandler.booleanReturn true if the response's headers has been computed by anAsyncHandlerIt will return false if the eitherAsyncHandler.onStatusReceived(HttpResponseStatus)orAsyncHandler.onHeadersReceived(HttpResponseHeaders)returnedAsyncHandler.STATE.ABORTbooleanReturn true if the response's status has been computed by anAsyncHandlerbooleanReturn true if the response redirects to another object.toString()Subclasses SHOULD implement toString() in a way that identifies the response for logging.
-
Method Details
-
getStatusCode
int getStatusCode()Returns the status code for the request.- Returns:
- The status code
-
getStatusText
String getStatusText()Returns the status text for the request.- Returns:
- The status text
-
getResponseBodyAsBytes
Return the entire response body as a byte[].- Returns:
- the entire response body as a byte[].
- Throws:
IOException
-
getResponseBodyAsByteBuffer
Return the entire response body as a ByteBuffer.- Returns:
- the entire response body as a ByteBuffer.
- Throws:
IOException
-
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
-
getResponseBodyExcerpt
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 readcharset- the charset to use when decoding the stream- Returns:
- The response body
- Throws:
IOException
-
getResponseBody
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
-
getResponseBodyExcerpt
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
-
getResponseBody
Return the entire response body as a String.- Returns:
- the entire response body as a String.
- Throws:
IOException
-
getUri
Uri getUri()Return the requestUri. Note that if the request got redirected, the value of theURIwill be the last valid redirect url.- Returns:
- the request
Uri.
-
getContentType
String getContentType()Return the content-type header value.- Returns:
- the content-type header value.
-
getHeader
Return the response header- Returns:
- the response header
-
getHeaders
Return aListof 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
String toString()Subclasses SHOULD implement toString() in a way that identifies the response for logging. -
getCookies
Return the list ofCookie. -
hasResponseStatus
boolean hasResponseStatus()Return true if the response's status has been computed by anAsyncHandler- 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 anAsyncHandlerIt will return false if the eitherAsyncHandler.onStatusReceived(HttpResponseStatus)orAsyncHandler.onHeadersReceived(HttpResponseHeaders)returnedAsyncHandler.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 anAsyncHandler. It will return false if the eitherAsyncHandler.onStatusReceived(HttpResponseStatus)orAsyncHandler.onHeadersReceived(HttpResponseHeaders)returnedAsyncHandler.STATE.ABORT- Returns:
- true if the response's body has been computed by an
AsyncHandler
-