Package play.libs.ws
Interface WSRequest
-
- All Superinterfaces:
play.libs.ws.StandaloneWSRequest
- All Known Implementing Classes:
AhcWSRequest
public interface WSRequest extends play.libs.ws.StandaloneWSRequestThis 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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description WSRequestaddCookie(play.libs.ws.WSCookie cookie)Adds a cookie to the requestWSRequestaddCookie(Http.Cookie cookie)Adds a cookie to the requestWSRequestaddCookies(play.libs.ws.WSCookie... cookies)Sets several cookies on the request.WSRequestaddHeader(String name, String value)Adds a header to the request.WSRequestaddQueryParameter(String name, String value)Sets a query parameter with the given name, this can be called repeatedly.CompletionStage<WSResponse>delete()Perform a DELETE on the request asynchronously.CompletionStage<WSResponse>execute()Execute an arbitrary method on the request asynchronously.CompletionStage<WSResponse>execute(String method)Execute an arbitrary method on the request asynchronously.CompletionStage<WSResponse>get()Perform a GET on the request asynchronously.Map<String,List<String>>getHeaders()Map<String,List<String>>getQueryParameters()StringgetUrl()CompletionStage<WSResponse>head()Perform a HEAD on the request asynchronously.CompletionStage<WSResponse>options()Perform an OPTIONS on the request asynchronously.CompletionStage<WSResponse>patch(Source<? super Http.MultipartFormData.Part<Source<ByteString,?>>,?> body)Perform a PATCH on the request asynchronously.CompletionStage<WSResponse>patch(com.fasterxml.jackson.databind.JsonNode body)Perform a PATCH on the request asynchronously.CompletionStage<WSResponse>patch(File body)Perform a PATCH on the request asynchronously.CompletionStage<WSResponse>patch(InputStream body)Deprecated.Deprecated as of 2.7.0.CompletionStage<WSResponse>patch(String body)Perform a PATCH on the request asynchronously.CompletionStage<WSResponse>patch(Document body)Perform a PATCH on the request asynchronously.CompletionStage<WSResponse>patch(play.libs.ws.BodyWritable body)Perform a PATCH on the request asynchronously.CompletionStage<WSResponse>post(Source<? super Http.MultipartFormData.Part<Source<ByteString,?>>,?> body)Perform a POST on the request asynchronously.CompletionStage<WSResponse>post(com.fasterxml.jackson.databind.JsonNode body)Perform a POST on the request asynchronously.CompletionStage<WSResponse>post(File body)Perform a POST on the request asynchronously.CompletionStage<WSResponse>post(InputStream body)Deprecated.Deprecated as of 2.6.0.CompletionStage<WSResponse>post(String body)Perform a POST on the request asynchronously.CompletionStage<WSResponse>post(Document body)Perform a POST on the request asynchronously.CompletionStage<WSResponse>post(play.libs.ws.BodyWritable body)Perform a POST on the request asynchronously.CompletionStage<WSResponse>put(Source<? super Http.MultipartFormData.Part<Source<ByteString,?>>,?> body)Perform a PUT on the request asynchronously.CompletionStage<WSResponse>put(com.fasterxml.jackson.databind.JsonNode body)Perform a PUT on the request asynchronously.CompletionStage<WSResponse>put(File body)Perform a PUT on the request asynchronously.CompletionStage<WSResponse>put(InputStream body)Deprecated.Deprecated as of 2.7.0.CompletionStage<WSResponse>put(String body)Perform a PUT on the request asynchronously.CompletionStage<WSResponse>put(Document body)Perform a PUT on the request asynchronously.CompletionStage<WSResponse>put(play.libs.ws.BodyWritable body)Perform a PUT on the request asynchronously.WSRequestsetAuth(String userInfo)Sets the authentication header for the current request using BASIC authentication.WSRequestsetAuth(String username, String password)Sets the authentication header for the current request using BASIC authentication.WSRequestsetAuth(String username, String password, play.libs.ws.WSAuthScheme scheme)Sets the authentication header for the current request.<U> WSRequestsetBody(Source<ByteString,U> body)Set the body this request should use.WSRequestsetBody(com.fasterxml.jackson.databind.JsonNode body)Set the body this request should use.WSRequestsetBody(File body)Set the body this request should use.WSRequestsetBody(InputStream body)Deprecated.Deprecated as of 2.6.0.WSRequestsetBody(String body)Set the body this request should use.WSRequestsetBody(play.libs.ws.BodyWritable body)Set the body this request should use.WSRequestsetContentType(String contentType)Set the content type.WSRequestsetCookies(List<play.libs.ws.WSCookie> cookies)Sets all the cookies on the request.WSRequestsetFollowRedirects(boolean followRedirects)Sets whether redirects (301, 302) should be followed automatically.WSRequestsetHeader(String name, String value)Deprecated.WSRequestsetHeaders(Map<String,List<String>> headers)Sets all of the headers on the request.WSRequestsetMethod(String method)Sets the HTTP method this request should use, where the no args execute() method is invoked.WSRequestsetQueryParameter(String name, String value)Deprecated.WSRequestsetQueryString(String query)Sets the query string to query.WSRequestsetQueryString(Map<String,List<String>> params)Sets the query string to query.WSRequestsetRequestFilter(play.libs.ws.WSRequestFilter filter)Adds a request filter.WSRequestsetRequestTimeout(long timeout)Deprecated.WSRequestsetRequestTimeout(Duration timeout)Sets the request timeout in milliseconds.WSRequestsetVirtualHost(String virtualHost)Sets the virtual host as a "hostname:port" string.WSRequestsign(play.libs.ws.WSSignatureCalculator calculator)Sets an (OAuth) signature calculator.CompletionStage<WSResponse>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 Detail
-
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
CompletionStage<WSResponse> patch(play.libs.ws.BodyWritable body)
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
CompletionStage<WSResponse> patch(String body)
Perform a PATCH on the request asynchronously.- Parameters:
body- represented as String- Returns:
- a promise to the response
-
patch
CompletionStage<WSResponse> patch(com.fasterxml.jackson.databind.JsonNode body)
Perform a PATCH on the request asynchronously.- Parameters:
body- represented as JSON- Returns:
- a promise to the response
-
patch
CompletionStage<WSResponse> patch(Document body)
Perform a PATCH on the request asynchronously.- Parameters:
body- represented as a Document- Returns:
- a promise to the response
-
patch
@Deprecated CompletionStage<WSResponse> patch(InputStream body)
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
CompletionStage<WSResponse> patch(File body)
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
CompletionStage<WSResponse> post(play.libs.ws.BodyWritable body)
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
CompletionStage<WSResponse> post(String body)
Perform a POST on the request asynchronously.- Parameters:
body- represented as String- Returns:
- a promise to the response
-
post
CompletionStage<WSResponse> post(com.fasterxml.jackson.databind.JsonNode body)
Perform a POST on the request asynchronously.- Parameters:
body- represented as JSON- Returns:
- a promise to the response
-
post
CompletionStage<WSResponse> post(Document body)
Perform a POST on the request asynchronously.- Parameters:
body- represented as a Document- Returns:
- a promise to the response
-
post
@Deprecated CompletionStage<WSResponse> post(InputStream body)
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
CompletionStage<WSResponse> post(File body)
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
CompletionStage<WSResponse> put(play.libs.ws.BodyWritable body)
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
CompletionStage<WSResponse> put(String body)
Perform a PUT on the request asynchronously.- Parameters:
body- represented as String- Returns:
- a promise to the response
-
put
CompletionStage<WSResponse> put(com.fasterxml.jackson.databind.JsonNode body)
Perform a PUT on the request asynchronously.- Parameters:
body- represented as JSON- Returns:
- a promise to the response
-
put
CompletionStage<WSResponse> put(Document body)
Perform a PUT on the request asynchronously.- Parameters:
body- represented as a Document- Returns:
- a promise to the response
-
put
@Deprecated CompletionStage<WSResponse> put(InputStream body)
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
CompletionStage<WSResponse> put(File body)
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
CompletionStage<WSResponse> execute(String method)
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
WSRequest setMethod(String method)
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
WSRequest setBody(play.libs.ws.BodyWritable body)
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
WSRequest setBody(String body)
Set the body this request should use.- Parameters:
body- the body of the request.- Returns:
- the modified WSRequest.
-
setBody
WSRequest setBody(com.fasterxml.jackson.databind.JsonNode body)
Set the body this request should use.- Parameters:
body- the body of the request.- Returns:
- the modified WSRequest.
-
setBody
@Deprecated WSRequest setBody(InputStream body)
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
WSRequest setBody(File body)
Set the body this request should use.- Parameters:
body- the body of the request.- Returns:
- the modified WSRequest.
-
setBody
<U> WSRequest setBody(Source<ByteString,U> body)
Set the body this request should use.- Parameters:
body- the body of the request.- Returns:
- the modified WSRequest.
-
addHeader
WSRequest addHeader(String name, String value)
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 WSRequest setHeader(String name, String value)
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
WSRequest setHeaders(Map<String,List<String>> headers)
Sets all of the headers on the request.- Specified by:
setHeadersin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
headers- the headers- Returns:
- the modified WSRequest.
-
setQueryString
WSRequest setQueryString(String query)
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
WSRequest setQueryString(Map<String,List<String>> params)
Sets the query string to query.- Specified by:
setQueryStringin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
params- the query string parameters- Returns:
- the modified WSRequest.
-
addQueryParameter
WSRequest addQueryParameter(String name, String value)
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 WSRequest setQueryParameter(String name, String value)
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
WSRequest addCookie(play.libs.ws.WSCookie cookie)
Adds a cookie to the request- Specified by:
addCookiein interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
cookie- the cookie to add.- Returns:
- the modified request
-
addCookie
WSRequest addCookie(Http.Cookie cookie)
Adds a cookie to the request- Parameters:
cookie- the cookie to add.- Returns:
- the modified request
-
addCookies
WSRequest addCookies(play.libs.ws.WSCookie... cookies)
Sets several cookies on the request.- Specified by:
addCookiesin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
cookies- the cookies.- Returns:
- the modified request
-
setCookies
WSRequest setCookies(List<play.libs.ws.WSCookie> cookies)
Sets all the cookies on the request.- Specified by:
setCookiesin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
cookies- all the cookies.- Returns:
- the modified request
-
setAuth
WSRequest setAuth(String userInfo)
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
WSRequest setAuth(String username, String password)
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
WSRequest setAuth(String username, String password, play.libs.ws.WSAuthScheme scheme)
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
WSRequest sign(play.libs.ws.WSSignatureCalculator calculator)
Sets an (OAuth) signature calculator.- Specified by:
signin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
calculator- the signature calculator- Returns:
- the modified WSRequest
-
setFollowRedirects
WSRequest setFollowRedirects(boolean followRedirects)
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
WSRequest setVirtualHost(String virtualHost)
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
WSRequest setRequestTimeout(Duration timeout)
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 WSRequest setRequestTimeout(long timeout)
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
WSRequest setRequestFilter(play.libs.ws.WSRequestFilter filter)
Adds a request filter.- Specified by:
setRequestFilterin interfaceplay.libs.ws.StandaloneWSRequest- Parameters:
filter- a transforming filter.- Returns:
- the modified request.
-
setContentType
WSRequest setContentType(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.- 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
Map<String,List<String>> 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.
-
-