WSResponse
A WS Response that can use Play specific classes.
Attributes
- Graph
-
- Supertypes
-
trait WSBodyReadablestrait XMLBodyReadablestrait JsonBodyReadablestrait DefaultBodyReadablestrait StandaloneWSResponseclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Abstract methods
The response body as String.
The response body as String.
Attributes
- Definition Classes
-
StandaloneWSResponse
The response body as a byte string.
The response body as a byte string.
Attributes
- Definition Classes
-
StandaloneWSResponse
Attributes
- Returns
-
the response as a source of bytes
- Definition Classes
-
StandaloneWSResponse
Get only one cookie, using the cookie name.
Get only one cookie, using the cookie name.
Attributes
- Definition Classes
-
StandaloneWSResponse
Get all the cookies.
Get all the cookies.
Attributes
- Definition Classes
-
StandaloneWSResponse
Return the current headers for this response.
Return the current headers for this response.
Attributes
- Definition Classes
-
StandaloneWSResponse
The response status code.
The response status code.
Attributes
- Definition Classes
-
StandaloneWSResponse
The response status message.
The response status message.
Attributes
- Definition Classes
-
StandaloneWSResponse
Get the underlying response object.
Get the underlying response object.
Attributes
- Definition Classes
-
StandaloneWSResponse
Concrete methods
The response body as the given type. This renders as the given type. You must have a BodyReadable in implicit scope, which is done with
The response body as the given type. This renders as the given type. You must have a BodyReadable in implicit scope, which is done with
class MyClass extends play.api.libs.ws.WSBodyReadables {
// JSON and XML body readables
}
The simplest use case is
val responseBodyAsString: String = response.body[String]
But you can also render as JSON
val responseBodyAsJson: JsValue = response.body[JsValue]
or as XML:
val xml: Elem = response.body[Elem]
Attributes
- Definition Classes
-
StandaloneWSResponse
Attributes
- Returns
-
the content type.
- Definition Classes
-
StandaloneWSResponse
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
- Definition Classes
-
StandaloneWSResponse
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.
- Definition Classes
-
StandaloneWSResponse
Deprecated methods
Attributes
- Deprecated
- true
Inherited methods
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
- Inherited from:
- StandaloneWSResponse
Implicits
Inherited implicits
Converts a response body into Array[Byte]
.
Converts a response body into Array[Byte]
.
import play.api.libs.ws.DefaultBodyReadables._
def example(response: play.api.libs.ws.StandaloneWSResponse): Array[Byte] =
response.body[Array[Byte]]
Attributes
- Inherited from:
- DefaultBodyReadables
Converts a response body into a read only ByteBuffer
.
Converts a response body into a read only ByteBuffer
.
import java.nio.ByteBuffer
import play.api.libs.ws.DefaultBodyReadables._
def example(response: play.api.libs.ws.StandaloneWSResponse): ByteBuffer =
response.body[ByteBuffer]
Attributes
- Inherited from:
- DefaultBodyReadables
Converts a response body into an akka.util.ByteString
:
Converts a response body into an akka.util.ByteString
:
import akka.util.ByteString
import play.api.libs.ws.DefaultBodyReadables._
def example(response: play.api.libs.ws.StandaloneWSResponse): ByteString =
response.body[ByteString]
Attributes
- Inherited from:
- DefaultBodyReadables
Converts a response body into Play JSON format:
Converts a response body into Play JSON format:
import play.api.libs.ws.StandaloneWSResponse
import play.api.libs.ws.JsonBodyReadables._
def json(r: StandaloneWSResponse) = r.body[play.api.libs.json.JsValue]
Attributes
- Inherited from:
- JsonBodyReadables
Converts a response body into Source[ByteString, _]
.
Converts a response body into Source[ByteString, _]
.
Attributes
- Inherited from:
- DefaultBodyReadables
Converts a response body into a String
.
Converts a response body into a String
.
Note: this is only a best-guess effort and does not handle all content types. See StandaloneWSResponse.body:String* for more information.
import play.api.libs.ws.DefaultBodyReadables._
def example(response: play.api.libs.ws.StandaloneWSResponse): String =
response.body[String]
Attributes
- Inherited from:
- DefaultBodyReadables
Converts a response body into XML document:
Converts a response body into XML document:
import scala.xml.Elem
import play.api.libs.ws.StandaloneWSResponse
import play.api.libs.ws.XMLBodyReadables._
def foo(resp: StandaloneWSResponse): Elem = resp.body[Elem]
Attributes
- Inherited from:
- XMLBodyReadables