Thank you for the suggestion.  I did try that, but the order in which you
set f->r->status and call ap_pass_brigade doesn't seem to really make a
difference.

Basically what happens is that the browsers don't like the format of the
HTTP response packet.  They complain that there is "extra unexpected data
after the end of the response."  Oddly, when I use the Linux "wget" command,
it doesn't complain.  I may just write a handler hook specifically for
returning error codes.  Then when the filter modules has an error, it can
call ap_internal_redirect to a special page whose exclusive purpose is to be
captured by my error handler to return an HTTP status code.

Any other suggestions?

Thanks, -Eric


-----Original Message-----
From: Sorin Manolache [mailto:sor...@gmail.com] 
Sent: Thursday, October 16, 2014 12:59 PM
To: modules-dev@httpd.apache.org
Subject: Re: output filter needs to redirect to 503 error status

On 2014-10-16 15:36, Eric Johanson wrote:
> Hi,
> I have an output filter module which is working just fine, but I need 
> to add a feature so that when certain error conditions occur during 
> processing, the output filter hook function redirects the whole 
> request to a 503 error status (service unavailable).  Obviously for a 
> "handler" module this is trivial to accomplish, but it is not clear 
> how to do this in an output filter module.
>
> My output filter hooked function is defined as follows:
>         apr_status_t mts_out_filter(ap_filter_t *f,apr_bucket_brigade 
> *bb)
>
> I need this function to "do something" that causes the whole request 
> to be redirected such that the client sees a 503 error status with no 
> body/content.
>
> Things that I've tried so far:
> * Returning HTTP_SERVICE_UNAVAILABLE from the output filter function 
> after calling "ap_pass_brigade(f->next,bb)"
> * Setting f->r->status to HTTP_SERVICE_UNAVAILABLE after calling 
> "ap_pass_brigade(f->next,bb)"

Try setting f->r->status _before_ calling ap_pass_brigade.

If you get the 503 but you get the default 503 error response body that is
automatically set by apache then replace it by using the ErrorDocument
directive http://httpd.apache.org/docs/2.2/mod/core.html#errordocument (or
http://httpd.apache.org/docs/2.4/mod/core.html#errordocument).

Sorin

> * calling "ap_send_error_response(f->r,HTTP_SERVICE_UNAVAILABLE)"
>
> None of these really seem to behave properly.  I just want the client 
> to receive a 503 error status with no content body.  There must be a 
> way to achieve this behavior from within an output filter hook?
>
> Any advice is appreciated.
> Thanks, -Eric
>
>


Reply via email to