Package play.libs.ws
Interface WSRequest
- All Superinterfaces:
play.libs.ws.StandaloneWSRequest
- All Known Implementing Classes:
AhcWSRequest
public interface WSRequest
extends play.libs.ws.StandaloneWSRequest
This is the main interface to building a WS request in Java.
Note that this interface does not expose properties that are only exposed after building the request: notably, the URL, headers and query parameters are shown before an OAuth signature is calculated.
-
Method Summary
Modifier and TypeMethodDescriptionaddCookie(play.libs.ws.WSCookie cookie) Adds a cookie to the requestaddCookie(Http.Cookie cookie) Adds a cookie to the requestaddCookies(play.libs.ws.WSCookie... cookies) Sets several cookies on the request.Adds a header to the request.addQueryParameter(String name, String value) Sets a query parameter with the given name, this can be called repeatedly.delete()Perform a DELETE on the request asynchronously.execute()Execute an arbitrary method on the request asynchronously.Execute an arbitrary method on the request asynchronously.get()Perform a GET on the request asynchronously.getUrl()head()Perform a HEAD on the request asynchronously.options()Perform an OPTIONS on the request asynchronously.patch(com.fasterxml.jackson.databind.JsonNode body) Perform a PATCH on the request asynchronously.Perform a PATCH on the request asynchronously.patch(InputStream body) Deprecated.Deprecated as of 2.7.0.Perform a PATCH on the request asynchronously.patch(Source<? super Http.MultipartFormData.Part<Source<ByteString, ?>>, ?> body) Perform a PATCH on the request asynchronously.Perform a PATCH on the request asynchronously.patch(play.libs.ws.BodyWritable body) Perform a PATCH on the request asynchronously.post(com.fasterxml.jackson.databind.JsonNode body) Perform a POST on the request asynchronously.Perform a POST on the request asynchronously.post(InputStream body) Deprecated.Deprecated as of 2.6.0.Perform a POST on the request asynchronously.post(Source<? super Http.MultipartFormData.Part<Source<ByteString, ?>>, ?> body) Perform a POST on the request asynchronously.Perform a POST on the request asynchronously.post(play.libs.ws.BodyWritable body) Perform a POST on the request asynchronously.put(com.fasterxml.jackson.databind.JsonNode body) Perform a PUT on the request asynchronously.Perform a PUT on the request asynchronously.put(InputStream body) Deprecated.Deprecated as of 2.7.0.Perform a PUT on the request asynchronously.put(Source<? super Http.MultipartFormData.Part<Source<ByteString, ?>>, ?> body) Perform a PUT on the request asynchronously.Perform a PUT on the request asynchronously.put(play.libs.ws.BodyWritable body) Perform a PUT on the request asynchronously.Sets the authentication header for the current request using BASIC authentication.Sets the authentication header for the current request using BASIC authentication.Sets the authentication header for the current request.setBody(com.fasterxml.jackson.databind.JsonNode body) Set the body this request should use.Set the body this request should use.setBody(InputStream body) Deprecated.Deprecated as of 2.6.0.Set the body this request should use.<U> WSRequestsetBody(Source<ByteString, U> body) Set the body this request should use.setBody(play.libs.ws.BodyWritable body) Set the body this request should use.setContentType(String contentType) Set the content type.setCookies(List<play.libs.ws.WSCookie> cookies) Sets all the cookies on the request.setFollowRedirects(boolean followRedirects) Sets whether redirects (301, 302) should be followed automatically.Deprecated.setHeaders(Map<String, List<String>> headers) Sets all of the headers on the request.Sets the HTTP method this request should use, where the no args execute() method is invoked.setQueryParameter(String name, String value) Deprecated.setQueryString(String query) Sets the query string to query.setQueryString(Map<String, List<String>> params) Sets the query string to query.setRequestFilter(play.libs.ws.WSRequestFilter filter) Adds a request filter.setRequestTimeout(long timeout) Deprecated.setRequestTimeout(Duration timeout) Sets the request timeout in milliseconds.setVirtualHost(String virtualHost) Sets the virtual host as a "hostname:port" string.sign(play.libs.ws.WSSignatureCalculator calculator) Sets an (OAuth) signature calculator.stream()Execute this request and stream the response body.Methods inherited from interface play.libs.ws.StandaloneWSRequest
getAuth, getBody, getCalculator, getContentType, getCookies, getDisableUrlEncoding, getFollowRedirects, getHeader, getHeaderValues, getMethod, getPassword, getRequestTimeout, getScheme, getUsername, setAuth, setDisableUrlEncoding, setUrl
-
Method Details
-
get
CompletionStage<WSResponse> get()Perform a GET on the request asynchronously.- Specified by:
getin interfaceplay.libs.ws.StandaloneWSRequest- Returns:
- a promise to the response
-
patch
Perform a PATCH on the request asynchronously.- Specified by:
patchin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
body- represented as BodyWritable- Returns:
- a promise to the response
-
patch
Perform a PATCH on the request asynchronously.- Parameters:
body- represented as String- Returns:
- a promise to the response
-
patch
Perform a PATCH on the request asynchronously.- Parameters:
body- represented as JSON- Returns:
- a promise to the response
-
patch
Perform a PATCH on the request asynchronously.- Parameters:
body- represented as a Document- Returns:
- a promise to the response
-
patch
Deprecated.Deprecated as of 2.7.0. Usepatch(BodyWritable)instead.Perform a PATCH on the request asynchronously.- Parameters:
body- represented as an InputStream- Returns:
- a promise to the response
-
patch
Perform a PATCH on the request asynchronously.- Parameters:
body- represented as a File- Returns:
- a promise to the response
-
patch
CompletionStage<WSResponse> patch(Source<? super Http.MultipartFormData.Part<Source<ByteString, ?>>, ?> body) Perform a PATCH on the request asynchronously.- Parameters:
body- represented as a MultipartFormData.Part- Returns:
- a promise to the response
-
post
Perform a POST on the request asynchronously.- Specified by:
postin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
body- represented as body writable- Returns:
- a promise to the response
-
post
Perform a POST on the request asynchronously.- Parameters:
body- represented as String- Returns:
- a promise to the response
-
post
Perform a POST on the request asynchronously.- Parameters:
body- represented as JSON- Returns:
- a promise to the response
-
post
Perform a POST on the request asynchronously.- Parameters:
body- represented as a Document- Returns:
- a promise to the response
-
post
Deprecated.Deprecated as of 2.6.0. Usepost(BodyWritable)instead.Perform a POST on the request asynchronously.- Parameters:
body- represented as an InputStream- Returns:
- a promise to the response
-
post
Perform a POST on the request asynchronously.- Parameters:
body- represented as a File- Returns:
- a promise to the response
-
post
CompletionStage<WSResponse> post(Source<? super Http.MultipartFormData.Part<Source<ByteString, ?>>, ?> body) Perform a POST on the request asynchronously.- Parameters:
body- represented as a MultipartFormData.Part- Returns:
- a promise to the response
-
put
Perform a PUT on the request asynchronously.- Specified by:
putin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
body- represented as BodyWritable- Returns:
- a promise to the response
-
put
Perform a PUT on the request asynchronously.- Parameters:
body- represented as String- Returns:
- a promise to the response
-
put
Perform a PUT on the request asynchronously.- Parameters:
body- represented as JSON- Returns:
- a promise to the response
-
put
Perform a PUT on the request asynchronously.- Parameters:
body- represented as a Document- Returns:
- a promise to the response
-
put
Deprecated.Deprecated as of 2.7.0. Useput(BodyWritable)instead.Perform a PUT on the request asynchronously.- Parameters:
body- represented as an InputStream- Returns:
- a promise to the response
-
put
Perform a PUT on the request asynchronously.- Parameters:
body- represented as a File- Returns:
- a promise to the response
-
put
CompletionStage<WSResponse> put(Source<? super Http.MultipartFormData.Part<Source<ByteString, ?>>, ?> body) Perform a PUT on the request asynchronously.- Parameters:
body- represented as a MultipartFormData.Part- Returns:
- a promise to the response
-
delete
CompletionStage<WSResponse> delete()Perform a DELETE on the request asynchronously.- Specified by:
deletein interfaceplay.libs.ws.StandaloneWSRequest- Returns:
- a promise to the response
-
head
CompletionStage<WSResponse> head()Perform a HEAD on the request asynchronously.- Specified by:
headin interfaceplay.libs.ws.StandaloneWSRequest- Returns:
- a promise to the response
-
options
CompletionStage<WSResponse> options()Perform an OPTIONS on the request asynchronously.- Specified by:
optionsin interfaceplay.libs.ws.StandaloneWSRequest- Returns:
- a promise to the response
-
execute
Execute an arbitrary method on the request asynchronously.- Specified by:
executein interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
method- The method to execute- Returns:
- a promise to the response
-
execute
CompletionStage<WSResponse> execute()Execute an arbitrary method on the request asynchronously. Should be used with setMethod().- Specified by:
executein interfaceplay.libs.ws.StandaloneWSRequest- Returns:
- a promise to the response
-
stream
CompletionStage<WSResponse> stream()Execute this request and stream the response body.- Specified by:
streamin interfaceplay.libs.ws.StandaloneWSRequest- Returns:
- a promise to the streaming response
-
setMethod
Sets the HTTP method this request should use, where the no args execute() method is invoked.- Specified by:
setMethodin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
method- the HTTP method.- Returns:
- the modified WSRequest.
-
setBody
Set the body this request should use.- Specified by:
setBodyin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
body- the body of the request.- Returns:
- the modified WSRequest.
-
setBody
Set the body this request should use.- Parameters:
body- the body of the request.- Returns:
- the modified WSRequest.
-
setBody
Set the body this request should use.- Parameters:
body- the body of the request.- Returns:
- the modified WSRequest.
-
setBody
Deprecated.Deprecated as of 2.6.0. UsesetBody(BodyWritable)instead.Set the body this request should use.- Parameters:
body- the request body.- Returns:
- the modified WSRequest.
-
setBody
Set the body this request should use.- Parameters:
body- the body of the request.- Returns:
- the modified WSRequest.
-
setBody
Set the body this request should use.- Parameters:
body- the body of the request.- Returns:
- the modified WSRequest.
-
addHeader
Adds a header to the request. Note that duplicate headers are allowed by the HTTP specification, and removing a header is not available through this API.- Specified by:
addHeaderin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
name- the header namevalue- the header value- Returns:
- the modified WSRequest.
-
setHeader
Deprecated.Adds a header to the request. Note that duplicate headers are allowed by the HTTP specification, and removing a header is not available through this API.- Parameters:
name- the header namevalue- the header value- Returns:
- the modified WSRequest.
-
setHeaders
Sets all of the headers on the request.- Specified by:
setHeadersin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
headers- the headers- Returns:
- the modified WSRequest.
-
setQueryString
Sets the query string to query.- Specified by:
setQueryStringin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
query- the fully formed query string- Returns:
- the modified WSRequest.
-
setQueryString
Sets the query string to query.- Specified by:
setQueryStringin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
params- the query string parameters- Returns:
- the modified WSRequest.
-
addQueryParameter
Sets a query parameter with the given name, this can be called repeatedly. Duplicate query parameters are allowed.- Specified by:
addQueryParameterin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
name- the query parameter namevalue- the query parameter value- Returns:
- the modified WSRequest.
-
setQueryParameter
Deprecated.Sets a query parameter with the given name, this can be called repeatedly. Duplicate query parameters are allowed.- Parameters:
name- the query parameter namevalue- the query parameter value- Returns:
- the modified WSRequest.
-
addCookie
Adds a cookie to the request- Specified by:
addCookiein interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
cookie- the cookie to add.- Returns:
- the modified request
-
addCookie
Adds a cookie to the request- Parameters:
cookie- the cookie to add.- Returns:
- the modified request
-
addCookies
Sets several cookies on the request.- Specified by:
addCookiesin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
cookies- the cookies.- Returns:
- the modified request
-
setCookies
Sets all the cookies on the request.- Specified by:
setCookiesin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
cookies- all the cookies.- Returns:
- the modified request
-
setAuth
Sets the authentication header for the current request using BASIC authentication.- Specified by:
setAuthin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
userInfo- a string formed as "username:password".- Returns:
- the modified WSRequest.
-
setAuth
Sets the authentication header for the current request using BASIC authentication.- Specified by:
setAuthin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
username- the basic auth usernamepassword- the basic auth password- Returns:
- the modified WSRequest.
-
setAuth
Sets the authentication header for the current request.- Specified by:
setAuthin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
username- the usernamepassword- the passwordscheme- authentication scheme- Returns:
- the modified WSRequest.
-
sign
Sets an (OAuth) signature calculator.- Specified by:
signin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
calculator- the signature calculator- Returns:
- the modified WSRequest
-
setFollowRedirects
Sets whether redirects (301, 302) should be followed automatically.- Specified by:
setFollowRedirectsin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
followRedirects- true if the request should follow redirects- Returns:
- the modified WSRequest
-
setVirtualHost
Sets the virtual host as a "hostname:port" string.- Specified by:
setVirtualHostin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
virtualHost- the virtual host- Returns:
- the modified WSRequest
-
setRequestTimeout
Sets the request timeout in milliseconds.- Specified by:
setRequestTimeoutin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
timeout- the request timeout in milliseconds. A value of -1 indicates an infinite request timeout.- Returns:
- the modified WSRequest.
-
setRequestTimeout
Deprecated.Sets the request timeout in milliseconds.- Parameters:
timeout- the request timeout in milliseconds. A value of -1 indicates an infinite request timeout.- Returns:
- the modified WSRequest.
-
setRequestFilter
Adds a request filter.- Specified by:
setRequestFilterin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
filter- a transforming filter.- Returns:
- the modified request.
-
setContentType
Set the content type. If the request body is a String, and no charset parameter is included, then it will default to UTF-8.- Specified by:
setContentTypein interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
contentType- The content type- Returns:
- the modified WSRequest
-
getUrl
String getUrl()- Specified by:
getUrlin interfaceplay.libs.ws.StandaloneWSRequest- Returns:
- the URL of the request. This has not passed through an internal request builder and so will not be signed.
-
getHeaders
- Specified by:
getHeadersin interfaceplay.libs.ws.StandaloneWSRequest- Returns:
- the headers (a copy to prevent side-effects). This has not passed through an internal request builder and so will not be signed.
-
getQueryParameters
- Specified by:
getQueryParametersin interfaceplay.libs.ws.StandaloneWSRequest- Returns:
- the query parameters (a copy to prevent side-effects). This has not passed through an internal request builder and so will not be signed.
-