Class 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 Detail

      • getHeaderValues

        public List<String> getHeaderValues​(String name)
        Specified by:
        getHeaderValues in interface play.libs.ws.StandaloneWSResponse
        Specified by:
        getHeaderValues 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
      • 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.
      • 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