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: unable to get connection from MultiThreadedConnectionManager
Date Sun, 18 Dec 2005 12:27:30 GMT
Hi George,

if you use the IGNORE_COOKIES policy, you don't have
to create a new state for each request. Just create one
for each thread. This will still be an improvement over
using a shared state, where the threads will lock out
each other while looking for cookies that aren't there.
The HostConfiguration is at least not heavyweight:

http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HostConfiguration.java

DNS lookups should not happen until the connection to the
server is opened.

> Here is a new code fragment that leads to the execute
> call:
> 
> (url is the full string of the object I want to
> download, i.e. http://www.adobe.com/reader.zip)
> 
> HttpURL hurl = new HttpURL(url);
> HostConfiguration config= new HostConfiguration();
> config.setHost(hurl);
> int statusCode =
> httpClient.executeMethod(config,method,new
> HttpState());

You don't have to create the HostConfiguration object
yourself, unless you want to set request specific
things like a proxy. HttpClient will clone a default
host configuration and call setHost() if null is
passed as the host config. It's not in the JavaDocs,
but have a look at the code:

http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpClient.java

> I understand now what I seemed to be collecting too
> many cookies, although I am still confused why I was
> collecting any of them at all, given that I seet the
> cookie policy to ignore before executing every
> request, i.e.:
> method.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);

Strange indeed. Consider changing the default cookie spec:
http://jakarta.apache.org/commons/httpclient/cookies.html

Maybe there were some requests for which the cookie policy
was not set by mistake?

hope that helps,
  Roland

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


Mime
View raw message