commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "otisg" <>
Subject Re: httpclient: timeout
Date Wed, 13 Mar 2002 14:23:15 GMT
I have tried this before. It did not work for me under IBM's 1.3.1 JVM
and Linux.

Get your own FREE email account at!

<-----Original Message----->

From: Mohammad M. Purbo
Sent: 3/13/2002 8:02:36 PM
Subject: httpclient: timeout

Hi All, i was just joining & have a question/suggestion.

i downloaded commons-httpclient source code sometimes ago (nightly
20020307) to try to use it in one of my project, in which i need to set
timeout for a connection.

i wrote something like:

import org.apache.commons.httpclient.*;
HttpConnectionManager httpconn = ........
HttpUrlMethod method = ......
int timeout = 60000;

HttpConnection connection = httpconn.getConnection(method.getUrl());
int status = method.execute(getState(),connection);

which of course wouldn't work because HttpConnectionManger.getConnection
not returning opened connection, and the connection wouldn't be opened
the execution of HttpMethodBase.execute.

now, i couldn't find any way to set the timeout so that it can be set to
HttpConnection once it's opened inside HttpMethodBase.execute (except by
overriding the execute method in my own Method-descendant class, which
is a
bit too much because it's almost as good as writing the whole

So I made a patch temporarily in HttpConnection:

1. add private member:
private int _timeout = -1;

2. update setSoTimeout():
public void setSoTimeout(int timeout) throws SocketException,
IllegalStateException {
_timeout = timeout;

3. update open(), and add the following lines just before _open = true;
if (_timeout > 0) {

Did i miss something?

Thank you,

M. Purbo

To unsubscribe, e-mail: 
For additional commands, e-mail: 

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message