play.libs
Class WS.Response

java.lang.Object
  extended by play.libs.WS.Response
Enclosing class:
WS

public static class WS.Response
extends java.lang.Object

A WS response.


Constructor Summary
WS.Response(com.ning.http.client.Response ahcResponse)
           
 
Method Summary
 byte[] asByteArray()
          Get the response body as a byte array
 com.fasterxml.jackson.databind.JsonNode asJson()
          Get the response body as a JsonNode
 org.w3c.dom.Document asXml()
          Get the response body as a DOM document
 java.lang.String getBody()
          Get the response body as a string.
 java.io.InputStream getBodyAsStream()
          Get the response body as a stream
 WS.Cookie getCookie(java.lang.String name)
          Get only one cookie, using the cookie name.
 java.util.List<WS.Cookie> getCookies()
          Get all the cookies.
 java.lang.String getHeader(java.lang.String key)
          Get the given HTTP header of the response
 int getStatus()
          Get the HTTP status code of the response
 java.lang.String getStatusText()
          Get the HTTP status text of the response
 java.net.URI getUri()
          Return the request URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WS.Response

public WS.Response(com.ning.http.client.Response ahcResponse)
Method Detail

getStatus

public int getStatus()
Get the HTTP status code of the response


getStatusText

public java.lang.String getStatusText()
Get the HTTP status text of the response


getHeader

public java.lang.String getHeader(java.lang.String key)
Get the given HTTP header of the response


getCookies

public java.util.List<WS.Cookie> getCookies()
Get all the cookies.


getCookie

public WS.Cookie getCookie(java.lang.String name)
Get only one cookie, using the cookie name.


getBody

public java.lang.String getBody()
Get the response body as a string. If the charset is not specified, this defaults to ISO-8859-1 for text sub mime types, as per RFC-2616 sec 3.7.1, otherwise it defaults to UTF-8.


asXml

public org.w3c.dom.Document asXml()
Get the response body as a DOM document

Returns:
a DOM document

asJson

public com.fasterxml.jackson.databind.JsonNode asJson()
Get the response body as a JsonNode

Returns:
the json response

getBodyAsStream

public java.io.InputStream getBodyAsStream()
Get the response body as a stream

Returns:
The stream to read the response body from

asByteArray

public byte[] asByteArray()
Get the response body as a byte array

Returns:
The byte array

getUri

public java.net.URI getUri()
Return the request URI. Note that if the request got redirected, the value of the URI will be the last valid redirect url.

Returns:
the request URI.