hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pankaj Arora" <PAro...@castiron.com>
Subject RE: FW: HttpClient authentication problem.
Date Fri, 18 May 2007 12:03:40 GMT
 

-----Original Message-----
From: Ortwin Gl├╝ck [mailto:odi@odi.ch] 
Sent: Friday, May 18, 2007 3:32 PM
To: HttpComponents Project
Subject: Re: FW: HttpClient authentication problem.

Pankaj,

When always closing the connections it makes no sense to pool them. The MultithreadedConnectionManager
is an overkill base class for this case, as it tries to do the exact oposite. Rather start
a conn mgr from scratch. Look at the SimpleHttpConnectionManager for sample code.

getConnectionWithTimeout can just create a new connection every time.

  public HttpConnection getConnectionWithTimeout(
          HostConfiguration hostConfiguration, long timeout) {

          HttpConnection httpConnection = new HttpConnection(hostConfiguration);
          httpConnection.setHttpConnectionManager(this);
          httpConnection.getParams().setDefaults(this.params);

          return httpConnection;
}

and releaseConnection() can just close it:

public void releaseConnection(HttpConnection conn) {
          if (conn != httpConnection) {
              throw new IllegalStateException("Unexpected release of an unknown connection.");
          }
          httpConnection.close();
}

This connection manager can be completely stateless and thus unsynchronized.

Ortwin

Pankaj Arora wrote:
> But how to close connection while they are returned to pool.
> I completely missed this part. What to overload here? 
> 
> May be something like this ::
> 
> Void releaseConnection(httpConnection connection){ connection.close(); 
> super.releaseConnection();
> 
> }
> Right?
> 
> Thanks,
> Pankaj Arora
--
[web]  http://www.odi.ch/
[blog] http://www.odi.ch/weblog/
[pgp]  key 0x81CF3416
        finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416

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


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


Mime
View raw message