Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 68AE94581 for ; Wed, 15 Jun 2011 17:14:35 +0000 (UTC) Received: (qmail 97898 invoked by uid 500); 15 Jun 2011 17:14:35 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 97860 invoked by uid 500); 15 Jun 2011 17:14:34 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 97852 invoked by uid 99); 15 Jun 2011 17:14:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jun 2011 17:14:34 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of support@bettercgi.com designates 216.17.105.202 as permitted sender) Received: from [216.17.105.202] (HELO ps536.phatservers.com) (216.17.105.202) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jun 2011 17:14:27 +0000 Received: from r74-192-17-33.bcstcmta01.clsttx.tl.dh.suddenlink.net ([74.192.17.33] helo=localhost) by ps536.phatservers.com with esmtpa (Exim 4.66) (envelope-from ) id 1QWtfJ-0003Tp-28 for modules-dev@httpd.apache.org; Wed, 15 Jun 2011 10:14:05 -0700 Date: Wed, 15 Jun 2011 12:14:03 -0500 From: Ray Morris To: modules-dev@httpd.apache.org Subject: Re: Kill a request nicely Message-ID: <20110615121403.284b1ac5@bettercgi.com> In-Reply-To: References: <20110614231229.5274b84e@baldur> Organization: RMEE Inc X-Mailer: Claws Mail 3.7.8 (GTK+ 2.18.9; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org > > > I am writing an output filter module that will under some > > > circumstances want to send back an HTTP Error Code and kill > > > the request without sending back the content. ... > > The only way you can affect a response status is to return an > > error to your caller before passing anything down the chain. ... > So what option do I have? Cache all the buckets of the request without > passing anything down the chain so I can make the decision about what > to do? Obviously reading in the whole request is asking for trouble, mainly a memory bomb when the output you're "filtering" i slarger than you planned. What to do, I think, depends on what your module is trying to accomplish. What sort of error might happen in the middle of the content? First, consider whether or not your module is actually a filter. That is, does it transform the content from one representation to another, or is it actually something else, like an access, authorization or authentication module? At least in my mind, a filter is like mod_deflate or chunking - something that changes how the content is represented, but doesn't fundamentally change the content itself. If it sometimes changes 200 OK content into some error, it may not be an output filter. Secondly, can the error be detected earlier with some proactive checking? -- Ray Morris support@bettercgi.com Strongbox - The next generation in site security: http://www.bettercgi.com/strongbox/ Throttlebox - Intelligent Bandwidth Control http://www.bettercgi.com/throttlebox/ Strongbox / Throttlebox affiliate program: http://www.bettercgi.com/affiliates/user/register.php On Tue, 14 Jun 2011 21:08:28 -0500 Jason Funk wrote: > So what option do I have? Cache all the buckets of the request without > passing anything down the chain so I can make the decision about what > to do? Would that even require caching them in the filter's ctx? > > Do I have any other choice? > > On Tue, Jun 14, 2011 at 5:12 PM, Nick Kew wrote: > > > On Tue, 14 Jun 2011 16:31:22 -0500 > > Jason Funk wrote: > > > > > I am writing an output filter module that will under some > > > circumstances > > want > > > to send back an HTTP Error Code and kill the request without > > > sending back the content. > > > > You can't set an HTTP response code when one has already been sent > > down the wire to the client. It's in the nature of an output > > filter that the work is done in a callback, which (in general) > > only happens after the response has started, and too late to > > set a response code or headers. Thus the filter callback API > > isn't designed to set a status like a processing hook can > > when it determines the outcome of a request. > > > > The only way you can affect a response status is to return an > > error to your caller before passing anything down the chain. > > > > > > -- > > Nick Kew > > > > Available for work, contract or permanent. > > http://www.webthing.com/~nick/cv.html > >