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 StringgetContentType()Return the content-type header value.List<io.netty.handler.codec.http.cookie.Cookie>getCookies()StringgetHeader(CharSequence name)io.netty.handler.codec.http.HttpHeadersgetHeaders()List<String>getHeaders(CharSequence name)Return aListof the response header value.SocketAddressgetLocalAddress()Get the local address that the client initiated the request from.SocketAddressgetRemoteAddress()Get the remote address that the client initiated the request to.StringgetResponseBody()Return the entire response body as a String.StringgetResponseBody(Charset charset)Return the entire response body as a String.io.netty.buffer.ByteBufgetResponseBodyAsByteBuf()Return the entire response body as a ByteBuf.ByteBuffergetResponseBodyAsByteBuffer()Return the entire response body as a ByteBuffer.byte[]getResponseBodyAsBytes()Return the entire response body as a byte[].InputStreamgetResponseBodyAsStream()Returns an input stream for the response body.intgetStatusCode()Returns the status code for the request.StringgetStatusText()Returns the status text for the request.UrigetUri()Return the requestUri.booleanhasResponseBody()Return true if the response's body has been computed by anAsyncHandler.booleanhasResponseHeaders()Return true if the response's headers has been computed by anAsyncHandlerIt will return false if the eitherAsyncHandler.onStatusReceived(HttpResponseStatus)orAsyncHandler.onHeadersReceived(HttpHeaders)returnedAsyncHandler.State.ABORTbooleanhasResponseStatus()Return true if the response's status has been computed by anAsyncHandlerbooleanisRedirected()Return true if the response redirects to another object.StringtoString()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:ResponseReturns the status code for the request.- Specified by:
getStatusCodein interfaceResponse- Returns:
- The status code
-
getStatusText
public final String getStatusText()
Description copied from interface:ResponseReturns the status text for the request.- Specified by:
getStatusTextin interfaceResponse- Returns:
- The status text
-
getRemoteAddress
public SocketAddress getRemoteAddress()
Description copied from interface:ResponseGet the remote address that the client initiated the request to.- Specified by:
getRemoteAddressin interfaceResponse- Returns:
- The remote address that the client initiated the request to. May be
nullif asynchronous provider is unable to provide the remote address
-
getLocalAddress
public SocketAddress getLocalAddress()
Description copied from interface:ResponseGet the local address that the client initiated the request from.- Specified by:
getLocalAddressin interfaceResponse- Returns:
- The local address that the client initiated the request from. May be
nullif asynchronous provider is unable to provide the local address
-
getContentType
public final String getContentType()
Description copied from interface:ResponseReturn the content-type header value.- Specified by:
getContentTypein 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:ResponseReturn aListof the response header value.- Specified by:
getHeadersin interfaceResponse- Parameters:
name- the header name- Returns:
- the response header value
-
getHeaders
public final io.netty.handler.codec.http.HttpHeaders getHeaders()
- Specified by:
getHeadersin interfaceResponse
-
isRedirected
public final boolean isRedirected()
Description copied from interface:ResponseReturn true if the response redirects to another object.- Specified by:
isRedirectedin interfaceResponse- Returns:
- True if the response redirects to another object.
-
getCookies
public List<io.netty.handler.codec.http.cookie.Cookie> getCookies()
- Specified by:
getCookiesin interfaceResponse- Returns:
- the list of
Cookie.
-
hasResponseStatus
public boolean hasResponseStatus()
Description copied from interface:ResponseReturn true if the response's status has been computed by anAsyncHandler- Specified by:
hasResponseStatusin interfaceResponse- Returns:
- true if the response's status has been computed by an
AsyncHandler
-
hasResponseHeaders
public boolean hasResponseHeaders()
Description copied from interface:ResponseReturn true if the response's headers has been computed by anAsyncHandlerIt will return false if the eitherAsyncHandler.onStatusReceived(HttpResponseStatus)orAsyncHandler.onHeadersReceived(HttpHeaders)returnedAsyncHandler.State.ABORT- Specified by:
hasResponseHeadersin interfaceResponse- Returns:
- true if the response's headers has been computed by an
AsyncHandler
-
hasResponseBody
public boolean hasResponseBody()
Description copied from interface:ResponseReturn 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:
hasResponseBodyin interfaceResponse- Returns:
- true if the response's body has been computed by an
AsyncHandlerto new empty bytes
- either the
-
getResponseBodyAsBytes
public byte[] getResponseBodyAsBytes()
Description copied from interface:ResponseReturn the entire response body as a byte[].- Specified by:
getResponseBodyAsBytesin interfaceResponse- Returns:
- the entire response body as a byte[].
-
getResponseBodyAsByteBuffer
public ByteBuffer getResponseBodyAsByteBuffer()
Description copied from interface:ResponseReturn the entire response body as a ByteBuffer.- Specified by:
getResponseBodyAsByteBufferin interfaceResponse- Returns:
- the entire response body as a ByteBuffer.
-
getResponseBodyAsByteBuf
public io.netty.buffer.ByteBuf getResponseBodyAsByteBuf()
Description copied from interface:ResponseReturn the entire response body as a ByteBuf.- Specified by:
getResponseBodyAsByteBufin interfaceResponse- Returns:
- the entire response body as a ByteBuf.
-
getResponseBody
public String getResponseBody()
Description copied from interface:ResponseReturn the entire response body as a String.- Specified by:
getResponseBodyin interfaceResponse- Returns:
- the entire response body as a String.
-
getResponseBody
public String getResponseBody(Charset charset)
Description copied from interface:ResponseReturn the entire response body as a String.- Specified by:
getResponseBodyin 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:ResponseReturns 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:
getResponseBodyAsStreamin interfaceResponse- Returns:
- The input stream
-
-