request body filter

Dk Jack dnj0496 at gmail.com
Mon Aug 9 18:48:35 UTC 2021


Hi,
In my module, I am inspecting the request body. My body filter init code is
shown below:

int
module_body_filter_init(ngx_conf_t *cf)
{
  ngx_http_next_body_filter = ngx_http_top_request_body_filter;
  ngx_http_top_request_body_filter = nginx_module_inspect_body_filter;

  return NGX_OK;
}

Even though I have the above initialization, I do not want to inspect the
body for all requests. I figured the body filter would be invoked in the
content phase. Hence, I registered a handler in the NGX_HTTP_ACCESS_PHASE
to create my module context and set the flag to inspect the request body.
This works in some cases but is inconsistent. It looks like my
inspect_body_filter function is getting called before my access handler
function in some cases. I've now moved my handler to POST_READ_PHASE to get
consistent results. Is this the correct way to solve this problem? Are
there any other ways to accomplish this or are there any pitfalls to this
approach. Any help is appreciated. Thanks.

Regards,
Dk.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20210809/b479dad7/attachment.htm>


More information about the nginx-devel mailing list