<div dir="ltr">@Maxim,<div>Sorry did not see your response. Looks like my email settings were incorrect and I was not receiving the emails.</div><div><br></div><div>I just want to discard the post body and respond with a custom status code and message. In my code,</div><div>I call <span style="font-family:monospace,monospace">ngx_http_discard_request_body </span>before I send the header i.e. the response. </div><div><br></div><div>Dk.</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 5, 2018 at 5:44 PM Dk Jack <<a href="mailto:dnj0496@gmail.com">dnj0496@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div>I have an nginx module. The purpose of my module is to inspect every request and make a binary decision (i.e drop or allow). When dropping, I am sending a custom status code and response message. I've setup my module handler to be called in the NGX_HTTP_REWRITE_PHASE. Things seem to be working fine for the most part except for a small issue.</div><div><br></div><div>I am seeing 'header already sent' messages in the nginx error.log. In my handler, I create a context for my module and attach it request using the ngx_http_set_ctx call. I am using the context to store some info and also to prevent my module from processing the same request multiple times. My module processes the request only once.</div><div><br></div><div>I get the 'header already sent' message only for a fraction of the requests. The messages seem to be generated only for requests that I allowed in my module. In my module handler, I return an NGX_DECLINED return code when I allow a request. The message is not generated for every allowed request but only for some of the allowed requests. When the error is generated it is always for POST request and not all POST requests cause this error message to be logged. </div><div><br></div><div>Could someone explain what could be going on here or where I should look at next to debug this further? Any pointers are appreciated. Thanks.</div><div><br></div><div>Dk.</div><div><br></div></div>
</blockquote></div>