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: HTTP streaming using ProducingNHttpEntity
Date Sat, 28 May 2011 16:24:46 GMT
On Fri, 2011-05-27 at 17:22 +0200, dvrslype wrote:
> Hello,
> I'm writing a proxy server for large media files (that are shared with 
> Windows Media Player through DLNA).
> In my first ignorant attempt, i just copy pasted the http client and 
> server example together. On a request on my http server, it requests the 
> file at the WMP side. Only when that is finished, it sends the response 
> on the first request. I would like to enhance this to streaming.
> Here I read something about streaming with ProducingNHttpEntity.
> http://marc.info/?l=httpclient-commons-dev&m=122813780829230&w=2
> I read the entire tutorial, but couldn't figure out how to achieve this.
> This is an attempt to use ProducingNHttpEntity. It should be generating 
> a chunk of textual content every second, but that didn't work out.
> http://pastebin.com/BQBh2P69
> Can somebody point me in the right direction, of give me a good example 
> using ProducingNHttpEntity.
> regards,
> dvrslype

Building a fully streaming HTTP proxy is not an easy task. In order to
support content streaming the proxy process would need to maintain a
shared object with synchronized access accessible to both incoming
message handler (browser -> proxy) and outgoing message handler (proxy
-> target server). Both handlers would need to be able to coordinate
their activities and fill up and flush shared input and output buffers
as content becomes available.

One can certainly do that with ProducingNHttpEntity /
ConsumingNHttpEntity API provided by HttpCore, but I would also
recommend using HttpAsyncClient [1] as it makes client side HTTP
handling somewhat easier. For instance you would be relieved from having
to write your one connection pool manager for outgoing connections.

I'll see if I can share with the project a sample reverse proxy based on
HttpCore and HttpAsyncClient


[1] http://hc.apache.org/httpcomponents-asyncclient-dev/index.html  

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

View raw message