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: Sending a large entity causes the client to close the connection
Date Sat, 05 Dec 2009 12:03:00 GMT
Malte Ried wrote:
> Hi!
> 
> I'm trying to write a simple server application. It must be able to
> serve a big entity (about 45kb) to the client, which is a JBoss
> Application Server in my case. Sending the entity results in a
> connection reset. I'm not sure why this happens. Maybe the client side
> input buffer is not big enough, so the client closes the connection.
> 
> This is what I use:
> 
> HttpResponse response = new BasicHttpResponse(statusLine);
> 
> //set the header with response.addHeader(...);
> 
> StringEntity entity = new StringEntity(data, encoding);
> response.setEntity(entity);
> 
> serverConnection.sendResponseHeader(response);
> serverConnection.sendResponseEntity(response);
> 
> If I use a very simple client app which just opens a socket and prints
> all received data to the console, everything looks right. I also sniffed
> the communication between the JBoss and another server which serves the
> same data as I would like to serve. This data is sent in many small
> chunks (<500 bytes). If I shorten the data to that size, everything
> works (beside the data which is missing, of course).
> 
> I also tried to use chunked transfer coding but since the
> ChunkedOutputStream.write does not split the data, nothing changes.
> 
> So, the main question is: How do I send a large entity in small chunks?
> Or did I miss something else?
> 

HttpCore can deal with content entities of unlimited length, much, much 
larger than 45kb

Frankly, I do not understand what it is exactly you are trying to do. 
Why do not you just use HttpService and let it deal with content chunking?

http://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.0.x/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java

Oleg

> Thanks in advance for every help / comment!
> 
> Best regards,
> 
> Malte
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


---------------------------------------------------------------------
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