You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Eugeny N Dzhurinsky <bo...@redwerk.com> on 2007/04/26 15:56:46 UTC

Unable to parse header : HTTP/1.1 200 OK

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


Re: Unable to parse header : HTTP/1.1 200 OK

Posted by Roland Weber <os...@dubioso.net>.
Hello Eugeny,

> So is there some kind of a non-intrusive workaround for resolving such errors
> in HttpClient?

Not in 3.x. HttpCore, the base for HttpClient 4.0, is more
componentized and would allow you to plug in a different parser.
In 3.x, you can only extend the HttpMethod implementations
and override readResponseHeader(...) to call a different
parser implementation. The parser would have to be a
copy-and-edit clone of the HttpParser class. Unfortunately,
the HttpParser class is all static. There is no way we can
change that at this point in the 3.1 release cycle. Unless
volunteers come swarming to us, there will not be a 3.2
release either.

hope that helps,
  Roland


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


Re: Unable to parse header : HTTP/1.1 200 OK

Posted by sebb <se...@gmail.com>.
On 28/04/07, Eugeny N Dzhurinsky <bo...@redwerk.com> wrote:
> On Thu, Apr 26, 2007 at 04:56:46PM +0300, Eugeny N Dzhurinsky wrote:
> > Hello!
> >
> > 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

The server is returning

HTTP/1.1 302
Server: Microsoft-IIS/5.0
Date: ...
Location: http://www.archchemicals.com/Fed/BIO
HTTP/1.1 200 OK

This is not valid HTTP - the last line should not be present.

> > fine, we need to get some workaround. Could you please suggest something,
> > which will not lead us to modifying Httpclient sources?

Have you tried speaking to your server administrator?

In the meantime, why not try starting at:

http://www.archchemicals.com/Fed/BIO

which does not show the same problem?

> >
> > 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.
>
> So is there some kind of a non-intrusive workaround for resolving such errors
> in HttpClient?

See above ...

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


Re: Unable to parse header : HTTP/1.1 200 OK

Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Thu, Apr 26, 2007 at 04:56:46PM +0300, Eugeny N Dzhurinsky wrote:
> Hello!
> 
> 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.

So is there some kind of a non-intrusive workaround for resolving such errors
in HttpClient?

Thank you in advance.

-- 
Eugene N Dzhurinsky

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