hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Apache httpAsyncClient works fine but throws a HTTP protocol exception: Not a valid protocol version
Date Fri, 29 Jun 2012 14:57:13 GMT
On Fri, 2012-06-29 at 09:16 +0300, Juhan Ernits wrote:
> Hi!
> 
> My setup: Apache HttpAsyncClient 4.0-beta1, dependencies as pulled by
> Maven, httpcore and httpcore-nio 4.2-beta1. JREs tried are current
> Oracle 1.7 and 1.6.
> 
> The simplest code that exhibits the problem is taken from
> AsyncClientHttpExchange.java:
> 
> public static void main(String[] args) throws Exception {
>     HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
>     httpclient.start();
>     try {
>         HttpGet request = new HttpGet("http://1.2.3.4/mygeturl?c=123&b=asdf");
>         Future<HttpResponse> future = httpclient.execute(request, null);
>         HttpResponse response = future.get();
>         System.out.println("Response: " + response.getStatusLine());
>         System.out.println("Shutting down");
>     } finally {
>         httpclient.shutdown();
>     }
>     System.out.println("Done");
> }
> 
> The sample code works fine on Apache.org website, but I need to access
> a page that does not contain any HTML, just 4 lines of plain text.

[DEBUG] wire - http-outgoing-0 << "Content-Length: 2

One cannot pack four lines of text into 2 bytes. The server sends back a
response with expected content of 2 bytes but apparently also sends some
trailing garbage that HttpAsyncClient interprets as a malformed, out of
sync response.

Oleg

>  I
> can get the information I need out of the response, i.e. the
> functionality I need works, but HttpAsyncClient throws a HTTP protocol
> exception for some reason. By examining the log I could detect that
> the problem occurs after the connection has been closed, but noting
> useful for me happens to the response at that stage. It boggles my
> mind why it happens in my case and not when accessing
> http://www.apache.org.
> 
> Question: Can you spot an obvious problem? If not, could this be a
> bug? I ran the code in the debugger and then the if condition leading
> to the offending line
> 
> org.apache.http.message.BasicLineParser.parseProtocolVersion(BasicLineParser.java:144)
> 
> could not be reached. Also, search did not yield anything enlightening.
> 
> Any hints appreciated,
> 
> Juhan Ernits
> 



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


Mime
View raw message