Package play.libs.ws.ahc
Class AhcWSResponse
- Object
-
- play.libs.ws.ahc.AhcWSResponse
-
- All Implemented Interfaces:
play.libs.ws.StandaloneWSResponse
,WSResponse
public class AhcWSResponse extends Object implements WSResponse
A Play WS response backed by an AsyncHttpClient response.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description byte[]
asByteArray()
Deprecated.Useresponse.getBodyAsBytes().toArray()
com.fasterxml.jackson.databind.JsonNode
asJson()
Deprecated.Useresponse.getBody(json())
Document
asXml()
Deprecated.Useresponse.getBody(xml())
Map<String,List<String>>
getAllHeaders()
Deprecated.Deprecated since 2.6.0.String
getBody()
<T> T
getBody(play.libs.ws.BodyReadable<T> readable)
Gets the body of the response as a T, using aBodyReadable
.ByteString
getBodyAsBytes()
Source<ByteString,?>
getBodyAsSource()
InputStream
getBodyAsStream()
Deprecated.Useresponse.getBody(inputStream())
String
getContentType()
Optional<play.libs.ws.WSCookie>
getCookie(String name)
List<play.libs.ws.WSCookie>
getCookies()
Map<String,List<String>>
getHeaders()
List<String>
getHeaderValues(String name)
Optional<String>
getSingleHeader(String name)
int
getStatus()
String
getStatusText()
Object
getUnderlying()
Gets the underlying implementation response object, if any.URI
getUri()
-
-
-
Method Detail
-
getHeaders
public Map<String,List<String>> getHeaders()
- Specified by:
getHeaders
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getHeaders
in interfaceWSResponse
-
getHeaderValues
public List<String> getHeaderValues(String name)
- Specified by:
getHeaderValues
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getHeaderValues
in interfaceWSResponse
-
getSingleHeader
public Optional<String> getSingleHeader(String name)
- Specified by:
getSingleHeader
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getSingleHeader
in interfaceWSResponse
-
getUnderlying
public Object getUnderlying()
Description copied from interface:WSResponse
Gets the underlying implementation response object, if any.- Specified by:
getUnderlying
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getUnderlying
in interfaceWSResponse
-
getContentType
public String getContentType()
- Specified by:
getContentType
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getContentType
in interfaceWSResponse
-
getStatus
public int getStatus()
- Specified by:
getStatus
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getStatus
in interfaceWSResponse
- Returns:
- the HTTP status code from the response.
-
getStatusText
public String getStatusText()
- Specified by:
getStatusText
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getStatusText
in interfaceWSResponse
- Returns:
- the text associated with the status code.
-
getCookies
public List<play.libs.ws.WSCookie> getCookies()
- Specified by:
getCookies
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getCookies
in interfaceWSResponse
- Returns:
- all the cookies from the response.
-
getCookie
public Optional<play.libs.ws.WSCookie> getCookie(String name)
- Specified by:
getCookie
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getCookie
in interfaceWSResponse
- Returns:
- a single cookie from the response, if any.
-
getBodyAsBytes
public ByteString getBodyAsBytes()
- Specified by:
getBodyAsBytes
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getBodyAsBytes
in interfaceWSResponse
- Returns:
- the body as a ByteString
-
getBody
public <T> T getBody(play.libs.ws.BodyReadable<T> readable)
Description copied from interface:WSResponse
Gets the body of the response as a T, using aBodyReadable
.See
WSBodyReadables
for convenient functions.- Specified by:
getBody
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getBody
in interfaceWSResponse
- Type Parameters:
T
- the type to return, i.e. String.- Parameters:
readable
- a transformation function from a response to a T.- Returns:
- the body as an instance of T.
-
getBodyAsSource
public Source<ByteString,?> getBodyAsSource()
- Specified by:
getBodyAsSource
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getBodyAsSource
in interfaceWSResponse
- Returns:
- the body as a Source
-
getBody
public String getBody()
- Specified by:
getBody
in interfaceplay.libs.ws.StandaloneWSResponse
- Specified by:
getBody
in interfaceWSResponse
- Returns:
- the body as a string.
-
getUri
public URI getUri()
- Specified by:
getUri
in interfaceplay.libs.ws.StandaloneWSResponse
-
getAllHeaders
@Deprecated public Map<String,List<String>> getAllHeaders()
Deprecated.Deprecated since 2.6.0. UsegetHeaders()
instead.Description copied from interface:WSResponse
Gets all the headers from the response.- Specified by:
getAllHeaders
in interfaceWSResponse
- Returns:
- the headers
-
asXml
@Deprecated public Document asXml()
Deprecated.Useresponse.getBody(xml())
Description copied from interface:WSResponse
return the body as XML.- Specified by:
asXml
in interfaceWSResponse
-
asJson
@Deprecated public com.fasterxml.jackson.databind.JsonNode asJson()
Deprecated.Useresponse.getBody(json())
Description copied from interface:WSResponse
Gets the body as JSON node.- Specified by:
asJson
in interfaceWSResponse
- Returns:
- json node.
-
getBodyAsStream
@Deprecated public InputStream getBodyAsStream()
Deprecated.Useresponse.getBody(inputStream())
Description copied from interface:WSResponse
Gets the body as a stream.- Specified by:
getBodyAsStream
in interfaceWSResponse
-
asByteArray
@Deprecated public byte[] asByteArray()
Deprecated.Useresponse.getBodyAsBytes().toArray()
Description copied from interface:WSResponse
Gets the body as an array of bytes.- Specified by:
asByteArray
in interfaceWSResponse
-
-