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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description WSRequest
addCookie(play.libs.ws.WSCookie cookie)
Adds a cookie to the requestWSRequest
addCookie(Http.Cookie cookie)
Adds a cookie to the requestWSRequest
addCookies(play.libs.ws.WSCookie... cookies)
Sets several cookies on the request.WSRequest
addHeader(String name, String value)
Adds a header to the request.WSRequest
addQueryParameter(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()
String
getUrl()
CompletionStage<WSResponse>
head()
Perform a HEAD on the request asynchronously.CompletionStage<WSResponse>
options()
Perform an OPTIONS 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(Source<? super Http.MultipartFormData.Part<Source<ByteString,?>>,?> 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(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(Source<? super Http.MultipartFormData.Part<Source<ByteString,?>>,?> 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(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(Source<? super Http.MultipartFormData.Part<Source<ByteString,?>>,?> 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.WSRequest
setAuth(String userInfo)
Sets the authentication header for the current request using BASIC authentication.WSRequest
setAuth(String username, String password)
Sets the authentication header for the current request using BASIC authentication.WSRequest
setAuth(String username, String password, play.libs.ws.WSAuthScheme scheme)
Sets the authentication header for the current request.WSRequest
setBody(com.fasterxml.jackson.databind.JsonNode body)
Set the body this request should use.WSRequest
setBody(File body)
Set the body this request should use.WSRequest
setBody(InputStream body)
Deprecated.Deprecated as of 2.6.0.WSRequest
setBody(String body)
Set the body this request should use.<U> WSRequest
setBody(Source<ByteString,U> body)
Set the body this request should use.WSRequest
setBody(play.libs.ws.BodyWritable body)
Set the body this request should use.WSRequest
setContentType(String contentType)
Set the content type.WSRequest
setCookies(List<play.libs.ws.WSCookie> cookies)
Sets all the cookies on the request.WSRequest
setFollowRedirects(boolean followRedirects)
Sets whether redirects (301, 302) should be followed automatically.WSRequest
setHeader(String name, String value)
Deprecated.WSRequest
setHeaders(Map<String,List<String>> headers)
Sets all of the headers on the request.WSRequest
setMethod(String method)
Sets the HTTP method this request should use, where the no args execute() method is invoked.WSRequest
setQueryParameter(String name, String value)
Deprecated.WSRequest
setQueryString(String query)
Sets the query string to query.WSRequest
setQueryString(Map<String,List<String>> params)
Sets the query string to query.WSRequest
setRequestFilter(play.libs.ws.WSRequestFilter filter)
Adds a request filter.WSRequest
setRequestTimeout(long timeout)
Deprecated.WSRequest
setRequestTimeout(Duration timeout)
Sets the request timeout in milliseconds.WSRequest
setVirtualHost(String virtualHost)
Sets the virtual host as a "hostname:port" string.WSRequest
sign(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:
get
in 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:
patch
in 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:
post
in 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:
put
in 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:
delete
in interfaceplay.libs.ws.StandaloneWSRequest
- Returns:
- a promise to the response
-
head
CompletionStage<WSResponse> head()
Perform a HEAD on the request asynchronously.- Specified by:
head
in interfaceplay.libs.ws.StandaloneWSRequest
- Returns:
- a promise to the response
-
options
CompletionStage<WSResponse> options()
Perform an OPTIONS on the request asynchronously.- Specified by:
options
in 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:
execute
in 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:
execute
in interfaceplay.libs.ws.StandaloneWSRequest
- Returns:
- a promise to the response
-
stream
CompletionStage<WSResponse> stream()
Execute this request and stream the response body.- Specified by:
stream
in 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:
setMethod
in 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:
setBody
in 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:
addHeader
in 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:
setHeaders
in 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:
setQueryString
in 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:
setQueryString
in 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:
addQueryParameter
in 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:
addCookie
in 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:
addCookies
in 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:
setCookies
in 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:
setAuth
in 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:
setAuth
in 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:
setAuth
in 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:
sign
in 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:
setFollowRedirects
in 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:
setVirtualHost
in 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:
setRequestTimeout
in 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:
setRequestFilter
in 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:
setContentType
in interfaceplay.libs.ws.StandaloneWSRequest
- Parameters:
contentType
- The content type- Returns:
- the modified WSRequest
-
getUrl
String getUrl()
- Specified by:
getUrl
in 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:
getHeaders
in 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.
-
-