Welcome! Log In Create A New Profile

Advanced

Re: header already sent

Maxim Dounin
July 05, 2018 09:40PM
Hello!

On Thu, Jul 05, 2018 at 05:44:00PM -0700, Dk Jack wrote:

> Hi,
> 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.
>
> 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.
>
> 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.
>
> 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.

The "header already sent" alert indicate that there is a serious
bug somewhere, resulting in an attempt to send a response header
second time.

If you see it for POST requests handled by your module, it likely
means that you are handling requests with bodies incorrectly.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

header already sent

dnj0496 659 July 05, 2018 08:46PM

Re: header already sent

Maxim Dounin 336 July 05, 2018 09:40PM

Re: header already sent

dnj0496 489 July 06, 2018 01:06AM

Re: header already sent

dnj0496 470 July 06, 2018 05:34PM

Re: header already sent

Hung Nguyen 340 July 06, 2018 09:24PM

Re: header already sent

dnj0496 598 July 09, 2018 07:44PM

Re: header already sent

dnj0496 462 July 09, 2018 07:42PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 254
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready