commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fredrik Lindgren <fredrik.lindg...@chello.se>
Subject Re: httpclient timeout
Date Sat, 01 Dec 2001 21:30:02 GMT
+1 for adding timeouts

Currently HttpClient does not seem to have a way to set the timeout. 
(I'm just a user and I might be wrong)

However it should be easy to implement since the HttpConnection uses 
Java.net.Socket inside.

The following snippet should do the trick if added to HttpConnection

/**
  * Set my {@link Socket}'s timeout, via
  * {@link Socket#setSoTimeout}.
  * @throws SocketException - if there is an error in the underlying
  * protocol, such as a TCP error.
  * @throws IllegalStateException if I am not connected
  */
public void setSoTimeout(int timeout)
		throws SocketException, IllegalStateException {
	log.debug("HttpConnection.setSoTimeout()");
	assertOpen();
	_socket.setSoTimeout(int timeout);
} 
	

Please correct me if I'm wrong, or respond with a good argument why this 
would be a bad way to do it.

An alternative to changing the public API would be to add a protected 
method getSocket() so that extending HttpConnection to support timeouts 
would be possible.

/Fredrik Lindgren	


otisg@ivillage.com wrote:

> Hello,
> 
> I would imagine that this is a very frequently asked question, but I could not find any
mention of it in the list archives.
> 
> Does Commons' httpclient have a way of setting a connection timeout?
> I looked at the API javadocs and could not find a way to do it.
> 
> If there is no way to do it does httpclient block when it encounters super slow connections?
> 
> Thanks,
> Otis
> 
> _________________________________________________________________
> iVillage.com: Solutions for Your Life 
> Check out the most exciting women's community on the Web   
> http://www.ivillage.com
> 
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>
> 
> 



--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message