Package org.asynchttpclient.netty
Class NettyResponse
- java.lang.Object
-
- org.asynchttpclient.netty.NettyResponse
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.asynchttpclient.Response
Response.ResponseBuilder
-
-
Constructor Summary
Constructors Constructor Description NettyResponse(HttpResponseStatus status, io.netty.handler.codec.http.HttpHeaders headers, List<HttpResponseBodyPart> bodyParts)
-
Method Summary
All Methods Instance Methods Concrete 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.
-
-
-
Constructor Detail
-
NettyResponse
public NettyResponse(HttpResponseStatus status, io.netty.handler.codec.http.HttpHeaders headers, List<HttpResponseBodyPart> bodyParts)
-
-
Method Detail
-
getStatusCode
public final int getStatusCode()
Description copied from interface:Response
Returns the status code for the request.- Specified by:
getStatusCode
in interfaceResponse
- Returns:
- The status code
-
getStatusText
public final String getStatusText()
Description copied from interface:Response
Returns the status text for the request.- Specified by:
getStatusText
in interfaceResponse
- Returns:
- The status text
-
getRemoteAddress
public SocketAddress getRemoteAddress()
Description copied from interface:Response
Get the remote address that the client initiated the request to.- Specified by:
getRemoteAddress
in interfaceResponse
- 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
public SocketAddress getLocalAddress()
Description copied from interface:Response
Get the local address that the client initiated the request from.- Specified by:
getLocalAddress
in interfaceResponse
- Returns:
- The local address that the client initiated the request from. May be
null
if asynchronous provider is unable to provide the local address
-
getContentType
public final String getContentType()
Description copied from interface:Response
Return the content-type header value.- Specified by:
getContentType
in interfaceResponse
- Returns:
- the content-type header value.
-
getHeader
public final String getHeader(CharSequence name)
-
getHeaders
public final List<String> getHeaders(CharSequence name)
Description copied from interface:Response
Return aList
of the response header value.- Specified by:
getHeaders
in interfaceResponse
- Parameters:
name
- the header name- Returns:
- the response header value
-
getHeaders
public final io.netty.handler.codec.http.HttpHeaders getHeaders()
- Specified by:
getHeaders
in interfaceResponse
-
isRedirected
public final boolean isRedirected()
Description copied from interface:Response
Return true if the response redirects to another object.- Specified by:
isRedirected
in interfaceResponse
- Returns:
- True if the response redirects to another object.
-
getCookies
public List<io.netty.handler.codec.http.cookie.Cookie> getCookies()
- Specified by:
getCookies
in interfaceResponse
- Returns:
- the list of
Cookie
.
-
hasResponseStatus
public boolean hasResponseStatus()
Description copied from interface:Response
Return true if the response's status has been computed by anAsyncHandler
- Specified by:
hasResponseStatus
in interfaceResponse
- Returns:
- true if the response's status has been computed by an
AsyncHandler
-
hasResponseHeaders
public boolean hasResponseHeaders()
Description copied from interface:Response
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
- Specified by:
hasResponseHeaders
in interfaceResponse
- Returns:
- true if the response's headers has been computed by an
AsyncHandler
-
hasResponseBody
public boolean hasResponseBody()
Description copied from interface:Response
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
- Specified by:
hasResponseBody
in interfaceResponse
- Returns:
- true if the response's body has been computed by an
AsyncHandler
to new empty bytes
- either the
-
getResponseBodyAsBytes
public byte[] getResponseBodyAsBytes()
Description copied from interface:Response
Return the entire response body as a byte[].- Specified by:
getResponseBodyAsBytes
in interfaceResponse
- Returns:
- the entire response body as a byte[].
-
getResponseBodyAsByteBuffer
public ByteBuffer getResponseBodyAsByteBuffer()
Description copied from interface:Response
Return the entire response body as a ByteBuffer.- Specified by:
getResponseBodyAsByteBuffer
in interfaceResponse
- Returns:
- the entire response body as a ByteBuffer.
-
getResponseBody
public String getResponseBody()
Description copied from interface:Response
Return the entire response body as a String.- Specified by:
getResponseBody
in interfaceResponse
- Returns:
- the entire response body as a String.
-
getResponseBody
public String getResponseBody(Charset charset)
Description copied from interface:Response
Return the entire response body as a String.- Specified by:
getResponseBody
in interfaceResponse
- Parameters:
charset
- the charset to use when decoding the stream- Returns:
- the entire response body as a String.
-
getResponseBodyAsStream
public InputStream getResponseBodyAsStream()
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 interfaceResponse
- Returns:
- The input stream
-
-