hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Lowe" <chris.l...@triggersoft.com>
Subject RE: Reverse Proxy Example
Date Tue, 25 Nov 2008 10:49:19 GMT
Morning Oleg,

Thanks for the insight. I was asked to look at this project despite
raising many of my own concerns!  As you say, creating a production
quality proxy is hard and scalability is one of the main concerns I
have.  Scalability is something I will be assessing, but right now I'm
just in an R&D phase and I'm investigating how the transformations can
be applied.

Since this is just a proof of concept, I was hoping to shoehorn some
example code using the reverse proxy example to try out my thoughts.  I
was looking at the ConnectingHandler.inputReady() method since this is
where data from the origin is read and passed on to the client.  Instead
of passing on the data, I gathered it up until the stream was complete
so I could run a then run a transform and then pass the result onto the
client.  Obviously this breaks the flow of the proxy and at the minute I
can't work out where I need to introduce hooks to make my logic work.



-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org] 
Sent: 25 November 2008 10:12
To: HttpClient User Discussion
Subject: Re: Reverse Proxy Example

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.


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.


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

View raw message