Error handling from filter modules
Roman Arutyunyan
arut at nginx.com
Fri Oct 16 12:16:23 UTC 2015
Hello Steve,
> On 16 Oct 2015, at 04:36, Steven Hartland <steven.hartland at multiplay.co.uk> wrote:
>
> I'm making changes to a filter module
Header filter or body filter?
> and when it detected an error it
> returned NGX_ERROR however the response generated to the client isn't
> the expected 500 internal server error I would have expected given said
> return.
If you return NGX_ERROR from a filter handler, your request will be terminated
without sending any response to client. If you want a certain error code
to be sent to client, you can either return it from your header filter handler
directly or call ngx_http_finalize_request().
> So the question is do filters have to manually call
> ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); or is it
> expected that the upper layers should actually do the right thing and
> ensure the client doesn't get a bad response generated from the current
> state of r with no indication an error occurred?
Calling ngx_http_finalize_request() is the most correct way to return an
error from a filter handler. It does some additional cleanup, which can
make sense in certain cases.
--
Roman Arutyunyan
More information about the nginx-devel
mailing list