org.openid4java.util
Class HttpRequestOptions

java.lang.Object
  extended by org.openid4java.util.HttpRequestOptions

public class HttpRequestOptions
extends java.lang.Object

Container class for the various options associated with HTTP requests.

Author:
Marius Scurtescu, Johnny Bufu
See Also:
HttpCache

Field Summary
private  boolean _allowCircularRedirects
           
private  long _cacheTTLSeconds
          If set to a positive value, then new HTTP request will be placed if the cache is older than that positive value (in seconds) This applies to the internal HttpCache, not the HTTP protocol cache-control mechanisms.
private  int _connTimeout
          HTTP connect timeout, in milliseconds.
private  java.lang.String _contentType
          If HttpRequestOptions' content type matches a cached HttpResponse's content type, the cache copy is returned; otherwise a new HTTP request is placed.
private  int _maxBodySize
          Maximum size in bytes to be retrieved for the response body.
private  int _maxRedirects
          Maximum number of redirects to be followed for the HTTP calls.
private  java.util.Map _requestHeaders
          Map with HTTP request headers to be used when placing the HTTP request.
private  int _socketTimeout
          HTTP socket (read) timeout, in milliseconds.
private  boolean _useCache
          If set to false, a new HTTP request will be placed even if a cached copy exists.
 
Constructor Summary
HttpRequestOptions()
          Constructs a set of HTTP request options with the default values.
HttpRequestOptions(HttpRequestOptions other)
          Creates a new HttpRequestOptions object as a clone of the provided parameter.
 
Method Summary
 void addRequestHeader(java.lang.String headerName, java.lang.String headerValue)
          Adds a new HTTP request header.
 boolean getAllowCircularRedirects()
           
 long getCacheTTLSeconds()
          Gets the TTL for the cached response in seconds
 int getConnTimeout()
          Gets the HTTP connect timeout, in milliseconds.
 java.lang.String getContentType()
          Gets the required content-type for the HTTP response.
static HttpRequestOptions getDefaultOptionsForDiscovery()
          Returns an HttpRequestOptions object suitable to use for HTTP requests to perform discovery.
static HttpRequestOptions getDefaultOptionsForOpCalls()
          Returns an HttpRequestOptions object suitable to use for HTTP requests to OP endpoints for the purpose of creating associations or verifying signatures.
 int getMaxBodySize()
          Gets configuration parameter for the maximum HTTP body size that will be downloaded.
 int getMaxRedirects()
          Gets the internal limit configured for the maximum number of redirects to be followed for the HTTP calls.
 java.util.Map getRequestHeaders()
          Gets the HTTP request headers that will be used when placing HTTP requests using the options in this object.
 int getSocketTimeout()
          Gets the HTTP socket (read) timeout, in milliseconds.
 boolean isUseCache()
          Returns true if a cached copy can be used when placing HTTP requests using the options in this object.
 void setAllowCircularRedirects(boolean allow)
           
 void setCacheTTLSeconds(long ttl)
          Sets the TTL for the cached response in seconds
 void setConnTimeout(int connTimeout)
          Sets the HTTP connect timeout, in milliseconds.
 void setContentType(java.lang.String contentType)
          Sets the required content-type for the HTTP response.
 void setMaxBodySize(int maxBodySize)
          Sets the maximum HTTP body size that will be downloaded.
 void setMaxRedirects(int maxRedirects)
          Sets the maximum number of redirects to be followed for the HTTP calls.
 void setRequestHeaders(java.util.Map requestHeaders)
          Sets the HTTP request headers that will be used when placing HTTP requests using the options in this object.
 void setSocketTimeout(int socketTimeout)
          Sets HTTP socket (read) timeout, in milliseconds.
 void setUseCache(boolean useCache)
          Sets the flag for allowing cached copy to be used when placing HTTP requests using the options in this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_connTimeout

private int _connTimeout
HTTP connect timeout, in milliseconds. Default 3000 miliseconds.


_socketTimeout

private int _socketTimeout
HTTP socket (read) timeout, in milliseconds. Default 5000 miliseconds.


_maxRedirects

private int _maxRedirects
Maximum number of redirects to be followed for the HTTP calls. Defalut 10.


_maxBodySize

private int _maxBodySize
Maximum size in bytes to be retrieved for the response body. Default 100,000 bytes.


_requestHeaders

