StandaloneWSResponse
A WS HTTP response.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Abstract methods
The response body decoded as String, using a simple algorithm to guess the encoding.
The response body decoded as String, using a simple algorithm to guess the encoding.
This decodes the body to a string representation based on the following algorithm:
- Look for a "charset" parameter on the Content-Type. If it exists, set
charsetto its value and go to step 3. - If the Content-Type is of type "text", set charset to "ISO-8859-1"; else set
charsetto "UTF-8". - Decode the raw bytes of the body using
charset.
Note that this does not take into account any special cases for specific content types. For example, for application/json, we do not support encoding autodetection and will trust the charset parameter if provided..
Attributes
- Returns
-
the response body parsed as a String using the above algorithm.
Attributes
- Returns
-
The response body as ByteString.
Attributes
- Returns
-
the response as a source of bytes
Get only one cookie, using the cookie name.
Get only one cookie, using the cookie name.
Attributes
Returns the current headers for this response.
Returns the current headers for this response.
Attributes
The response status code.
The response status code.
Attributes
The response status message.
The response status message.
Attributes
Get the underlying response object.
Get the underlying response object.
Attributes
Returns the URI for this response, which can differ from the request one in case of redirection.
Returns the URI for this response, which can differ from the request one in case of redirection.
Attributes
Concrete methods
The response body as the given type. This renders as the given type. You must have a BodyReadable in implicit scope.
The response body as the given type. This renders as the given type. You must have a BodyReadable in implicit scope.
The simplest use case is
import play.api.libs.ws.StandaloneWSResponse
import play.api.libs.ws.DefaultBodyReadables._
def responseBodyAsString(response: StandaloneWSResponse): String =
response.body[String]
But you can also render as JSON
// not compilable: requires `play-ws-standalone-json` dependency
import play.api.libs.json.JsValue
import play.api.libs.ws.StandaloneWSResponse
def responseBodyAsJson(response: StandaloneWSResponse): JsValue =
response.body[JsValue]
or as binary:
import org.apache.pekko.util.ByteString
import play.api.libs.ws.StandaloneWSResponse
import play.api.libs.ws.DefaultBodyReadables._
def responseBodyAsByteString(response: StandaloneWSResponse): ByteString =
response.body[ByteString]
Attributes
Attributes
- Returns
-
the content type.
Get the value of the header with the specified name. If there are more than one values for this header, the first value is returned. If there are no values, than a None is returned.
Get the value of the header with the specified name. If there are more than one values for this header, the first value is returned. If there are no values, than a None is returned.
Value parameters
- name
-
the header name
Attributes
- Returns
-
the header value
Get all the values of header with the specified name. If there are no values for the header with the specified name, than an empty sequence is returned.
Get all the values of header with the specified name. If there are no values for the header with the specified name, than an empty sequence is returned.
Value parameters
- name
-
the header name.
Attributes
- Returns
-
all the values for this header name.