public class RequestBuilder extends Object
Modifier and Type | Method and Description |
---|---|
com.squareup.okhttp.Request |
build()
Builds a request with the given set of parameters and files.
|
static RequestBuilder |
delete(String url)
The DELETE method requests that the origin server delete the resource identified by the
Request-URI.
|
static RequestBuilder |
get(String url)
The GET method means retrieve whatever information (in the form of an entity) is identified by
the Request-URI.
|
static RequestBuilder |
post(String url)
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 RequestBuilder |
put(String url)
The PUT method requests that the enclosed entity be stored under the supplied Request-URI.
|
String |
toString() |
String |
toUrl()
Create and return the URL being used in the request.
|
RequestBuilder |
withBody(com.squareup.okhttp.RequestBody body)
Adds an arbitrary entity to the request (used with POST/PUT).
|
RequestBuilder |
withBodyContent(String content,
String contentType)
Adds string content to the request (used with POST/PUT).
|
RequestBuilder |
withBodyJson(com.google.gson.JsonObject json)
Adds a JSON content to the request (used with POST/PUT).
|
RequestBuilder |
withForm(Object... args)
Adds form parameters.
|
RequestBuilder |
withFormMap(Map<String,Object> parameters)
Adds form parameters.
|
RequestBuilder |
withHeader(Object... args)
Adds header parameters.
|
RequestBuilder |
withQuery(Object... args)
Adds query parameters.
|
RequestBuilder |
withQueryMap(Map<String,Object> parameters)
Adds query parameters.
|
public static RequestBuilder delete(String url)
url
- the URLpublic static RequestBuilder get(String url)
url
- the URLpublic static RequestBuilder post(String url)
url
- the URLpublic static RequestBuilder put(String url)
url
- the URLpublic com.squareup.okhttp.Request build()
public String toUrl()
public RequestBuilder withBody(com.squareup.okhttp.RequestBody body)
body
- the request body to POST/PUTpublic RequestBuilder withBodyContent(String content, String contentType)
RequestBody
encoded with UTF-8content
- the content to POST/PUTcontentType
- the HTTP contentType to use.public RequestBuilder withBodyJson(com.google.gson.JsonObject json)
RequestBody
encoded with UTF-8 and use "application/json" as Content-Typejson
- the JsonObject jsonpublic RequestBuilder withForm(Object... args)
args
- a list of name-value form parameterspublic RequestBuilder withFormMap(Map<String,Object> parameters)
parameters
- a list of name-value form parameterspublic RequestBuilder withHeader(Object... args)
args
- a list of name-value headerspublic RequestBuilder withQuery(Object... args)
args
- a list of name-value query parameterspublic RequestBuilder withQueryMap(Map<String,Object> parameters)
parameters
- a list of name-value query parametersCopyright © 2015–2016. All rights reserved.