public class CustomRequest extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CONTENT_TYPE |
Constructor and Description |
---|
CustomRequest(org.scribe.model.Verb verb,
String url)
Creates a new Http Request
|
Modifier and Type | Method and Description |
---|---|
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 |
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
|
Map<String,String> |
getBodyParams()
Obtains a
Map of the body parameters. |
String |
getCharset()
Returns the connection charset.
|
Map<String,String> |
getHeaders()
Returns the connection headers as a
Map |
Map<String,String> |
getQueryStringParams()
Get a
Map of 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.
|
org.scribe.model.Verb |
getVerb()
Returns the HTTP Verb
|
org.scribe.model.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 wether 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() |
public static final String DEFAULT_CONTENT_TYPE
public CustomRequest(org.scribe.model.Verb verb, String url)
verb
- Http Verb (GET, POST, etc)url
- url with optional querystring parameters.public org.scribe.model.Response send()
Response
RuntimeException
- if the connection cannot be created.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 Map<String,String> getQueryStringParams()
Map
of the query string parameters.org.scribe.exceptions.OAuthException
- if the URL is not validpublic Map<String,String> getBodyParams()
Map
of the body parameters.public String getUrl()
public String getSanitizedUrl()
public String getBodyContents()
org.scribe.exceptions.OAuthException
- if the charset chosen is not supportedpublic org.scribe.model.Verb getVerb()
public Map<String,String> getHeaders()
Map
public String getCharset()
Charset
defaultCharset if not setpublic 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
Copyright © 2012 xaloon.org. All Rights Reserved.