Class AhcWSResponse

java.lang.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 Details

    • getHeaders

      public Map<String,List<String>> getHeaders()
      Specified by:
      getHeaders in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getHeaders in interface WSResponse
    • getHeaderValues

      public List<String> getHeaderValues(String name)
      Specified by:
      getHeaderValues in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getHeaderValues in interface WSResponse
    • getSingleHeader

      public Optional<String> getSingleHeader(String name)
      Specified by:
      getSingleHeader in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getSingleHeader in interface WSResponse
    • getUnderlying

      public Object getUnderlying()
      Description copied from interface: WSResponse
      Gets the underlying implementation response object, if any.
      Specified by:
      getUnderlying in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getUnderlying in interface WSResponse
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getContentType in interface WSResponse
    • getStatus

      public int getStatus()
      Specified by:
      getStatus in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getStatus in interface WSResponse
      Returns:
      the HTTP status code from the response.
    • getStatusText

      public String getStatusText()
      Specified by:
      getStatusText in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getStatusText in interface WSResponse
      Returns:
      the text associated with the status code.
    • getCookies

      public List<play.libs.ws.WSCookie> getCookies()
      Specified by:
      getCookies in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getCookies in interface WSResponse
      Returns:
      all the cookies from the response.
    • getCookie

      public Optional<play.libs.ws.WSCookie> getCookie(String name)
      Specified by:
      getCookie in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getCookie in interface WSResponse
      Returns:
      a single cookie from the response, if any.
    • getBodyAsBytes

      public ByteString getBodyAsBytes()
      Specified by:
      getBodyAsBytes in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getBodyAsBytes in interface WSResponse
      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 a BodyReadable.

      See WSBodyReadables for convenient functions.

      Specified by:
      getBody in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getBody in interface WSResponse
      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 interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getBodyAsSource in interface WSResponse
      Returns:
      the body as a Source
    • getBody

      public String getBody()
      Specified by:
      getBody in interface play.libs.ws.StandaloneWSResponse
      Specified by:
      getBody in interface WSResponse
      Returns:
      the body as a string.
    • getUri

      public URI getUri()
      Specified by:
      getUri in interface play.libs.ws.StandaloneWSResponse
    • getAllHeaders

      @Deprecated public Map<String,List<String>> getAllHeaders()
      Deprecated.
      Deprecated since 2.6.0. Use getHeaders() instead.
      Description copied from interface: WSResponse
      Gets all the headers from the response.
      Specified by:
      getAllHeaders in interface WSResponse
      Returns:
      the headers
    • asXml

      @Deprecated public Document asXml()
      Deprecated.
      Use response.getBody(xml())
      Description copied from interface: WSResponse
      return the body as XML.
      Specified by:
      asXml in interface WSResponse
    • asJson

      @Deprecated public com.fasterxml.jackson.databind.JsonNode asJson()
      Deprecated.
      Use response.getBody(json())
      Description copied from interface: WSResponse
      Gets the body as JSON node.
      Specified by:
      asJson in interface WSResponse
      Returns:
      json node.
    • getBodyAsStream

      @Deprecated public InputStream getBodyAsStream()
      Deprecated.
      Use response.getBody(inputStream())
      Description copied from interface: WSResponse
      Gets the body as a stream.
      Specified by:
      getBodyAsStream in interface WSResponse
    • asByteArray

      @Deprecated public byte[] asByteArray()
      Deprecated.
      Use response.getBodyAsBytes().toArray()
      Description copied from interface: WSResponse
      Gets the body as an array of bytes.
      Specified by:
      asByteArray in interface WSResponse