play.libs

## Class WS.WSRequest

- java.lang.Object
- - play.libs.WS.WSRequest

Direct Known Subclasses:
  WSAsync.WSAsyncRequest, WSUrlFetch.WSUrlfetchRequest

Enclosing class:
  WS

    public abstract static class WS.WSRequest
    extends java.lang.Object

### Field Summary

Fields
`java.lang.Object` `body` The body of this request
`java.lang.String` `encoding`
`WS.FileParam[]` `fileParams`
`boolean` `followRedirects` Sets whether redirects (301, 302) should be followed automatically
`java.util.Map<java.lang.String,java.lang.String>` `headers`
`java.lang.String` `mimeType`
`OAuth.ServiceInfo` `oauthInfo`
`java.lang.String` `oauthSecret`
`java.lang.String` `oauthToken`
`java.util.Map<java.lang.String,java.lang.Object>` `parameters`
`java.lang.String` `password`
`WS.Scheme` `scheme`
`java.lang.Integer` `timeout` Timeout: value in seconds
`java.lang.String` `url`
`java.lang.String` `username`
`java.lang.String` `virtualHost` The virtual host this request will use

### Constructor Summary

Constructors
Constructor and Description
`WSRequest()`
`WSRequest(java.lang.String url, java.lang.String encoding)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
`WS.WSRequest` `authenticate(java.lang.String username, java.lang.String password)` define client authentication for a server host provided credentials will be used during the request the basic scheme will be used
`WS.WSRequest` `authenticate(java.lang.String username, java.lang.String password, WS.Scheme scheme)` Define client authentication for a server host provided credentials will be used during the request
`protected java.lang.String` `basicAuthHeader()`
`WS.WSRequest` `body(java.lang.Object body)` Add the given body to the request.
`protected java.lang.String` `createQueryString()`
`abstract WS.HttpResponse` `delete()` Execute a DELETE request.
`F.Promise<WS.HttpResponse>` `deleteAsync()` Execute a DELETE request asynchronously.
`protected java.lang.String` `encode(java.lang.String part)`
`WS.WSRequest` `files(java.io.File... files)` Add files to request.
`WS.WSRequest` `files(WS.FileParam... fileParams)` Add fileParams aka File and Name parameter to the request.
`WS.WSRequest` `followRedirects(boolean value)` Indicate if the WS should continue when hitting a 301 or 302
`abstract WS.HttpResponse` `get()` Execute a GET request synchronously.
`F.Promise<WS.HttpResponse>` `getAsync()` Execute a GET request asynchronously.
`abstract WS.HttpResponse` `head()` Execute a HEAD request.
`F.Promise<WS.HttpResponse>` `headAsync()` Execute a HEAD request asynchronously.
`WS.WSRequest` `headers(java.util.Map<java.lang.String,java.lang.String> headers)` Use the provided headers when executing request.
`WS.WSRequest` `mimeType(java.lang.String mimeType)` Add a MimeType to the web service request.
`WS.WSRequest` `oauth(OAuth.ServiceInfo oauthInfo, OAuth.TokenPair oauthTokens)` Deprecated.
`WS.WSRequest` `oauth(OAuth.ServiceInfo oauthInfo, java.lang.String token, java.lang.String secret)` Sign the request for do a call to a server protected by OAuth
`abstract WS.HttpResponse` `options()` Execute a OPTIONS request.
`F.Promise<WS.HttpResponse>` `optionsAsync()` Execute a OPTIONS request asynchronously.
`WS.WSRequest` `params(java.util.Map<java.lang.String,java.lang.Object> parameters)` Add parameters to request.
`abstract WS.HttpResponse` `patch()` Execute a PATCH request.
`F.Promise<WS.HttpResponse>` `patchAsync()` Execute a PATCH request asynchronously.
`abstract WS.HttpResponse` `post()` Execute a POST request.
`F.Promise<WS.HttpResponse>` `postAsync()` Execute a POST request asynchronously.
`abstract WS.HttpResponse` `put()` Execute a PUT request.
`F.Promise<WS.HttpResponse>` `putAsync()` Execute a PUT request asynchronously.
`WS.WSRequest` `setHeader(java.lang.String name, java.lang.String value)` Add a header to the request
`WS.WSRequest` `setParameter(java.lang.String name, java.lang.Object value)`
`WS.WSRequest` `setParameter(java.lang.String name, java.lang.String value)` Add a parameter to the request
`WS.WSRequest` `setParameters(java.util.Map<java.lang.String,java.lang.String> parameters)` Add parameters to request.
`WS.WSRequest` `timeout(java.lang.String timeout)` Set the value of the request timeout, i.e.
`abstract WS.HttpResponse` `trace()` Execute a TRACE request.
`F.Promise<WS.HttpResponse>` `traceAsync()` Execute a TRACE request asynchronously.
`WS.WSRequest` `withVirtualHost(java.lang.String virtualHost)` Sets the virtual host to use in this request

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### url

    public java.lang.String url

#### virtualHost

    public java.lang.String virtualHost

The virtual host this request will use

#### encoding

    public final java.lang.String encoding

#### username

    public java.lang.String username

#### password

    public java.lang.String password

#### scheme

    public WS.Scheme scheme

#### body

    public java.lang.Object body

The body of this request

#### fileParams

    public WS.FileParam[] fileParams

#### headers

    public java.util.Map<java.lang.String,java.lang.String> headers

#### parameters

    public java.util.Map<java.lang.String,java.lang.Object> parameters

#### mimeType

    public java.lang.String mimeType

#### followRedirects

    public boolean followRedirects

Sets whether redirects (301, 302) should be followed automatically

#### timeout

    public java.lang.Integer timeout

Timeout: value in seconds

#### oauthInfo

    public OAuth.ServiceInfo oauthInfo

#### oauthToken

    public java.lang.String oauthToken

#### oauthSecret

    public java.lang.String oauthSecret

### Constructor Detail

#### WSRequest

    public WSRequest()

#### WSRequest

    public WSRequest(java.lang.String url,
                     java.lang.String encoding)

### Method Detail

#### withVirtualHost

    public WS.WSRequest withVirtualHost(java.lang.String virtualHost)

Sets the virtual host to use in this request

Parameters:
  `virtualHost` - The given virtual host
Returns:
  the WSRequest

#### mimeType

    public WS.WSRequest mimeType(java.lang.String mimeType)

Add a MimeType to the web service request.

Parameters:
  `mimeType` - the given mimeType
Returns:
  the WSRequest for chaining.

#### authenticate

    public WS.WSRequest authenticate(java.lang.String username,
                                     java.lang.String password,
                                     WS.Scheme scheme)

Define client authentication for a server host provided credentials will be used during the request

Parameters:
  `username` - Login
  `password` - Password
  `scheme` - The given Scheme
Returns:
  the WSRequest for chaining.

#### authenticate

    public WS.WSRequest authenticate(java.lang.String username,
                                     java.lang.String password)

define client authentication for a server host provided credentials will be used during the request the basic scheme will be used

Parameters:
  `username` - Login
  `password` - Password
Returns:
  the WSRequest for chaining.

#### oauth

    public WS.WSRequest oauth(OAuth.ServiceInfo oauthInfo,
                              java.lang.String token,
                              java.lang.String secret)

Sign the request for do a call to a server protected by OAuth

Parameters:
  `oauthInfo` - OAuth Information
  `token` - The OAuth token
  `secret` - The secret key
Returns:
  the WSRequest for chaining.

#### oauth

    @Deprecated
    public WS.WSRequest oauth(OAuth.ServiceInfo oauthInfo,
                                          OAuth.TokenPair oauthTokens)

Deprecated.

#### followRedirects

    public WS.WSRequest followRedirects(boolean value)

Indicate if the WS should continue when hitting a 301 or 302

Parameters:
  `value` - Indicate if follow or not follow redirects
Returns:
  the WSRequest for chaining.

#### timeout

    public WS.WSRequest timeout(java.lang.String timeout)

Set the value of the request timeout, i.e. the number of seconds before cutting the connection - default to 60 seconds

Parameters:
  `timeout` - the timeout value, e.g. "30s", "1min"
Returns:
  the WSRequest for chaining

#### files

    public WS.WSRequest files(java.io.File... files)

Add files to request. This will only work with POST or PUT.

Parameters:
  `files` - list of files
Returns:
  the WSRequest for chaining.

#### files

    public WS.WSRequest files(WS.FileParam... fileParams)

Add fileParams aka File and Name parameter to the request. This will only work with POST or PUT.

Parameters:
  `fileParams` - The fileParams list
Returns:
  the WSRequest for chaining.

#### body

    public WS.WSRequest body(java.lang.Object body)

Add the given body to the request.

Parameters:
  `body` - The request body
Returns:
  the WSRequest for chaining.

#### setHeader

    public WS.WSRequest setHeader(java.lang.String name,
                                  java.lang.String value)

Add a header to the request

Parameters:
  `name` - header name
  `value` - header value
Returns:
  the WSRequest for chaining.

#### setParameter

    public WS.WSRequest setParameter(java.lang.String name,
                                     java.lang.String value)

Add a parameter to the request

Parameters:
  `name` - parameter name
  `value` - parameter value
Returns:
  the WSRequest for chaining.

#### setParameter

    public WS.WSRequest setParameter(java.lang.String name,
                                     java.lang.Object value)

#### headers

    public WS.WSRequest headers(java.util.Map<java.lang.String,java.lang.String> headers)

Use the provided headers when executing request.

Parameters:
  `headers` - The request headers
Returns:
  the WSRequest for chaining.

#### params

    public WS.WSRequest params(java.util.Map<java.lang.String,java.lang.Object> parameters)

Add parameters to request. If POST or PUT, parameters are passed in body using x-www-form-urlencoded if alone, or form-data if there is files too. For any other method, those params are appended to the queryString.

Parameters:
  `parameters` - The request parameters
Returns:
  the WSRequest for chaining.

#### setParameters

    public WS.WSRequest setParameters(java.util.Map<java.lang.String,java.lang.String> parameters)

Add parameters to request. If POST or PUT, parameters are passed in body using x-www-form-urlencoded if alone, or form-data if there is files too. For any other method, those params are appended to the queryString.

Parameters:
  `parameters` - The request parameters
Returns:
  the WSRequest for chaining.

#### get

    public abstract WS.HttpResponse get()

Execute a GET request synchronously.

Returns:
  The HTTP response

#### getAsync

    public F.Promise<WS.HttpResponse> getAsync()

Execute a GET request asynchronously.

Returns:
  The HTTP response

#### patch

    public abstract WS.HttpResponse patch()

Execute a PATCH request.

Returns:
  The HTTP response

#### patchAsync

    public F.Promise<WS.HttpResponse> patchAsync()

Execute a PATCH request asynchronously.

Returns:
  The HTTP response

#### post

    public abstract WS.HttpResponse post()

Execute a POST request.

Returns:
  The HTTP response

#### postAsync

    public F.Promise<WS.HttpResponse> postAsync()

Execute a POST request asynchronously.

Returns:
  The HTTP response

#### put

    public abstract WS.HttpResponse put()

Execute a PUT request.

Returns:
  The HTTP response

#### putAsync

    public F.Promise<WS.HttpResponse> putAsync()

Execute a PUT request asynchronously.

Returns:
  The HTTP response

#### delete

    public abstract WS.HttpResponse delete()

Execute a DELETE request.

Returns:
  The HTTP response

#### deleteAsync

    public F.Promise<WS.HttpResponse> deleteAsync()

Execute a DELETE request asynchronously.

Returns:
  The HTTP response

#### options

    public abstract WS.HttpResponse options()

Execute a OPTIONS request.

Returns:
  The HTTP response

#### optionsAsync

    public F.Promise<WS.HttpResponse> optionsAsync()

Execute a OPTIONS request asynchronously.

Returns:
  The HTTP response

#### head

    public abstract WS.HttpResponse head()

Execute a HEAD request.

Returns:
  The HTTP response

#### headAsync

    public F.Promise<WS.HttpResponse> headAsync()

Execute a HEAD request asynchronously.

Returns:
  The HTTP response

#### trace

    public abstract WS.HttpResponse trace()

Execute a TRACE request.

Returns:
  The HTTP response

#### traceAsync

    public F.Promise<WS.HttpResponse> traceAsync()

Execute a TRACE request asynchronously.

Returns:
  The HTTP response

#### basicAuthHeader

    protected java.lang.String basicAuthHeader()

#### encode

    protected java.lang.String encode(java.lang.String part)

#### createQueryString

    protected java.lang.String createQueryString()