hi,
i'm trying to use the httpclient.
so far it's a good thing but i've one problem. i set a connection timeout
(HttpClient) and nothing happens. even when i set my connection timeout to 1
msec. and try to connect www.apple.com/de (a really slow site [from germany]
) then the connection timeout don't will happen.
next, i copied the important source code:
...
import org.apache.commons.httpclient.HttpMultiClient;
import org.apache.commons.httpclient.HttpSharedState;
import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.HttpUrlMethod;
import org.apache.commons.httpclient.methods.UrlGetMethod;
import org.apache.commons.httpclient.HttpException;
public class Client implements LoggingI {
...
private HttpMultiClient client = null;
private HttpSharedState state = null;
private HttpConnection connection = null;
private HttpUrlMethod method = null;
client = new HttpMultiClient();
// hier kann mit cookies gearbeitet werden
state = new HttpSharedState();
connection = new HttpConnection( strURL , port );
...
try{
//wird sp�ter �berschrieben
connection.setSoTimeout( 5 );
}
catch(java.net.SocketException de ){
rcMessage = "Timout while receiving datas.";
rc = RC_ERR;
return;
}
catch(IllegalStateException ise ){
rcMessage = "You're already connected.";
rc = RC_ERR;
return;
}
try{
method = new UrlGetMethod( strURL );
}
catch( java.net.MalformedURLException mfurle ){
rcMessage = "url isn't malformed.";
rc = RC_ERR;
return;
}
client.setState( state );
client.setConnectionTimeout( 1 );
client.setRequestTimeout( 150 );
}
public int execute(){
try{
rc = client.executeMethod( method );
}
catch(IOException ioe){
// leifert unter anderm Fehlermeldung, wenn request
timeout erreicht wird.
rcMessage = "Receive no datas from url: [" +
ioe.getMessage() + "].";
rc = RC_OK;
return rc;
}
catch(HttpException httpe){
rcMessage = "HTTPEXc: [" + httpe.getMessage() + "].";
return rc;
}
catch ( NullPointerException npe ){
rcMessage = "Message: " + npe.getMessage();
return rc;
}
// liefert html-code zur�ck
// auch als inputstream m�glich, dies hier ist nur f�r
testzweck
strResponse = method.getResponseBodyAsString();
...
}
}
thanks for helping.
mfg
marco
--
QUALITY MANAGEMENT
VIRBUS AG
Neumarkt 9-19
04109 Leipzig
Fon +49 (341) 9797 446
Fax +49 (341) 9797 409
[EMAIL PROTECTED]
www.virbus.de
--------------
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>