You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Asankha C. Perera" <as...@apache.org> on 2009/03/03 08:23:47 UTC

Echo service implementation - copying the request entity as the response

Hi All

I wanted to write an echo service, and found that I cannot copy the 
entity from the request as the response.. Also see : 
http://hc.apache.org/httpcomponents-client/httpclient/xref-test/org/apache/http/localserver/EchoHandler.html#95

For small requests copying it into a byte array would work, but I am 
suspecting there is another way?

thanks
asankha

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


Re: Echo service implementation - copying the request entity as the response

Posted by "Asankha C. Perera" <as...@apache.org>.
Hi Oleg
> The problem is that lots of HTTP agents out there (including HttpClient
> 3.x and HttpClient 4.0) can only handle request / response content
> streams sequentially. That is, they can start reading response content
> only after the request content has been fully written out.
>   
This explains the reason clearly..
> You can try passing the input stream of the incoming request entity to
> the outgoing response entity to avoid buffering the entire message
> content in memory, but I suspect this will not work with many HTTP
> agents out there, especially for larger content entities.
>   
many thanks
asankha

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


Re: Echo service implementation - copying the request entity as the response

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2009-03-03 at 12:53 +0530, Asankha C. Perera wrote:
> Hi All
> 
> I wanted to write an echo service, and found that I cannot copy the 
> entity from the request as the response.. Also see : 
> http://hc.apache.org/httpcomponents-client/httpclient/xref-test/org/apache/http/localserver/EchoHandler.html#95
> 
> For small requests copying it into a byte array would work, but I am 
> suspecting there is another way?
> 
> thanks
> asankha
> 

Hi Asankha

The problem is that lots of HTTP agents out there (including HttpClient
3.x and HttpClient 4.0) can only handle request / response content
streams sequentially. That is, they can start reading response content
only after the request content has been fully written out.

You can try passing the input stream of the incoming request entity to
the outgoing response entity to avoid buffering the entire message
content in memory, but I suspect this will not work with many HTTP
agents out there, especially for larger content entities.

Oleg

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


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