hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kalnichevski, Oleg" <oleg.kalnichev...@bearingpoint.com>
Subject RE: unable to find line starting with "HTTP"
Date Wed, 02 Jun 2004 17:52:45 GMT
Juan,
Usually HttpClient reports 'unable to find line starting with "HTTP"' when the target server
drops the connection without returning any response. This can happen, for instance, if the
server is being under heavy load. 

(1) If you have access to the target server, examine the server logs to see why the connection
was dropped. Fixing the problem on the server side would be the best

(2) Another possible solution to this problem _may_ be to retry the request, provided that
the POST methods your code is supposed to execute are idempotent. If the server application,
however, has been designed in a way that it may receive a request, parse it, change the application
state (by committing some data to the data store, for instance) and then simply drop the connection
without giving any kind of response back to the client, you are in <strong>BIG</strong>
trouble, as simply retrying the same POST method case cause data inconsistency problems. So,
the best thing to do is to get in touch with the server guys and find out if it is safe to
retry POST methods.

Hope this clarifies things a little

Oleg



-----Original Message-----
From: Juan Pedro López Sáez [mailto:jpls@altiria.com]
Sent: Wednesday, June 02, 2004 17:18
To: commons-httpclient-dev@jakarta.apache.org
Subject: unable to find line starting with "HTTP"


Hi,

I've been searching in the archive list looking for something related to
my "unable to find line starting with HTTP". 

There are lots of comments about it, but they all seem to be unuseful
for me.

Currently I'm using 2.0-rc3 version. My HTTP client is very simple.
Below you can see everything I do. That code is executed everytime I
need to send new data to the HTTP server.

--------------------------------------

HttpClient client= new HttpClient();
client.setStrictMode(true);
client.setTimeout(120000); 
client.setConnectionTimeout(10000); 

PostMethod post = new PostMethod(currentURL);
post.setRequestContentLength(XMLRequest.length());
post.setRequestBody(XMLRequest);
post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
post.addRequestHeader("Connection", "close");

String response;

try{
httpStatus = client.executeMethod(post);
response = post.getResponseBodyAsString();
}
catch (HttpException e) {
log.fatal("IOException in client.executeMethod( post )",e);
throw e;
}
catch(IOException e){ 
log.fatal("IOException in client.executeMethod( post )",e);
throw e;
}
finally {
post.releaseConnection();
}

------------------------------------------------

I'm getting the exception in the HttpClient.excetuteMethod line. The
exception happens from time to time, is not quite common but I don't
know what to do with it.  

The exception stack trace is the following:

org.apache.commons.httpclient.HttpRecoverableException:
org.apache.commons.httpclient.HttpRecoverableException: Error in parsing
the status  line from the response: unable to find line starting with
"HTTP"
at
org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1965)
at
org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.java:2659)
at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1093)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:674)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:529)

I would apreciate any help.

Thank you very much

Juan Pedro López




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


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


Mime
View raw message