org.jboss.seam.social.rest
Interface RestRequest

All Superinterfaces:
Serializable
All Known Subinterfaces:
OAuthRequest
All Known Implementing Classes:
OAuthRequestScribe

public interface RestRequest
extends Serializable

Author:
Antoine Sabot-Durand

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 addPayload(String payload)
          Add body payload.
 void addQuerystringParameter(String key, String value)
          Add a QueryString parameter
 String getBodyContents()
           
 Map<String,String> getBodyParams()
          Obtains a Map of the body parameters.
 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.
 RestVerb getVerb()
           
 RestResponse send()
          Execute the request and return a HttpResonse
 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
 

Method Detail

send

RestResponse send()
Execute the request and return a HttpResonse

Returns:
Rest Response

addHeader

void addHeader(String key,
               String value)
Add an HTTP Header to the Request

Parameters:
key - the header name
value - the header value

addBodyParameter

void addBodyParameter(String key,
                      String value)
Add a body Parameter (for POST/ PUT Requests)

Parameters:
key - the parameter name
value - the parameter value

addQuerystringParameter

void addQuerystringParameter(String key,
                             String value)
Add a QueryString parameter

Parameters:
key - the parameter name
value - the parameter value

addPayload

void addPayload(String payload)
Add body payload. This method is used when the HTTP body is not a form-url-encoded string, but another thing. Like for example XML.

Parameters:
payload - the body of the request

getQueryStringParams

Map<String,String> getQueryStringParams()
Get a Map of the query string parameters.

Returns:
a map containing the query string parameters
Throws:
OAuthException - if the URL is not valid

getBodyParams

Map<String,String> getBodyParams()
Obtains a Map of the body parameters.

Returns:
a map containing the body parameters.

getUrl

String getUrl()
Obtains the URL of the HTTP Request.

Returns:
the original URL of the HTTP Request

getSanitizedUrl

String getSanitizedUrl()
Returns the URL without the port and the query string part.

Returns:
the sanitized URL

getBodyContents

String getBodyContents()
Returns:
the Body of the request

getVerb

RestVerb getVerb()
Returns:
the REST verb

getHeaders

Map<String,String> getHeaders()
Returns the connection headers as a Map

Returns:
map of headers

setConnectTimeout

void setConnectTimeout(int duration,
                       TimeUnit unit)
Sets the connect timeout for the underlying HttpURLConnection

Parameters:
duration - duration of the timeout
unit - unit of time (milliseconds, seconds, etc)

setReadTimeout

void setReadTimeout(int duration,
                    TimeUnit unit)
Sets the read timeout for the underlying HttpURLConnection

Parameters:
duration - duration of the timeout
unit - unit of time (milliseconds, seconds, etc)


Copyright © 2011 Seam Framework. All Rights Reserved.