private java.util.Map _requestHeaders
Map with HTTP request headers to be used when placing the HTTP request.


_useCache

private boolean _useCache
If set to false, a new HTTP request will be placed even if a cached copy exists. This applies to the internal HttpCache, not the HTTP protocol cache-control mechanisms.

See Also:
HttpCache

_allowCircularRedirects

private boolean _allowCircularRedirects

_contentType

private java.lang.String _contentType
If HttpRequestOptions' content type matches a cached HttpResponse's content type, the cache copy is returned; otherwise a new HTTP request is placed.


_cacheTTLSeconds

private long _cacheTTLSeconds
If set to a positive value, then new HTTP request will be placed if the cache is older than that positive value (in seconds) This applies to the internal HttpCache, not the HTTP protocol cache-control mechanisms.

See Also:
HttpCache
Constructor Detail

HttpRequestOptions

public HttpRequestOptions()
Constructs a set of HTTP request options with the default values.


HttpRequestOptions

public HttpRequestOptions(HttpRequestOptions other)
Creates a new HttpRequestOptions object as a clone of the provided parameter.

Parameters:
other - HttpRequestOptions instance to be cloned.
Method Detail

getDefaultOptionsForDiscovery

public static HttpRequestOptions getDefaultOptionsForDiscovery()
Returns an HttpRequestOptions object suitable to use for HTTP requests to perform discovery.


getDefaultOptionsForOpCalls

public static HttpRequestOptions getDefaultOptionsForOpCalls()
Returns an HttpRequestOptions object suitable to use for HTTP requests to OP endpoints for the purpose of creating associations or verifying signatures.


getConnTimeout

public int getConnTimeout()
Gets the HTTP connect timeout, in milliseconds.


setConnTimeout

public void setConnTimeout(int connTimeout)
Sets the HTTP connect timeout, in milliseconds.


getSocketTimeout

public int getSocketTimeout()
Gets the HTTP socket (read) timeout, in milliseconds.


setSocketTimeout

public void setSocketTimeout(int socketTimeout)
Sets HTTP socket (read) timeout, in milliseconds.


getMaxRedirects

public int getMaxRedirects()
Gets the internal limit configured for the maximum number of redirects to be followed for the HTTP calls.


setMaxRedirects

public void setMaxRedirects(int maxRedirects)
Sets the maximum number of redirects to be followed for the HTTP calls.


getMaxBodySize

public int getMaxBodySize()
Gets configuration parameter for the maximum HTTP body size that will be downloaded.


setMaxBodySize

public void setMaxBodySize(int maxBodySize)
Sets the maximum HTTP body size that will be downloaded.


getRequestHeaders

public java.util.Map getRequestHeaders()
Gets the HTTP request headers that will be used when placing HTTP requests using the options in this object.


setRequestHeaders

public void setRequestHeaders(java.util.Map requestHeaders)
Sets the HTTP request headers that will be used when placing HTTP requests using the options in this object.


addRequestHeader

public void addRequestHeader(java.lang.String headerName,
                             java.lang.String headerValue)
Adds a new HTTP request header.


isUseCache

public boolean isUseCache()
Returns true if a cached copy can be used when placing HTTP requests using the options in this object. This applies to the internally implemented HTTP cache, NOT to the HTTP protocol cache-control.


setUseCache

public void setUseCache(boolean useCache)
Sets the flag for allowing cached copy to be used when placing HTTP requests using the options in this object. This applies to the internally implemented HTTP cache, NOT to the HTTP protocol cache-control.


getContentType

public java.lang.String getContentType()
Gets the required content-type for the HTTP response. If this option matches the content-type of a cached response, the cached copy is used; otherwise a new HTTP request is made.


setContentType

public void setContentType(java.lang.String contentType)
Sets the required content-type for the HTTP response. If this option matches the content-type of a cached response, the cached copy is used; otherwise a new HTTP request is made.


getAllowCircularRedirects

public boolean getAllowCircularRedirects()

setAllowCircularRedirects

public void setAllowCircularRedirects(boolean allow)

getCacheTTLSeconds

public long getCacheTTLSeconds()
Gets the TTL for the cached response in seconds


setCacheTTLSeconds

public void setCacheTTLSeconds(long ttl)
Sets the TTL for the cached response in seconds



Copyright 2006-2008 Sxip Identity Corporation