Package play.libs.ws

Interface WSResponse

  • All Superinterfaces:
    play.libs.ws.StandaloneWSResponse
    All Known Implementing Classes:
    AhcWSResponse

    public interface WSResponse
    extends play.libs.ws.StandaloneWSResponse
    This is the WS response from the server.
    • Method Detail

      • getHeaders

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

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

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

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

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

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

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

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

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

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

        ByteString getBodyAsBytes()
        Specified by:
        getBodyAsBytes in interface play.libs.ws.StandaloneWSResponse
        Returns:
        the body as a ByteString
      • getBodyAsSource

        Source<ByteString,​?> getBodyAsSource()
        Specified by:
        getBodyAsSource in interface play.libs.ws.StandaloneWSResponse
        Returns:
        the body as a Source
      • getBody

        <T> T getBody​(play.libs.ws.BodyReadable<T> readable)
        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
        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.
      • asXml

        Document asXml()
        return the body as XML.
      • asJson

        com.fasterxml.jackson.databind.JsonNode asJson()
        Gets the body as JSON node.
        Returns:
        json node.
      • asByteArray

        byte[] asByteArray()
        Gets the body as an array of bytes.