com.noelios.restlet.ext.httpclient
Class HttpClientHelper

java.lang.Object
  extended by org.restlet.util.Helper<T>
      extended by com.noelios.restlet.ConnectorHelper<Client>
          extended by com.noelios.restlet.ClientHelper
              extended by com.noelios.restlet.http.HttpClientHelper
                  extended by com.noelios.restlet.ext.httpclient.HttpClientHelper

public class HttpClientHelper
extends HttpClientHelper

HTTP client connector using the HttpMethodCall and Apache HTTP Client project. Note that the response must be fully read in all cases in order to surely release the underlying connection. Not doing so may cause future requests to block. Here is the list of parameters that are supported:

Parameter name Value type Default value Description
followRedirects boolean false If true, the protocol will automatically follow redirects. If false, the protocol will not automatically follow redirects.
maxConnectionsPerHost int 2 (uses HttpClient's default) The maximum number of connections that will be created for any particular host.
maxTotalConnections int 20 (uses HttpClient's default) The maximum number of active connections.
connectionManagerTimeout int 0 The timeout in milliseconds used when retrieving an HTTP connection from the HTTP connection manager.
stopIdleTimeout int 1000 The minimum idle time, in milliseconds, for connections to be closed when stopping the connector.
readTimeout int 0 Sets the read timeout to a specified timeout, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
retryHandler String null Class name of the retry handler to use instead of HTTP Client default behavior. The given class name must implement the org.apache.commons.httpclient.HttpMethodRetryHandler interface and have a default constructor
tcpNoDelay boolean false Indicate if Nagle's TCP_NODELAY algorithm should be used.

Author:
Jerome Louvel
See Also:
Apache HTTP Client tutorial, Networking Features

Constructor Summary
HttpClientHelper(Client client)
          Constructor.
 
Method Summary
 HttpClientCall create(Request request)
          Creates a low-level HTTP client call from a high-level uniform call.
 int getConnectionManagerTimeout()
          Returns the timeout in milliseconds used when retrieving an HTTP connection from the HTTP connection manager.
 HttpClient getHttpClient()
           
 int getMaxConnectionsPerHost()
          Returns the maximum number of connections that will be created for any particular host.
 int getMaxTotalConnections()
          Returns the maximum number of active connections.
 int getReadTimeout()
          Returns the read timeout value.
 java.lang.String getRetryHandler()
          Returns the class name of the retry handler to use instead of HTTP Client default behavior.
 int getStopIdleTimeout()
          Returns the minimum idle time, in milliseconds, for connections to be closed when stopping the connector.
 boolean getTcpNoDelay()
          Indicates if the protocol will use Nagle's algorithm
 boolean isFollowRedirects()
          Indicates if the protocol will automatically follow redirects.
 void start()
           
 void stop()
           
 
Methods inherited from class com.noelios.restlet.http.HttpClientHelper
getConverter, handle, setConverter
 
Methods inherited from class com.noelios.restlet.ClientHelper
getConnectTimeout
 
Methods inherited from class com.noelios.restlet.ConnectorHelper
getProtocols, update
 
Methods inherited from class org.restlet.util.Helper
getAttributes, getContext, getHelped, getHelpedParameters, getLogger, setHelped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpClientHelper

public HttpClientHelper(Client client)
Constructor.

Parameters:
client - The client to help.
Method Detail

create

public HttpClientCall create(Request request)
Creates a low-level HTTP client call from a high-level uniform call.

Specified by:
create in class HttpClientHelper
Parameters:
request - The high-level request.
Returns:
A low-level HTTP client call.

getConnectionManagerTimeout

public int getConnectionManagerTimeout()
Returns the timeout in milliseconds used when retrieving an HTTP connection from the HTTP connection manager.

Returns:
The timeout in milliseconds used when retrieving an HTTP connection from the HTTP connection manager.

getHttpClient

public HttpClient getHttpClient()

getMaxConnectionsPerHost

public int getMaxConnectionsPerHost()
Returns the maximum number of connections that will be created for any particular host.

Returns:
The maximum number of connections that will be created for any particular host.

getMaxTotalConnections

public int getMaxTotalConnections()
Returns the maximum number of active connections.

Returns:
The maximum number of active connections.

getReadTimeout

public int getReadTimeout()
Returns the read timeout value. A timeout of zero is interpreted as an infinite timeout.

Returns:
The read timeout value.

getRetryHandler

public java.lang.String getRetryHandler()
Returns the class name of the retry handler to use instead of HTTP Client default behavior. The given class name must implement the org.apache.commons.httpclient.HttpMethodRetryHandler interface and have a default constructor.

Returns:
The class name of the retry handler.

getStopIdleTimeout

public int getStopIdleTimeout()
Returns the minimum idle time, in milliseconds, for connections to be closed when stopping the connector.

Returns:
The minimum idle time, in milliseconds, for connections to be closed when stopping the connector.

isFollowRedirects

public boolean isFollowRedirects()
Indicates if the protocol will automatically follow redirects.

Returns:
True if the protocol will automatically follow redirects.

getTcpNoDelay

public boolean getTcpNoDelay()
Indicates if the protocol will use Nagle's algorithm

Returns:
True to enable TCP_NODELAY, false to disable.
See Also:
Socket.setTcpNoDelay(boolean)

start

public void start()
           throws java.lang.Exception
Overrides:
start in class ConnectorHelper<Client>
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Overrides:
stop in class ConnectorHelper<Client>
Throws:
java.lang.Exception


Copyright © 2005-2008 Noelios Technologies.