hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugeny N Dzhurinsky <b...@redwerk.com>
Subject Unable to parse header : HTTP/1.1 200 OK
Date Thu, 26 Apr 2007 13:56:46 GMT
Hello!

I'm facing strange issue:

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import junit.framework.TestCase;

/**
 * Tests HttpClient
 */
public class TestHttpclient extends TestCase {

    public void testHttpClient() throws Exception {
        BasicConfigurator.configure();
        Logger.getRootLogger().setLevel(Level.ERROR);
        Logger.getLogger("httpclient.wire.header").setLevel(Level.DEBUG);
        HttpClient client = new HttpClient();
        HttpMethod method = new GetMethod("http://www.archbiocides.com/");
        method.setFollowRedirects(true);
        client.executeMethod(method);
        assertEquals(HttpStatus.SC_OK, method.getStatusCode());
    }
}

0 [main] DEBUG httpclient.wire.header  - >> "GET / HTTP/1.1[\r][\n]"
36 [main] DEBUG httpclient.wire.header  - >> "User-Agent: Jakarta Commons-HttpClient/3.1-rc1[\r][\n]"
37 [main] DEBUG httpclient.wire.header  - >> "Host: www.archbiocides.com[\r][\n]"
37 [main] DEBUG httpclient.wire.header  - >> "[\r][\n]"
313 [main] DEBUG httpclient.wire.header  - << "HTTP/1.1 302[\r][\n]"

org.apache.commons.httpclient.ProtocolException: Unable to parse header: HTTP/1.1 200 OK
at org.apache.commons.httpclient.HttpParser.parseHeaders(HttpParser.java:192)
at org.apache.commons.httpclient.HttpMethodBase.readResponseHeaders(HttpMethodBase.java:1927)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1729)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1090)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at TestHttpclient.testHttpClient(TestHttpclient.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

I understand something might be wrong for the website and the protocol might
be corrupted, but as soon as mozilla/IE browsers are displaying the website
fine, we need to get some workaround. Could you please suggest something,
which will not lead us to modifying Httpclient sources?

I've read about error handling for protocol errors, but I just found it is
possible to force HttpClient to retry this url again and again. In such case
as described above this will lead to a infinite loop unless we will still
handle this error (which isn't an error in our case).

We are using HttpClient 3.01 and 3.1-RC1, with same results.

-- 
Eugene N Dzhurinsky

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


Mime
View raw message