play.libs
Class WS.WSRequestHolder

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

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

provides the User facing API for building WS request.


Constructor Summary
WS.WSRequestHolder(java.lang.String url)
           
 
Method Summary
 F.Promise<WS.Response> delete()
          Perform a DELETE on the request asynchronously.
 F.Promise<WS.Response> execute(java.lang.String method)
          Execute an arbitrary method on the request asynchronously.
 F.Promise<WS.Response> get()
          Perform a GET on the request asynchronously.
 WS.SignatureCalculator getCalculator()
           
 java.lang.Boolean getFollowRedirects()
           
 java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> getHeaders()
           
 java.lang.String getPassword()
           
 java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> getQueryParameters()
           
 com.ning.http.client.Realm.AuthScheme getScheme()
           
 int getTimeout()
           
 java.lang.String getUrl()
           
 java.lang.String getUsername()
           
 F.Promise<WS.Response> head()
          Perform a HEAD on the request asynchronously.
 F.Promise<WS.Response> options()
          Perform an OPTIONS on the request asynchronously.
 F.Promise<WS.Response> post(java.io.File body)
          Perform a POST on the request asynchronously.
 F.Promise<WS.Response> post(java.io.InputStream body)
          Perform a POST on the request asynchronously.
 F.Promise<WS.Response> post(com.fasterxml.jackson.databind.JsonNode body)
          Perform a POST on the request asynchronously.
 F.Promise<WS.Response> post(java.lang.String body)
          Perform a POST on the request asynchronously.
 F.Promise<WS.Response> put(java.io.File body)
          Perform a PUT on the request asynchronously.
 F.Promise<WS.Response> put(java.io.InputStream body)
          Perform a PUT on the request asynchronously.
 F.Promise<WS.Response> put(com.fasterxml.jackson.databind.JsonNode body)
          Perform a PUT on the request asynchronously.
 F.Promise<WS.Response> put(java.lang.String body)
          Perform a PUT on the request asynchronously.
 WS.WSRequestHolder setAuth(java.lang.String username, java.lang.String password)
          Sets the authentication header for the current request using BASIC authentication.
 WS.WSRequestHolder setAuth(java.lang.String username, java.lang.String password, com.ning.http.client.Realm.AuthScheme scheme)
          Sets the authentication header for the current request.
 WS.WSRequestHolder setContentType(java.lang.String contentType)
          Set the content type.
 WS.WSRequestHolder setFollowRedirects(java.lang.Boolean followRedirects)
          Sets whether redirects (301, 302) should be followed automatically.
 WS.WSRequestHolder setHeader(java.lang.String name, java.lang.String value)
          Sets a header with the given name, this can be called repeatedly.
 WS.WSRequestHolder setQueryParameter(java.lang.String name, java.lang.String value)
          Sets a query parameter with the given name,this can be called repeatedly.
 WS.WSRequestHolder setTimeout(int timeout)
          Sets the request timeout in milliseconds.
 WS.WSRequestHolder sign(WS.SignatureCalculator calculator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WS.WSRequestHolder

public WS.WSRequestHolder(java.lang.String url)
Method Detail

setHeader

public WS.WSRequestHolder setHeader(java.lang.String name,
                                    java.lang.String value)
Sets a header with the given name, this can be called repeatedly.

Parameters:
name -
value -

setQueryParameter

public WS.WSRequestHolder setQueryParameter(java.lang.String name,
                                            java.lang.String value)
Sets a query parameter with the given name,this can be called repeatedly.

Parameters:
name -
value -

setAuth

public WS.WSRequestHolder setAuth(java.lang.String username,
                                  java.lang.String password)
Sets the authentication header for the current request using BASIC authentication.

Parameters:
username -
password -

setAuth

public WS.WSRequestHolder setAuth(java.lang.String username,
                                  java.lang.String password,
                                  com.ning.http.client.Realm.AuthScheme scheme)
Sets the authentication header for the current request.

Parameters:
username -
password -
scheme - authentication scheme

sign

public WS.WSRequestHolder sign(WS.SignatureCalculator calculator)

setFollowRedirects

public WS.WSRequestHolder setFollowRedirects(java.lang.Boolean followRedirects)
Sets whether redirects (301, 302) should be followed automatically.

Parameters:
followRedirects -

setTimeout

public WS.WSRequestHolder setTimeout(int timeout)
Sets the request timeout in milliseconds.

Parameters:
timeout -

setContentType

public WS.WSRequestHolder setContentType(java.lang.String contentType)
Set the content type. If the request body is a String, and no charset parameter is included, then it will default to UTF-8.

Parameters:
contentType - The content type

getUrl

public java.lang.String getUrl()
Returns:
the URL of the request.

getHeaders

public java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> getHeaders()
Returns:
the headers (a copy to prevent side-effects).

getQueryParameters

public java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> getQueryParameters()
Returns:
the query parameters (a copy to prevent side-effects).

getUsername

public java.lang.String getUsername()
Returns:
the auth username, null if not an authenticated request.

getPassword

public java.lang.String getPassword()
Returns:
the auth password, null if not an authenticated request

getScheme

public com.ning.http.client.Realm.AuthScheme getScheme()
Returns:
the auth scheme, null if not an authenticated request

getCalculator

public WS.SignatureCalculator getCalculator()
Returns:
the signature calculator (exemple: OAuth), null if none is set.

getTimeout

public int getTimeout()
Returns:
the auth scheme (null if not an authenticated request)

getFollowRedirects

public java.lang.Boolean getFollowRedirects()
Returns:
true if the request is configure to follow redirect, false if it is configure not to, null if nothing is configured and the global client preference should be used instead.

get

public F.Promise<WS.Response> get()
Perform a GET on the request asynchronously.


post

public F.Promise<WS.Response> post(java.lang.String body)
Perform a POST on the request asynchronously.

Parameters:
body - represented as String

put

public F.Promise<WS.Response> put(java.lang.String body)
Perform a PUT on the request asynchronously.

Parameters:
body - represented as String

post

public F.Promise<WS.Response> post(com.fasterxml.jackson.databind.JsonNode body)
Perform a POST on the request asynchronously.

Parameters:
body - represented as JSON

put

public F.Promise<WS.Response> put(com.fasterxml.jackson.databind.JsonNode body)
Perform a PUT on the request asynchronously.

Parameters:
body - represented as JSON

post

public F.Promise<WS.Response> post(java.io.InputStream body)
Perform a POST on the request asynchronously.

Parameters:
body - represented as an InputStream

put

public F.Promise<WS.Response> put(java.io.InputStream body)
Perform a PUT on the request asynchronously.

Parameters:
body - represented as an InputStream

post

public F.Promise<WS.Response> post(java.io.File body)
Perform a POST on the request asynchronously.

Parameters:
body - represented as a File

put

public F.Promise<WS.Response> put(java.io.File body)
Perform a PUT on the request asynchronously.

Parameters:
body - represented as a File

delete

public F.Promise<WS.Response> delete()
Perform a DELETE on the request asynchronously.


head

public F.Promise<WS.Response> head()
Perform a HEAD on the request asynchronously.


options

public F.Promise<WS.Response> options()
Perform an OPTIONS on the request asynchronously.


execute

public F.Promise<WS.Response> execute(java.lang.String method)
Execute an arbitrary method on the request asynchronously.

Parameters:
method - The method to execute