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: Reverse Proxy Example
Date Tue, 25 Nov 2008 10:11:33 GMT
On Mon, 2008-11-24 at 18:48 +0000, Chris Lowe wrote:
> Hello all,
> 
> I'm looking at the NHttpReverseProxy class in the NIO examples.  This serves
> as great base for a project that I'm working on at the minute with one
> exception.  Obviously, the ConnectingHandler that responds to content from
> the target server streams the content straight through to the client.  In my
> case, there are occasions where I need to read the content in full and
> modify the response body before passing it on to the client.  I've been
> looking at this for while now and I can't see an easy way of achieving this,
> can anyone offer some pointers?
> 
> Cheers,
> 
> Chris.

Chris,

First off, be warned: writing an HTTP proxy is NOT an easy task. You
should evaluate your architecture options very carefully. Most of the
time production quality proxies cannot afford the luxury of buffering
the entire message content in memory. If you are are writing a highly
specialized proxy for a limited number of concurrent users and if
messages it is going to deal with are known to be bounded in length, you
can get away with reading the content into a in-memory buffer, running
some of data transformation against it and then sending buffered content
to the client as one chunk. HttpCore NIO provides SimpleInputBuffer and
SimpleOutputBuffer classes you can use for that end. However, if you
want your proxy to scale, it should be able to transform data while
streaming it. And this is quite hard to pull off right.

Oleg  


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