<div dir="ltr">Thank you. Will looking it and get back. Since I need to inspect, I'll follow your suggestion<div>and see if I can use the body filter option.</div><div><br></div><div>regards,</div><div>Dk</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 8, 2018 at 11:34 AM Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<br>
On Tue, Aug 07, 2018 at 10:46:08PM -0700, Dk Jack wrote:<br>
<br>
> Haven't received any response to inquiry. Would appreciate it if someone<br>
> can comment.<br>
> <br>
> > In my module, I'd like to look into the post body to decide if the request<br>
> > should be allowed to proceed to origin server or not. Based on the examples<br>
> > I could find I've coded this in my module. After some trial and error it<br>
> > seems to be working. I am not sure if my implementation is 100% correct. I<br>
> > would appreciate it if someone can go over my code below and let me know if<br>
> > my implementation is correct. Especially, the body_complete_handler. Thanks.<br>
<br>
You may want to read general request body reading guidelines here:<br>
<br>
<a href="http://nginx.org/en/docs/dev/development_guide.html#http_request_body" rel="noreferrer" target="_blank">http://nginx.org/en/docs/dev/development_guide.html#http_request_body</a><br>
<br>
Your code suggests you've never seen these guidelines, so consider <br>
re-writing it after reading the above link.<br>
<br>
Note that the above guidelines cover content phase handling. In <br>
other request processing phases reqding the request body might be <br>
tricky and will require additional handling (if at all possible). <br>
In particular, you'll have to restore request phases processing <br>
after the call, and you might have to call <br>
ngx_http_finalize_request() yourself. Consider looking into <br>
src/http/modules/ngx_http_mirror_module.c for an example. Note <br>
well that required handling might depend on the exact request <br>
processing phase you are trying to use.<br>
<br>
Note well that if you are trying to inspec the request body, <br>
writing a request body filter might be a better solution. See <br>
here for a trivial example:<br>
<br>
<a href="http://mdounin.ru/hg/ngx_http_catch_body_filter_module/file/tip/ngx_http_catch_body_filter_module.c" rel="noreferrer" target="_blank">http://mdounin.ru/hg/ngx_http_catch_body_filter_module/file/tip/ngx_http_catch_body_filter_module.c</a><br>
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/" rel="noreferrer" target="_blank">http://mdounin.ru/</a><br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</blockquote></div>