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