tags:

views:

40

answers:

1

With ThreadSafeClientConnManager.requestConnection(HttpRoute route, Object state), what is the second item "state" supposed to be?

Ultimately I'm trying to ThreadSafeClientConnManager.releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) to release the connection. But I need the ManagedClientConnection, which is only available from the requestConnection method (via the returned ClientConnectionRequest)

A: 

I found a fairly decent example on how to use this class (see link at bottom). Turns out releaseConnection is not required, if you do a entity.consumeContent() on the response. Also make sure to pass in BasicHttpContext in to httpclient.execute.

Similar to this:

this.context = new BasicHttpContext();

httpclient.execute(httppost,context); String entityStr = EntityUtils.toString(response.getEntity()); response.getEntity().consumeContent();

http://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.0.x/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java

Still no idea what "state" is inside of requestConnection: ThreadSafeClientConnManager.requestConnection(HttpRoute route, Object state)