public class Request
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_CONTENT_TYPE |
| Constructor and Description |
|---|
Request(Verb verb,
java.lang.String url)
Creates a new Http Request
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBodyParameter(java.lang.String key,
java.lang.String value)
Add a body Parameter (for POST/ PUT Requests)
|
void |
addHeader(java.lang.String key,
java.lang.String value)
Add an HTTP Header to the Request
|
void |
addPayload(byte[] payload)
Overloaded version for byte arrays
|
void |
addPayload(java.lang.String payload)
Add body payload.
|
void |
addQuerystringParameter(java.lang.String key,
java.lang.String value)
Add a QueryString parameter
|
java.lang.String |
getBodyContents()
Returns the body of the request
|
ParameterList |
getBodyParams()
Obtains a
ParameterList of the body parameters. |
java.lang.String |
getCharset()
Returns the connection charset.
|
java.lang.String |
getCompleteUrl()
Returns the complete url (host + resource + encoded querystring parameters).
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders()
Returns the connection headers as a
Map |
ParameterList |
getQueryStringParams()
Get a
ParameterList with the query string parameters. |
java.lang.String |
getSanitizedUrl()
Returns the URL without the port and the query string part.
|
java.lang.String |
getUrl()
Obtains the URL of the HTTP Request.
|
Verb |
getVerb()
Returns the HTTP Verb
|
Response |
send() |
Response |
send(RequestTuner tuner)
Execute the request and return a
Response |
void |
setCharset(java.lang.String charsetName)
Set the charset of the body of the request
|
void |
setConnectionKeepAlive(boolean connectionKeepAlive)
Sets whether the underlying Http Connection is persistent or not.
|
void |
setConnectTimeout(int duration,
java.util.concurrent.TimeUnit unit)
Sets the connect timeout for the underlying
HttpURLConnection |
void |
setFollowRedirects(boolean followRedirects)
Sets whether the underlying Http Connection follows redirects or not.
|
void |
setReadTimeout(int duration,
java.util.concurrent.TimeUnit unit)
Sets the read timeout for the underlying
HttpURLConnection |
java.lang.String |
toString() |
public static final java.lang.String DEFAULT_CONTENT_TYPE
public Request(Verb verb, java.lang.String url)
verb - Http Verb (GET, POST, etc)url - url with optional querystring parameters.public Response send(RequestTuner tuner)
Responsejava.lang.RuntimeException - if the connection cannot be created.public Response send()
public java.lang.String getCompleteUrl()
public void addHeader(java.lang.String key,
java.lang.String value)
key - the header namevalue - the header valuepublic void addBodyParameter(java.lang.String key,
java.lang.String value)
key - the parameter namevalue - the parameter valuepublic void addQuerystringParameter(java.lang.String key,
java.lang.String value)
key - the parameter namevalue - the parameter valuepublic void addPayload(java.lang.String payload)
payload - the body of the requestpublic void addPayload(byte[] payload)
payload - public ParameterList getQueryStringParams()
ParameterList with the query string parameters.ParameterList containing the query string parameters.OAuthException - if the request URL is not valid.public ParameterList getBodyParams()
ParameterList of the body parameters.ParameterListcontaining the body parameters.public java.lang.String getUrl()
public java.lang.String getSanitizedUrl()
public java.lang.String getBodyContents()
OAuthException - if the charset chosen is not supportedpublic Verb getVerb()
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
Mappublic java.lang.String getCharset()
Charset defaultCharset if not setpublic void setConnectTimeout(int duration,
java.util.concurrent.TimeUnit unit)
HttpURLConnectionduration - duration of the timeoutunit - unit of time (milliseconds, seconds, etc)public void setReadTimeout(int duration,
java.util.concurrent.TimeUnit unit)
HttpURLConnectionduration - duration of the timeoutunit - unit of time (milliseconds, seconds, etc)public void setCharset(java.lang.String charsetName)
charsetName - name of the charset of the requestpublic void setConnectionKeepAlive(boolean connectionKeepAlive)
connectionKeepAlive - http://download.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.htmlpublic void setFollowRedirects(boolean followRedirects)
followRedirects - http://docs.oracle.com/javase/6/docs/api/java/net/HttpURLConnection.html#setInstanceFollowRedirects(boolean)public java.lang.String toString()
toString in class java.lang.Object"Copyright © 2010 - 2018 Adobe Systems Incorporated. All Rights Reserved"