httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Vitale <cvit...@us.ibm.com>
Subject Re: Howto return apache status (error) page from output filter ?
Date Tue, 28 Aug 2007 17:05:46 GMT

Hello,

I've got some questions about Nick's comments on filters and errors. I
understand why setting an error status on an output filter is dicey. What
about content input filters?

Are handlers required to detect errors in inbound filters, pass them to
Apache,  and respect r->status?
Is this more of a best practice that some people choose not to follow?
Are handlers encouraged to decide for themselves what is correct as
handlers can be so varied?

When I first started looking at filters I thought that the handlers would
respect inbound filter errors, stop processing, and hand an error code to
Apache. If mod_deflate is given a compressed upload and detects an error
then the entire request should be considered to be as dangerous as
radioactive waste. Throwing away the bad buckets and proceeding with the
request shouldn't be an option.

In practice, I'm starting to think that handlers do whatever they wish.
This makes things messy because handlers lack uniformity. A hacked upload
would return a 400 error with handler X and a 200  with handler Y.

Are there hard and fast rules for real world handlers?

vitale



                                                                                         
                                        
  From:       Nick Kew <nick@webthing.com>                                         
                                              
                                                                                         
                                        
  To:         modules-dev@httpd.apache.org                                               
                                        
                                                                                         
                                        
  Date:       08/27/2007 11:37 AM                                                        
                                        
                                                                                         
                                        
  Subject:    Re: Howto return apache status (error) page from ouptut filter ?           
                                        
                                                                                         
                                        





On Mon, 27 Aug 2007 16:05:09 +0200
Holger Moser <holger.moser@artofdefence.com> wrote:

> Hi,
>
> To keep a long storry short: i have an apache module that sets an
> ouput-filter (besides other things), does validate/mangle the data. so
> far so good. my question now is how can i get apache to generate an
> errorpage by itself if my module wants it to return with e.g. 404
> errcode (just returning the status code as outputfilter returnvalue
> doesnt work.. i tried that because someone mentioned it could work).
> currently i generate my own errorpage with the statuscode as
> workaround (but this is only a temp solution). so whats the correct
> way doing that?

A filter is the wrong place to set an error status.  Your filter
function is a callback, and in general will be called after the
response status has already been sent to the client.

The exception to that is in the first call to your filter function.
But if you're relying on that, it points to a problem in your
design.  Though in that case, you can still set r->status and
return APR_EGENERAL, and hope the content generator (which is
in control) does what you want.

--
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message