It can also be caused by more that one method using the same connection simultaneously. For example if two threads are using the same HttpClient instance with the SimpleHttpConnectionManager.

Mike

On Jun 11, 2004, at 4:27 AM, Kalnichevski, Oleg wrote:


Arturo,

"unable to find line starting with 'HTTP'" error is reported
(1) when response (status line, to be exact) sent by the server is malformed
(2) if HttpClient fails to correctly parse the status line sent by the server
(3) when the target server accepts connection but then fails to send any response back and simply drops the connection on unsuspecting HttpClient


The former two cases (1 and 2) are highly unlikely. They can easily be tested by examining the wire log produced by HttpClient. The former case (3) is by far more common and can occur when the target server is under heavy load. In this case the problem needs to be addressed on the server side and has nothing to do with HttpClient

Hope this helps

Oleg




-----Original Message----- From: Arturo Esquivel Sanchez [mailto:[EMAIL PROTECTED] Sent: Thursday, June 10, 2004 12:20 To: [EMAIL PROTECTED] Subject: HttpClient 2.0 problems





Hi,

The problem that im having is that sometimes i get the following error
when trying to connect to url, and then i change something in my code and
suddenly works fine, then i change something again and i get again the
same error (¿?), if a loop in my code in order to get a response other
than -1 it doesn´t work and i get a lots of the error.
This is the error:


[INFO] HttpMethodBase - -Recoverable exception caught when processing
request [WARN] HttpMethodBase - -Recoverable exception caught but
MethodRetryHandler.ret ryMethod() returned false, rethrowing exceptionA
recoverableexception occurred, retrying.
org.apache.commons.httpclient.Http RecoverableException: Error in parsing
the status line from the response: unabl e to find line starting with
"HTTP"
This is the code that im using:


      boolean retry=false;

      do{

statusCode = Procesa_Get_Url(url, client, config, state,
urlToConnect2, respHTML1);
if (statusCode != -1 && urlToConnect2.toString().trim() != "" &&
urlToConnect2.toString().trim().length() != 0){
retry=true; }
}while (retry==false);



private int Procesa_Get_Url(String urlProc, HttpClient clientProc, HostConfiguration configProc, HttpState stateProc, StringBuffer urlTC, StringBuffer respHTML) throws Exception { int statusCode=-1; String redirectLocation=null;

    clientProc.setTimeout(60*30*1000);
    clientProc.setHttpConnectionFactoryTimeout(60*30*1000);
    clientProc.setConnectionTimeout(60*30*1000);

    //try{

      //URI uri = new URI(urlProc.toCharArray());
      URI uri = new URI(urlProc.toCharArray());

      HttpMethod method = new GetMethod(uri.toString());

      String schema = uri.getScheme();

      if ((schema == null) || (schema.equals(""))){
            schema = "http";
      }

      Protocol protocol = Protocol.getProtocol(schema);

      String host = uri.getHost();
      int port = uri.getPort();

configProc.setHost(host,port,protocol);
configProc.setProxy(System.getProperty("http.proxyHost"),Integer.parseI nt(System.getProperty("http.proxyPort","80"))); stateProc.setProxyCredentials(null, null,
new UsernamePasswordCredentials(
System.getProperty("http.proxyUserName"),
System.getProperty("http.proxyPassword")));


      int attempt=0;
      boolean retry=false;

//do{
//for (attempt = 0; statusCode == -1 && attempt < 3; attempt++) {
try{
statusCode =
clientProc.executeMethod(configProc,method,stateProc); //if
(statusCode != -1){ // retry=true;
//}


        } catch (HttpRecoverableException e) {
                  method.recycle();
                  method.releaseConnection();
                  System.out.println("A recoverable exception occurred,
                  retrying.  " + e.getMessage());        } catch
                  (IOException e) {
                  System.err.println("Failed to download file.");
                  e.printStackTrace();
        }catch (Exception e) {
                  System.err.println("Errorsote.");
                  e.printStackTrace();
        }

      //}while (retry=false);

      if (statusCode == -1) {
        System.err.println("Numero de Intentos:" + attempt);
        System.err.println("Failed to recover from exception.");
      }

switch (statusCode){
case 200 : stateProc.setCookiePolicy(CookiePolicy.RFC2109);
Cookie[] cookies = stateProc.getCookies();
System.out.println("Present cookies: ");
for (int i = 0; i < cookies.length; i++) {
System.out.println(" - " +
cookies[i].toExternalForm()); }
urlTC.append(method.getURI().toString());
respHTML.append(method.getResponseBodyAsString());
break;


case 302 : stateProc.setCookiePolicy(CookiePolicy.RFC2109);
Cookie[] cookies2 = stateProc.getCookies();
System.out.println("Present cookies: ");
for (int i = 0; i < cookies2.length; i++) {
System.out.println(" - " +
cookies2[i].toExternalForm()); }
Header locationHeader =
method.getResponseHeader("location"); if
(locationHeader != null) {
redirectLocation =
locationHeader.getValue();
urlTC.append(redirectLocation);
}else{
urlTC.append(method.getURI().toString());
}
respHTML.append(method.getResponseBodyAsString());
break;



} method.recycle(); method.releaseConnection();

    //} catch (Exception e) {
    //    System.err.println("Failed to download file.");
    //    e.printStackTrace();
    //}
      return (statusCode);

  }


Thanks in advance for your help

Best Regards,
Arturo


Saludos, Arturo



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



*********************************************************************** ****************************
The information in this email is confidential and may be legally privileged. Access to this email by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system.
*********************************************************************** ****************************


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to