public class WLResourceRequest
extends java.lang.Object
send methods with different inputs for the body of a request.send methods support the WLResponseListener response listener.
The onSuccess method of this listener is called with an instance of the WLResponse class.
The content of the response is read by the security framework into the WLResponse instance, and is then
accessible through WLResponse methods. In case of failure, the onFailure method of the listener is
called with an instance of the WLFailResponse class, which contains all the information about the failure.onSuccess method.onFailure method.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BEARER_ERROR_INVALID_TOKEN |
static java.lang.String |
DELETE
String constant for the HTTP
DELETE method. |
static java.lang.String |
GET
String constant for the HTTP
GET method. |
static java.lang.String |
HEAD
String constant for the HTTP {@code HEAD method.
|
static java.lang.String |
OPTIONS
String constant for the HTTP
OPTIONS method. |
static java.lang.String |
POST
String constant for the HTTP
POST method. |
static java.lang.String |
PUT
String constant for the HTTP
PUT method. |
static java.lang.String |
TRACE
String constant for the HTTP
TRACE method. |
| Constructor and Description |
|---|
WLResourceRequest(java.net.URI url,
java.lang.String method)
Constructs a new resource request with the specified URL, using the specified HTTP method.
|
WLResourceRequest(java.net.URI url,
java.lang.String method,
int timeout)
Constructs a new resource request with the specified URL, using the specified HTTP method.
Additionally this constructor sets a custom expiration period (timeout) for the request. |
WLResourceRequest(java.net.URI url,
java.lang.String method,
int timeout,
java.lang.String scope)
Constructs a new resource request with the specified URL and protecting scope, using the specified HTTP method.
|
WLResourceRequest(java.net.URI url,
java.lang.String method,
java.lang.String scope)
Constructs a new resource request with the specified URL and protecting scope, using the specified HTTP method.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a header to this resource request.
This method allows response headers to have multiple values. |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getAllHeaders()
Returns all headers for this resource request.
|
java.util.List<java.lang.String> |
getHeaders(java.lang.String headerName)
Returns all headers of the specified name for this resource request.
|
java.lang.String |
getMethod()
Returns the HTTP method of this resource request.
|
java.util.Map<java.lang.String,java.lang.String> |
getQueryParameters()
Returns the query parameters set for this resource request as a Map.
|
java.lang.String |
getQueryString()
Returns the query parameters of this resource request as a string.
|
int |
getTimeout()
Returns the expiration period (timeout) for this resource request.
|
java.net.URL |
getUrl()
Returns the URL for this resource request.
|
void |
removeHeaders(java.lang.String headerName)
Removes headers with the specified name for this resource request.
|
void |
send(JSONObject json,
WLResponseListener listener)
Sends this resource request asynchronously, with the given JSON object as the request body.
|
void |
send(java.util.Map<java.lang.String,java.lang.String> formParameters,
WLResponseListener listener)
Sends this resource request asynchronously, with the provided form parameters as the request body.
|
void |
send(java.lang.String requestBody,
WLResponseListener listener)
Sends this resource request asynchronously, with the provided string as the request body.
|
void |
send(WLResponseListener listener)
Send this resource request asynchronously, without a request body.
|
void |
setHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
Sets the specified headers for this resource request.
For a header that is already set, the new value overwrites the previous value. |
void |
setQueryParameter(java.lang.String name,
java.lang.String value)
Sets the value of the specified query parameter to the provided value.
If no matching parameter is found, the parameter is added. |
void |
setQueryParameters(java.util.HashMap<java.lang.String,java.lang.String> parameters)
Sets the query parameters of this resource.
|
void |
setTimeout(int timeout)
Sets the expiration period (timeout) for this resource request.
|
public static final java.lang.String BEARER_ERROR_INVALID_TOKEN
public static final java.lang.String GET
GET method.public static final java.lang.String POST
POST method.public static final java.lang.String PUT
PUT method.public static final java.lang.String DELETE
DELETE method.public static final java.lang.String TRACE
TRACE method.public static final java.lang.String HEAD
public static final java.lang.String OPTIONS
OPTIONS method.public WLResourceRequest(java.net.URI url,
java.lang.String method)
url - Resource URL, either as a relative or as an absolute path.method - HTTP method to use.public WLResourceRequest(java.net.URI url,
java.lang.String method,
java.lang.String scope)
url - Resource URL, either as a relative or as an absolute path.method - HTTP method to use.scope - Protecting scope of the requested resource.public WLResourceRequest(java.net.URI url,
java.lang.String method,
int timeout)
url - Resource URL, either as a relative or as an absolute path.method - The HTTP method to use.timeout - The timeout in milliseconds for this request.public WLResourceRequest(java.net.URI url,
java.lang.String method,
int timeout,
java.lang.String scope)
url - Resource URL, either as a relative or as an absolute path.method - HTTP method to use.timeout - The timeout in milliseconds for this request.scope - Protecting scope of the requested resource.public java.net.URL getUrl()
public java.lang.String getMethod()
public java.util.Map<java.lang.String,java.lang.String> getQueryParameters()
public java.lang.String getQueryString()
public void setQueryParameters(java.util.HashMap<java.lang.String,java.lang.String> parameters)
parameters - A HashMap that contains the query parameters of the request.public void setQueryParameter(java.lang.String name,
java.lang.String value)
name - Name of the parameter to set.value - Value to set for the parameter.public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getAllHeaders()
public java.util.List<java.lang.String> getHeaders(java.lang.String headerName)
headerName - Name of the headers to retrieve.public void removeHeaders(java.lang.String headerName)
headerName - Name of the headers to remove.public void setHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
headerMap - Map of the headers to set.public void addHeader(java.lang.String name,
java.lang.String value)
value - Value of the header to add.public int getTimeout()
public void setTimeout(int timeout)
timeout - Expiration period for this resource request, in milliseconds.public void send(WLResponseListener listener)
listener - Listener whose onSuccess or onFailure method will be called when this request processing completes.public void send(java.lang.String requestBody,
WLResponseListener listener)
requestBody - The request body textlistener - Listener whose onSuccess or onFailure method will be called when this request processing completes.public void send(java.util.Map<java.lang.String,java.lang.String> formParameters,
WLResponseListener listener)
formParameters - The parameters to put in the request bodylistener - Listener whose onSuccess or onFailure method will be called when this request processing completes.public void send(JSONObject json,
WLResponseListener listener)
json - The JSON object to put in the request bodylistener - Listener whose onSuccess or onFailure method will be called when this request processing completes.