You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by ro...@bellsouth.net on 2003/06/07 00:03:07 UTC
HTTP Exception
I have an app that is pulling from about 6 different sites, all work but one
site. I get the following messages:
The Console:
Jun 6, 2003 3:14:34 PM org.apache.commons.httpclient.HttpMethodBase
processRequest INFO: Recoverable exception caught when processing request
Jun 6, 2003 3:14:34 PM org.apache.commons.httpclient.HttpMethodBase
processRequest WARNING: Recoverable exception caught but
MethodRetryHandler.retryMethod() returned false, rethrowing exception
The exception:
Fri Jun 06 15:14:34 EDT
2003,org.apache.commons.httpclient.HttpRecoverableException: Error in
parsing the status line from the response: unable to find line starting with
"HTTP"
The Results:
Unexpected failure
The Code:
String url = "/jobseeker/jobs/jobfindall.asp";
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost("www.careerbuilder.com",80,"http");
HttpState httpstate = new HttpState();
client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);
Header cjheader = new Header();
String responseBody = null;
org.apache.commons.httpclient.Cookie[] cookies = null;
// jobServlet.tools.writeLog("Initialized CJ Vars.");
client.setConnectionTimeout(30000); //30 seconds
Header[] requestHeaders = new Header[15];
GetMethod get = new GetMethod(url);
get.setFollowRedirects(true);
get.setStrictMode(false);
get.setHttp11(false);
client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);
try{
// jobServlet.tools.writeLog("Executing CB Get");
int iResultCode = client.executeMethod(get);
// jobServlet.tools.writeLog("Get Result Code: " + iResultCode);
httpstate = client.getState();
responseBody = get.getResponseBodyAsString();
// jobServlet.tools.writeLog("Getting Cookies and Headers");
cookies = httpstate.getCookies();
requestHeaders = get.getRequestHeaders();
}
catch (HttpException he) {
jobServlet.tools.writeLog("Http error connecting to '" + url +
"'");
jobServlet.tools.writeLog(he.getMessage());
}
catch (IOException ioe){
jobServlet.tools.writeLog("Unable to connect to '" + url + "'");
}
catch (NullPointerException np) {
jobServlet.tools.writeLog("Null Status: " + np.getMessage());
}
Any ideas? I'm using the Beta 2 release. It looks similar to bug 19635,
but it's a different GET so I'm not sure.
Ross Rankin
Re: HTTP Exception
Posted by Michael Becke <be...@u.washington.edu>.
Ross,
It looks like you've found a problem where HttpClient does not robustly
handle duplicate header values. In general the server should not be
sending two "Connection: close" headers. Still, HttpClient should be
able to handle it. I've attached a patch to fix this to following bug:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20569
If you can, please apply this patch and verify that it fixes the
problem.
Thanks,
Mike
On Friday, June 6, 2003, at 06:03 PM, <ro...@bellsouth.net> wrote:
> I have an app that is pulling from about 6 different sites, all work
> but one
> site. I get the following messages:
>
> The Console:
>
> Jun 6, 2003 3:14:34 PM org.apache.commons.httpclient.HttpMethodBase
> processRequest INFO: Recoverable exception caught when processing
> request
>
> Jun 6, 2003 3:14:34 PM org.apache.commons.httpclient.HttpMethodBase
> processRequest WARNING: Recoverable exception caught but
> MethodRetryHandler.retryMethod() returned false, rethrowing exception
>
>
>
> The exception:
>
> Fri Jun 06 15:14:34 EDT
> 2003,org.apache.commons.httpclient.HttpRecoverableException: Error in
> parsing the status line from the response: unable to find line
> starting with
> "HTTP"
>
>
>
> The Results:
>
> Unexpected failure
>
>
>
> The Code:
>
> String url = "/jobseeker/jobs/jobfindall.asp";
>
> HttpClient client = new HttpClient();
>
>
> client.getHostConfiguration().setHost("www.careerbuilder.com",80,"http"
> );
>
> HttpState httpstate = new HttpState();
>
> client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);
>
> Header cjheader = new Header();
>
> String responseBody = null;
>
> org.apache.commons.httpclient.Cookie[] cookies = null;
>
> // jobServlet.tools.writeLog("Initialized CJ Vars.");
>
>
>
> client.setConnectionTimeout(30000); //30 seconds
>
> Header[] requestHeaders = new Header[15];
>
> GetMethod get = new GetMethod(url);
>
> get.setFollowRedirects(true);
>
> get.setStrictMode(false);
>
> get.setHttp11(false);
>
> client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);
>
> try{
>
> // jobServlet.tools.writeLog("Executing CB Get");
>
> int iResultCode = client.executeMethod(get);
>
> // jobServlet.tools.writeLog("Get Result Code: " +
> iResultCode);
>
> httpstate = client.getState();
>
> responseBody = get.getResponseBodyAsString();
>
> // jobServlet.tools.writeLog("Getting Cookies and Headers");
>
> cookies = httpstate.getCookies();
>
> requestHeaders = get.getRequestHeaders();
>
> }
>
> catch (HttpException he) {
>
> jobServlet.tools.writeLog("Http error connecting to '" +
> url +
> "'");
>
> jobServlet.tools.writeLog(he.getMessage());
>
> }
>
> catch (IOException ioe){
>
> jobServlet.tools.writeLog("Unable to connect to '" + url +
> "'");
>
> }
>
> catch (NullPointerException np) {
>
> jobServlet.tools.writeLog("Null Status: " +
> np.getMessage());
>
> }
>
>
>
> Any ideas? I'm using the Beta 2 release. It looks similar to bug
> 19635,
> but it's a different GET so I'm not sure.
>
>
>
> Ross Rankin
>
>
>
>
>