You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Jun Ma <mj...@gmail.com> on 2008/12/23 04:00:29 UTC

Losing data in HttpResponse

I'm implementing a proxy server and I am using the example code to send a
http request and receive a http response. but I found that I am losing data
in the HttpEntity from the response.getEntity(), here is the situation:

int len1 = EntityUtils.toByteArray(response.getEntity()).lenth();
int len2 = response.getEntity().getContentLength();

and I found that len1<len2 and when I send out the response.getEntity() to
the client, I am losing data since the data send out in the 2nd connection
to the client browser is of len1 length.

I am using exactly the same code as the example code of HttpComponent,
what's wrong with my situation?

Best Regards,

-- 
马俊
Jun Ma
Shanghai Jiao Tong University
Mobile: +86 13918713028
Email: mjnicky@gmail.com

Re: Losing data in HttpResponse

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2008-12-23 at 11:00 +0800, Jun Ma wrote:
> I'm implementing a proxy server and I am using the example code to send a
> http request and receive a http response. but I found that I am losing data
> in the HttpEntity from the response.getEntity(), here is the situation:
> 
> int len1 = EntityUtils.toByteArray(response.getEntity()).lenth();
> int len2 = response.getEntity().getContentLength();
> 
> and I found that len1<len2 and when I send out the response.getEntity() to
> the client, I am losing data since the data send out in the 2nd connection
> to the client browser is of len1 length.
> 
> I am using exactly the same code as the example code of HttpComponent,
> what's wrong with my situation?
> 

There are CGI scripts out there in the wild that can generate incorrect
Content-Length header value. You may want to use a packet sniffer /
traffic analyzer to see exactly what packets get sent across the wire. 

Oleg


> Best Regards,
> 


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