public class Request extends Object
HttpRequestBase request = Request
.Get("/v1/translate")
.withQuery("from", "en", "to", "es", "text", "Good Morning")
.build();
| Modifier and Type | Method and Description |
|---|---|
org.apache.http.client.methods.HttpRequestBase |
build()
Builds a request with the given set of parameters and files.
|
static Request |
Delete(String url,
Object... args)
The DELETE method requests that the origin server delete the resource
identified by the Request-URI.
|
static Request |
Get(String url,
Object... args)
The GET method means retrieve whatever information (in the form of an
entity) is identified by the Request-URI.
|
static Request |
Post(String url,
Object... args)
The POST request method is designed to request that a web server accept
the data enclosed in the request message's body for storage.
|
static Request |
Put(String url,
Object... args)
The PUT method requests that the enclosed entity be stored under the
supplied Request-URI.
|
String |
toUrl()
Create and return the URL being used in the request.
|
Request |
withContent(com.google.gson.JsonObject json)
Adds a JSON content to the request (used with POST/PUT).
|
Request |
withContent(String content,
String contentType)
Adds string content to the request (used with POST/PUT).
|
Request |
withEntity(org.apache.http.HttpEntity entity)
Adds an arbitrary entity to the request (used with POST/PUT).
|
Request |
withForm(Map<String,Object> parameters)
Adds form parameters.
|
Request |
withForm(Object... args)
Adds form parameters.
|
Request |
withHeader(Object... args)
Adds header parameters.
|
Request |
withQuery(Map<String,Object> parameters)
Adds query parameters.
|
Request |
withQuery(Object... args)
Adds query parameters.
|
public static Request Delete(String url, Object... args)
url - the URLargs - the list of arguments to format the URLpublic static Request Get(String url, Object... args)
url - the URLargs - the list of arguments to format the URLpublic static Request Post(String url, Object... args)
url - the URLargs - the list of arguments to format the URLpublic static Request Put(String url, Object... args)
url - the URLargs - the list of arguments to format the URLpublic org.apache.http.client.methods.HttpRequestBase build()
public String toUrl()
public Request withContent(com.google.gson.JsonObject json)
StringEntity
encoded with UTF-8 and use "application/json" as Content-Typejson - the JsonObject jsonpublic Request withContent(String content, String contentType)
StringEntity
encoded with UTF-8content - the content to POST/PUTcontentType - the HTTP contentType to use.public Request withEntity(org.apache.http.HttpEntity entity)
entity - the entity to POST/PUTpublic Request withForm(Object... args)
args - a list of name-value form parameterspublic Request withHeader(Object... args)
args - a list of name-value headerspublic Request withQuery(Object... args)
args - a list of name-value query parameterspublic Request withQuery(Map<String,Object> parameters)
parameters - a list of name-value query parametersCopyright © 2015. All rights reserved.