hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <http-as...@dubioso.net>
Subject Re: HttpClient & custom host names resolving
Date Tue, 30 Jan 2007 17:35:37 GMT
Hello Erwan,

> it is not exactly attached to the request, but a context which would
> be attached to the HttpClient. Basically i'd like to be able to create
> several HttpClient instances, each using
> different DNS server.

Ok, that sounds very much different from "choosing DNS server by URL
or any other attribute of the request" :-)

> So i have built my own ProtocolSocketFactory which is called by my own
> HttpConnection and HttpConnectionManager

I see you have put a lot of effort into this. I hope it wasn't
only to deal with the "different DNS" requirement.

> My understanding with Protocol is that there is only one Protocol
> instance in the VM for a given protocol ("http", "https", etc ...),
> and that doesn't suits me because i need to be able to use different
> ProtocolSocketFactory instances for the same Protocol. Am i utterly
> wrong in that assumption ?

Not utterly, but somehow. You can create as many instances of a
protocol as you want. There is currently only one static map to
register the protocol in, but you can use alias names:

Protocol.register("http1", new Protocol("http",...));
Protocol.register("http2", new Protocol("http",...));

For HttpClient 4, we're removing the single static map in favor
of a map that can be set for each HttpClient instance. Maybe that
would be a solution for you, too.

> I'm not very familiar with ThreadLocal so don't understand your
> solution. It seems very elegant and would like you to elaborate ;-)

ThreadLocal is never really elegant, but since the dirtyness is
encapsulated in a standard class, it can appear that way :-)
I don't know what I should explain that the JavaDocs will not:

> Again, correct me if i'm wrong but Protocol.registerProtocol() doesn't
> allow to register more than one instance for the whole VM, while I'm
> running several HttpClient instances concurrently.

Yes. The point is that the single instance can get access to
thread-specific data. So you can have a "dispatcher" protocol
instance that calls a thread-specific protocol instance. Or
else you use the protocol alias trick above to specify one of
several protocol instances.

hope that helps,

To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

View raw message