Package 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 Modifier and Type Field Description java.lang.ObjectbodyThe body of this requestjava.lang.StringencodingWS.FileParam[]fileParamsbooleanfollowRedirectsSets whether redirects (301, 302) should be followed automaticallyjava.util.Map<java.lang.String,java.lang.String>headersjava.lang.StringmimeTypeOAuth.ServiceInfooauthInfojava.lang.StringoauthSecretjava.lang.StringoauthTokenjava.util.Map<java.lang.String,java.lang.Object>parametersjava.lang.StringpasswordWS.Schemeschemejava.lang.IntegertimeoutTimeout: value in secondsjava.lang.Stringurljava.lang.Stringusernamejava.lang.StringvirtualHostThe virtual host this request will use
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description WS.WSRequestauthenticate(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 usedWS.WSRequestauthenticate(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 requestprotected java.lang.StringbasicAuthHeader()WS.WSRequestbody(java.lang.Object body)Add the given body to the request.protected java.lang.StringcreateQueryString()abstract WS.HttpResponsedelete()Execute a DELETE request.F.Promise<WS.HttpResponse>deleteAsync()Execute a DELETE request asynchronously.protected java.lang.Stringencode(java.lang.String part)WS.WSRequestfiles(java.io.File... files)Add files to request.WS.WSRequestfiles(WS.FileParam... fileParams)Add fileParams aka File and Name parameter to the request.WS.WSRequestfollowRedirects(boolean value)Indicate if the WS should continue when hitting a 301 or 302abstract WS.HttpResponseget()Execute a GET request synchronously.F.Promise<WS.HttpResponse>getAsync()Execute a GET request asynchronously.abstract WS.HttpResponsehead()Execute a HEAD request.F.Promise<WS.HttpResponse>headAsync()Execute a HEAD request asynchronously.WS.WSRequestheaders(java.util.Map<java.lang.String,java.lang.String> headers)Use the provided headers when executing request.WS.WSRequestmimeType(java.lang.String mimeType)Add a MimeType to the web service request.WS.WSRequestoauth(OAuth.ServiceInfo oauthInfo, java.lang.String token, java.lang.String secret)Sign the request for do a call to a server protected by OAuthWS.WSRequestoauth(OAuth.ServiceInfo oauthInfo, OAuth.TokenPair oauthTokens)Deprecated.abstract WS.HttpResponseoptions()Execute a OPTIONS request.F.Promise<WS.HttpResponse>optionsAsync()Execute a OPTIONS request asynchronously.WS.WSRequestparams(java.util.Map<java.lang.String,java.lang.Object> parameters)Add parameters to request.abstract WS.HttpResponsepatch()Execute a PATCH request.F.Promise<WS.HttpResponse>patchAsync()Execute a PATCH request asynchronously.abstract WS.HttpResponsepost()Execute a POST request.F.Promise<WS.HttpResponse>postAsync()Execute a POST request asynchronously.abstract WS.HttpResponseput()Execute a PUT request.F.Promise<WS.HttpResponse>putAsync()Execute a PUT request asynchronously.WS.WSRequestsetHeader(java.lang.String name, java.lang.String value)Add a header to the requestWS.WSRequestsetParameter(java.lang.String name, java.lang.Object value)WS.WSRequestsetParameter(java.lang.String name, java.lang.String value)Add a parameter to the requestWS.WSRequestsetParameters(java.util.Map<java.lang.String,java.lang.String> parameters)Add parameters to request.WS.WSRequesttimeout(java.lang.String timeout)Set the value of the request timeout, i.e.abstract WS.HttpResponsetrace()Execute a TRACE request.F.Promise<WS.HttpResponse>traceAsync()Execute a TRACE request asynchronously.WS.WSRequestwithVirtualHost(java.lang.String virtualHost)Sets the virtual host to use in this request
-
-
-
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
-
-
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- Loginpassword- Passwordscheme- 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- Loginpassword- 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 Informationtoken- The OAuth tokensecret- 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 namevalue- 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 namevalue- 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()
-
-