hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francois-Xavier Bonnet <francois-xavier.bon...@centraliens.net>
Subject Re: valid HTTP request
Date Tue, 23 Apr 2013 12:17:11 GMT
Hi,

You should fix the client that sends this request. An incorrect
content-length header value makes it impossible to reuse http connections
and can lead to locked connections and timeouts for example.

In your case, I think disabling connection keep-alive could be a quick fix
but this is not very good for performance.


2013/4/23 Nir Dweck <nird@vasco-de.com>

> Hi,
> I have a question which involves both the code and the validity of an HTTP
> message.
> I am using httpcore-4.2.3.
> I receive from a client an HTTP (HTTP/1.1) request with the following
> headers:
> Content-type: text/xml
> Host: some host
> User-agent: UA
> Connection: keep-alive
> Accept: text/xml
> Content-Length: 109
>
> The entity is a an xml of of length of 109 bytes.
> At the end of the xml there are two extra bytes with the value of 0x0d and
> 0xoa (/r/n), these bytes are the 110'th and 111'th bytes.
> In my code I call: *EntityUtils.toString(entity, "UTF-8");*
> at the end of the handling of the request my server returns 200-OK to the
> client.
> the problem is that after I finish handling the request, the connection is
> still open and I call *httpService.handleRequest(conn, context);*
> This call sees the two extra bytes and returns 400-Bad request to the
> sender.
> Now my question are:
>
>    1. As far as I know when the Content-Length header is present
>    it determines the length  of the entity body, so actually the message I
> get
>    is a bad message.
>    2. Is there something I can do in my code to make it accept this
>    message? Will calling *EntityUtils.consume(entity)* help?
>
> Thanks,
> Nir
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message