Package play.libs.ws
Class WSRequest
java.lang.Object
play.libs.ws.WSRequest
- Direct Known Subclasses:
DummyWSRequest
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CharsetbooleanSets whether redirects (301, 302) should be followed automaticallyintTimeout: value in secondsThe virtual host this request will use -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(String username, String password) define client authentication for a server host provided credentials will be used during the request the basic scheme will be usedauthenticate(String username, String password, Scheme scheme) Define client authentication for a server host provided credentials will be used during the requestprotected StringAdd the given body to the request.abstract HttpResponsedelete()Execute a DELETE request.Execute a DELETE request asynchronously.protected StringAdd files to request.Add fileParams aka File and Name parameter to the request.followRedirects(boolean value) Indicate if the WS should continue when hitting a 301 or 302abstract HttpResponseget()Execute a GET request synchronously.getAsync()Execute a GET request asynchronously.abstract HttpResponsehead()Execute a HEAD request.Execute a HEAD request asynchronously.Use the provided headers when executing request.Add a MimeType to the web service request.abstract HttpResponseoptions()Execute a OPTIONS request.Execute a OPTIONS request asynchronously.Add parameters to request.abstract HttpResponsepatch()Execute a PATCH request.Execute a PATCH request asynchronously.abstract HttpResponsepost()Execute a POST request.Execute a POST request asynchronously.abstract HttpResponseput()Execute a PUT request.putAsync()Execute a PUT request asynchronously.Add a header to the requestsetParameter(String name, Object value) setParameter(String name, String value) Add a parameter to the requestSet the value of the request timeout, i.e.abstract HttpResponsetrace()Execute a TRACE request.Execute a TRACE request asynchronously.withVirtualHost(String virtualHost) Sets the virtual host to use in this request
-
Field Details
-
virtualHost
The virtual host this request will use -
encoding
-
username
-
password
-
scheme
-
body
-
fileParams
-
headers
-
parameters
-
mimeType
-
followRedirects
public boolean followRedirectsSets whether redirects (301, 302) should be followed automatically -
timeout
public int timeoutTimeout: value in seconds
-
-
Constructor Details
-
WSRequest
-
-
Method Details
-
withVirtualHost
Sets the virtual host to use in this request- Parameters:
virtualHost- The given virtual host- Returns:
- the WSRequest
-
mimeType
Add a MimeType to the web service request.- Parameters:
mimeType- the given mimeType- Returns:
- the WSRequest for chaining.
-
authenticate
Define client authentication for a server host provided credentials will be used during the request- Parameters:
username- Loginpassword- Passwordscheme- The given Scheme- Returns:
- the WSRequest for chaining.
-
authenticate
define client authentication for a server host provided credentials will be used during the request the basic scheme will be used- Parameters:
username- Loginpassword- Password- Returns:
- the WSRequest for chaining.
-
followRedirects
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
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
Add files to request. This will only work with POST or PUT.- Parameters:
files- list of files- Returns:
- the WSRequest for chaining.
-
files
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
Add the given body to the request.- Parameters:
body- The request body- Returns:
- the WSRequest for chaining.
-
setHeader
Add a header to the request- Parameters:
name- header namevalue- header value- Returns:
- the WSRequest for chaining.
-
setParameter
Add a parameter to the request- Parameters:
name- parameter namevalue- parameter value- Returns:
- the WSRequest for chaining.
-
setParameter
-
headers
Use the provided headers when executing request.- Parameters:
headers- The request headers- Returns:
- the WSRequest for chaining.
-
params
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
Execute a GET request synchronously.- Returns:
- The HTTP response
-
getAsync
Execute a GET request asynchronously.- Returns:
- The HTTP response
-
patch
Execute a PATCH request.- Returns:
- The HTTP response
-
patchAsync
Execute a PATCH request asynchronously.- Returns:
- The HTTP response
-
post
Execute a POST request.- Returns:
- The HTTP response
-
postAsync
Execute a POST request asynchronously.- Returns:
- The HTTP response
-
put
Execute a PUT request.- Returns:
- The HTTP response
-
putAsync
Execute a PUT request asynchronously.- Returns:
- The HTTP response
-
delete
Execute a DELETE request.- Returns:
- The HTTP response
-
deleteAsync
Execute a DELETE request asynchronously.- Returns:
- The HTTP response
-
options
Execute a OPTIONS request.- Returns:
- The HTTP response
-
optionsAsync
Execute a OPTIONS request asynchronously.- Returns:
- The HTTP response
-
head
Execute a HEAD request.- Returns:
- The HTTP response
-
headAsync
Execute a HEAD request asynchronously.- Returns:
- The HTTP response
-
trace
Execute a TRACE request.- Returns:
- The HTTP response
-
traceAsync
Execute a TRACE request asynchronously.- Returns:
- The HTTP response
-
basicAuthHeader
-
encode
-