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 13:20:02 GMT
On Tue, 2008-11-25 at 10:49 +0000, Chris Lowe wrote:
> 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.
> 

Chris,

There is no code sample, which you could just take as is without
modifications. You will have to tweak the reverse proxy example to meet
the specific requirements of the application you are developing or take
NHttpServer as a starting point and turn it into a reverse proxy.

Oleg

> Cheers,
> 
> Chris.
> 
> 
> 
> 
> -----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.
> 
> 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
> 
> 
> ---------------------------------------------------------------------
> 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