|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectoauthP5.oauth.OAuthRequest
public class OAuthRequest
The representation of an OAuth HttpRequest.
Adds OAuth-related functionality to the Request
Field Summary | |
---|---|
static String |
DEFAULT_CONTENT_TYPE
|
Constructor Summary | |
---|---|
OAuthRequest(Verb verb,
String url)
Default constructor. |
Method Summary | |
---|---|
void |
addBodyParameter(String key,
String value)
Add a body Parameter (for POST/ PUT Requests) |
void |
addHeader(String key,
String value)
Add an HTTP Header to the Request |
void |
addOAuthParameter(String key,
String value)
Adds an OAuth parameter. |
void |
addPayload(byte[] payload)
Overloaded version for byte arrays |
void |
addPayload(String payload)
Add body payload. |
void |
addQuerystringParameter(String key,
String value)
Add a QueryString parameter |
String |
getBodyContents()
Returns the body of the request |
ParameterList |
getBodyParams()
Obtains a ParameterList of the body parameters. |
String |
getCharset()
Returns the connection charset. |
String |
getCompleteUrl()
Returns the complete url (host + resource + encoded querystring parameters). |
Map<String,String> |
getHeaders()
Returns the connection headers as a Map |
Map<String,String> |
getOauthParameters()
Returns the Map containing the key-value pair of parameters. |
ParameterList |
getQueryStringParams()
Get a ParameterList with the query string parameters. |
String |
getSanitizedUrl()
Returns the URL without the port and the query string part. |
String |
getUrl()
Obtains the URL of the HTTP Request. |
Verb |
getVerb()
Returns the HTTP Verb |
Response |
send()
Execute the request and return a Response |
void |
setCharset(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,
TimeUnit unit)
Sets the connect timeout for the underlying HttpURLConnection |
void |
setReadTimeout(int duration,
TimeUnit unit)
Sets the read timeout for the underlying HttpURLConnection |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_CONTENT_TYPE
Constructor Detail |
---|
public OAuthRequest(Verb verb, String url)
verb
- Http verb/methodurl
- resource URLMethod Detail |
---|
public void addOAuthParameter(String key, String value)
key
- name of the parametervalue
- value of the parameter
IllegalArgumentException
- if the parameter is not an OAuth parameterpublic Map<String,String> getOauthParameters()
Map
containing the key-value pair of parameters.
public String toString()
public Response send()
Response
RuntimeException
- if the connection cannot be created.public String getCompleteUrl()
public void addHeader(String key, String value)
key
- the header namevalue
- the header valuepublic void addBodyParameter(String key, String value)
key
- the parameter namevalue
- the parameter valuepublic void addQuerystringParameter(String key, String value)
key
- the parameter namevalue
- the parameter valuepublic void addPayload(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.
ParameterList
containing the body parameters.public String getUrl()
public String getSanitizedUrl()
public String getBodyContents()
OAuthException
- if the charset chosen is not supportedpublic Verb getVerb()
public Map<String,String> getHeaders()
Map
public String getCharset()
Charset
defaultCharset if not set
public void setConnectTimeout(int duration, TimeUnit unit)
HttpURLConnection
duration
- duration of the timeoutunit
- unit of time (milliseconds, seconds, etc)public void setReadTimeout(int duration, TimeUnit unit)
HttpURLConnection
duration
- duration of the timeoutunit
- unit of time (milliseconds, seconds, etc)public void setCharset(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.html
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |