Package org.asynchttpclient
Interface Response
-
- All Known Implementing Classes:
NettyResponse
,WebDavResponse
public interface Response
Represents the asynchronous HTTP response callback for anAsyncCompletionHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Response.ResponseBuilder
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
getContentType()
Return the content-type header value.List<io.netty.handler.codec.http.cookie.Cookie>
getCookies()
String
getHeader(CharSequence name)
io.netty.handler.codec.http.HttpHeaders
getHeaders()
List<String>
getHeaders(CharSequence name)
Return aList
of the response header value.SocketAddress
getLocalAddress()
Get the local address that the client initiated the request from.SocketAddress
getRemoteAddress()
Get the remote address that the client initiated the request to.String
getResponseBody()
Return the entire response body as a String.String
getResponseBody(Charset charset)
Return the entire response body as a String.ByteBuffer
getResponseBodyAsByteBuffer()
Return the entire response body as a ByteBuffer.byte[]
getResponseBodyAsBytes()
Return the entire response body as a byte[].InputStream
getResponseBodyAsStream()
Returns an input stream for the response body.int
getStatusCode()
Returns the status code for the request.String
getStatusText()
Returns the status text for the request.Uri
getUri()
Return the requestUri
.boolean
hasResponseBody()
Return true if the response's body has been computed by anAsyncHandler
.boolean
hasResponseHeaders()
Return true if the response's headers has been computed by anAsyncHandler
It will return false if the eitherAsyncHandler.onStatusReceived(HttpResponseStatus)
orAsyncHandler.onHeadersReceived(HttpHeaders)
returnedAsyncHandler.State.ABORT
boolean
hasResponseStatus()
Return true if the response's status has been computed by anAsyncHandler
boolean
isRedirected()
Return true if the response redirects to another object.String
toString()
Subclasses SHOULD implement toString() in a way that identifies the response for logging.
-
-
-
Method Detail
-
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
byte[] getResponseBodyAsBytes()
Return the entire response body as a byte[].- Returns:
- the entire response body as a byte[].
-
getResponseBodyAsByteBuffer
ByteBuffer getResponseBodyAsByteBuffer()
Return the entire response body as a ByteBuffer.- Returns:
- the entire response body as a ByteBuffer.
-
getResponseBodyAsStream
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
-
getResponseBody
String getResponseBody(Charset 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.
-
getResponseBody
String getResponseBody()
Return the entire response body as a String.- Returns:
- the entire response body as a String.
-
getUri
Uri getUri()
Return the requestUri
. Note that if the request got redirected, the value of theUri
will 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
String getHeader(CharSequence name)
- Parameters:
name
- the header name- Returns:
- the first response header value
-
getHeaders
List<String> getHeaders(CharSequence name)
Return aList
of the response header value.- Parameters:
name
- the header name- Returns:
- the response header value
-
getHeaders
io.netty.handler.codec.http.HttpHeaders 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
List<io.netty.handler.codec.http.cookie.Cookie> getCookies()
- Returns:
- the list of
Cookie
.
-
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 anAsyncHandler
It will return false if the eitherAsyncHandler.onStatusReceived(HttpResponseStatus)
orAsyncHandler.onHeadersReceived(HttpHeaders)
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:- either the
AsyncHandler.onStatusReceived(HttpResponseStatus)
returnedAsyncHandler.State.ABORT
- or
AsyncHandler.onHeadersReceived(HttpHeaders)
returnedAsyncHandler.State.ABORT
- response body was empty
- Returns:
- true if the response's body has been computed by an
AsyncHandler
to new empty bytes
- either the
-
getRemoteAddress
SocketAddress getRemoteAddress()
Get the remote address that the client initiated the request to.- Returns:
- The remote address that the client initiated the request to. May be
null
if asynchronous provider is unable to provide the remote address
-
getLocalAddress
SocketAddress getLocalAddress()
Get the local address that the client initiated the request from.- Returns:
- The local address that the client initiated the request from. May be
null
if asynchronous provider is unable to provide the local address
-
-