A few answers in-line below.

Disclaimer: I've ported some HttpClient 3.1 code to 4.0, but I haven't made heavy use of the full 4.0 functionality.

I am new to HTTPComponents Client but have been using HttpClient 3.1 very
extensively... So I am facing some migration work.

1. How do I measure the time it took to get a response in a multithreaded
scenario with a limited size of max total connections?

In 3.1 I had to hack this into a custom ProtocolSocketFactory. When the
socket is created I am rembering the time in a thread local scope.

Is that still the way to go?


2. I want to set a different user agent per request

In 3.1 I could set HostParams when executing the method. How does it work
now?

I believe you'd want to implement a RequestUserAgent class that sets up the user agent that you want.

Seems like you might be able to do the same thing via using an HttpContext, but Oleg would know best.

3. Setting a proxy per request

httpClient.execute(proxyHost, httpget, responseHandler);

Correct?

4. Disabling redirects

params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);

Correct?

5. Enabling my own retry handler (which I just need because of verbose
logging)

((DefaultHttpClient) this.httpClient).setHttpRequestRetryHandler(XXX);

Correct?

6. When using the ThreadSafeClientConnManager how can I monitor the number
of threads used or threads waiting?

Well, you can call getConnectionsInPool() to get the number of in-use connections, though I think that would include connections that are no longer active but haven't been released back.

"Threads waiting" would (I assume) mean the number of HTTP requests you've made where no free connection is available, and thus the request is hung in ClientConnectionRequest.getConnection() until it gets a connection to use, or it times out.

There must be some way to find this out, but it's not obvious from the APIs.

I guess the ThreadSafeClientConnManager is the replacement of the
MultiThreadedHttpConnectionManager?

Yes, I believe so. Or at least that's what I've changed my 3.1 code to use with 4.0.

-- Ken
--
Ken Krugler
+1 530-210-6378

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to