AhcWSResponse

play.api.libs.ws.ahc.AhcWSResponse
case class AhcWSResponse(underlying: StandaloneWSResponse) extends WSResponse, WSBodyReadables

A WS HTTP Response backed by an AsyncHttpClient response.

Value parameters

underlying

the underlying WS response

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait WSResponse
trait XMLBodyReadables
trait JsonBodyReadables
trait DefaultBodyReadables
trait StandaloneWSResponse
class Object
trait Matchable
class Any
Show all

Members list

Value members

Constructors

def this(ahcResponse: Response)

Concrete methods

override def body: String

The response body as String.

The response body as String.

Attributes

Definition Classes
WSResponse -> StandaloneWSResponse
override def bodyAsBytes: ByteString

The response body as a byte string.

The response body as a byte string.

Attributes

Definition Classes
WSResponse -> StandaloneWSResponse
override def bodyAsSource: Source[ByteString, _]

Attributes

Returns

the response as a source of bytes

Definition Classes
WSResponse -> StandaloneWSResponse
override def cookies: Seq[WSCookie]

Get all the cookies.

Get all the cookies.

Attributes

Definition Classes
WSResponse -> StandaloneWSResponse
override def header(key: String): Option[String]

Get a response header.

Get a response header.

Attributes

Definition Classes
WSResponse -> StandaloneWSResponse
override def headers: Map[String, Seq[String]]

Return the current headers of the request being constructed

Return the current headers of the request being constructed

Attributes

Definition Classes
WSResponse -> StandaloneWSResponse
override def status: Int

The response status code.

The response status code.

Attributes

Definition Classes
WSResponse -> StandaloneWSResponse
override def statusText: String

The response status message.

The response status message.

Attributes

Definition Classes
WSResponse -> StandaloneWSResponse
override def underlying[T]: T

Get the underlying response object, i.e. play.shaded.ahc.org.asynchttpclient.Response

Get the underlying response object, i.e. play.shaded.ahc.org.asynchttpclient.Response

val ahcResponse = response.underlying[play.shaded.ahc.org.asynchttpclient.Response]

Attributes

Definition Classes
WSResponse -> StandaloneWSResponse
override def uri: URI

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

Definition Classes
StandaloneWSResponse

Deprecated methods

override def allHeaders: Map[String, Seq[String]]

Return the current headers of the request being constructed

Return the current headers of the request being constructed

Attributes

Deprecated
[Since version 2.6.0]
Definition Classes
override def json: JsValue

The response body as Json.

The response body as Json.

Attributes

Deprecated
[Since version 2.6.0]
Definition Classes
override def xml: Elem

The response body as Xml.

The response body as Xml.

Attributes

Deprecated
[Since version 2.6.0]
Definition Classes

Inherited methods

override def body[T : BodyReadable]: T

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
WSResponse -> StandaloneWSResponse
Inherited from:
WSResponse
override def contentType: String

Attributes

Returns

the content type.

Definition Classes
WSResponse -> StandaloneWSResponse
Inherited from:
WSResponse
override def headerValues(name: String): Seq[String]

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
WSResponse -> StandaloneWSResponse
Inherited from:
WSResponse

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Implicits

Inherited implicits

implicit val readableAsByteArray: BodyReadable[Array[Byte]]

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
implicit val readableAsByteBuffer: BodyReadable[ByteBuffer]

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
implicit val readableAsByteString: BodyReadable[ByteString]

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
implicit val readableAsJson: BodyReadable[JsValue]

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
implicit val readableAsSource: BodyReadable[Source[ByteString, _]]

Converts a response body into Source[ByteString, _].

Converts a response body into Source[ByteString, _].

Attributes

Inherited from:
DefaultBodyReadables
implicit val readableAsString: BodyReadable[String]

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
implicit val readableAsXml: BodyReadable[Elem]

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