public class OAuthRequest
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_CONTENT_TYPE |
Constructor and Description |
---|
OAuthRequest(java.lang.String verb,
java.lang.String url)
Construct an OAuthRequest to apply to specified verb against the specified resource URL.
|
OAuthRequest(java.lang.String verb,
java.lang.String baseUrl,
TextualPath resourcePath)
Construct an OAuthRequest to apply to specified verb against the specified resource.
|
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 |
addOAuthParameter(java.lang.String key,
java.lang.String value)
Adds an OAuth parameter.
|
void |
addPayload(byte[] payload)
Overloaded version for byte arrays
|
void |
addPayload(ByteArrayRange payload)
Overloaded version for byte arrays
|
void |
addPayload(File filePayload)
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 query string parameter
|
void |
addQueryStringParameters(HttpRequestParams params)
Add the passed parameters to the query string
|
ParameterList |
getBodyParams()
Obtains a
ParameterList of the body parameters. |
java.lang.String |
getCompleteUrl()
Returns the complete url (host + resource + encoded querystring parameters).
|
Map<java.lang.String,java.lang.String> |
getHeaders()
Returns the connection headers as a
Map |
Map<java.lang.String,java.lang.String> |
getOauthParameters()
Returns the
Map containing the key-value pair of parameters. |
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.
|
java.lang.String |
getVerb()
Returns the HTTP Verb
|
OAuthResponse |
send()
Execute the request and return a
OAuthResponse |
void |
setTimeout(int timeoutInMillis)
Sets the timeout for the underlying
HttpRequest |
java.lang.String |
toString() |
public static final java.lang.String DEFAULT_CONTENT_TYPE
public OAuthRequest(java.lang.String verb, java.lang.String url)
verb
- HTTP verb/methodurl
- resource URLpublic OAuthRequest(java.lang.String verb, java.lang.String baseUrl, TextualPath resourcePath)
verb
- HTTP verb/methodbaseUrl
- base URL, including server/port and optionally start of path; this should NOT end with a /
characterresourcePath
- path to resource on server, which will be appended to baseUrlpublic void addOAuthParameter(java.lang.String key, java.lang.String value)
key
- name of the parametervalue
- value of the parameterjava.lang.IllegalArgumentException
- if the parameter is not an OAuth parameterpublic Map<java.lang.String,java.lang.String> getOauthParameters()
Map
containing the key-value pair of parameters.public java.lang.String toString()
toString
in class java.lang.Object
public OAuthResponse send()
OAuthResponse
java.lang.RuntimeException
- if the connection cannot be created.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 addQueryStringParameters(HttpRequestParams params)
params
- parameterspublic void addPayload(java.lang.String payload)
payload
- the body of the requestpublic void addPayload(byte[] payload)
payload
- public void addPayload(ByteArrayRange payload)
payload
- public void addPayload(File filePayload)
filePayload
- 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.ParameterList
containing the body parameters.public java.lang.String getUrl()
public java.lang.String getSanitizedUrl()
public java.lang.String getVerb()
public Map<java.lang.String,java.lang.String> getHeaders()
Map
public void setTimeout(int timeoutInMillis)
HttpRequest
timeoutInMillis
- duration of the timeout