Return-Path: Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: (qmail 49894 invoked from network); 25 Nov 2008 13:46:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Nov 2008 13:46:33 -0000 Received: (qmail 54810 invoked by uid 500); 25 Nov 2008 13:46:43 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 54784 invoked by uid 500); 25 Nov 2008 13:46:42 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 54773 invoked by uid 99); 25 Nov 2008 13:46:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Nov 2008 05:46:42 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [217.150.250.44] (HELO ok2consulting.nine.ch) (217.150.250.44) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Nov 2008 13:45:16 +0000 Received: by ok2consulting.nine.ch (Postfix, from userid 1002) id 3425919854F; Tue, 25 Nov 2008 14:46:00 +0100 (CET) Received: from [10.14.83.14] (unknown [213.55.131.1]) by ok2consulting.nine.ch (Postfix) with ESMTP id 4C342198545 for ; Tue, 25 Nov 2008 14:45:58 +0100 (CET) Subject: RE: Reverse Proxy Example From: Oleg Kalnichevski To: HttpClient User Discussion In-Reply-To: <419453E53580FC4594E09D41E0D3D5920189AADB@denzel.triggersoft.local> References: <1227607893.22573.27.camel@ubuntu> <419453E53580FC4594E09D41E0D3D5920189AADB@denzel.triggersoft.local> Content-Type: text/plain Date: Tue, 25 Nov 2008 14:20:02 +0100 Message-Id: <1227619202.22573.36.camel@ubuntu> Mime-Version: 1.0 X-Mailer: Evolution 2.24.1 Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on ok2consulting.nine.ch X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.3 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