Welcome! Log In Create A New Profile

Advanced

terminate a connection after sending headers

September 01, 2014 05:25PM
Hi all,

In the module I'm developing, I have the possibility of encountering an error after the response headers were already sent. As the headers were already sent (with status 200) the only way for me to signal the error to the client would be to close the connection. I tried calling ngx_http_finalize_request with both NGX_ERROR and NGX_HTTP_CLOSE and the connection is not closed.
After debugging it, I found it has to do with the 'if (mr->write_event_handler)' in ngx_http_terminate_request. I'm not sure what is the purpose of this if, but in my case write_event_handler has the value ngx_http_request_empty_handler, so the if evaluates to true and the connection is not terminated. When I forcefully change write_event_handler to NULL with GDB, I see the connection is closed as expected.
I searched the code for 'write_event_handler =' and could not find a single place where this member gets a value of NULL (it always gets a pointer to some function).

Can anyone confirm if this is really a bug ? maybe the if should be updated to 'if (mr->write_event_handler != ngx_http_request_empty_handler)' ?

Thank you,

Eran
Subject Author Posted

terminate a connection after sending headers

erankor2 September 01, 2014 05:25PM

Re: terminate a connection after sending headers

Maxim Dounin September 02, 2014 09:10AM

Re: terminate a connection after sending headers

erankor2 September 03, 2014 10:10AM

Re: terminate a connection after sending headers

Maxim Dounin September 03, 2014 09:12PM

Re: terminate a connection after sending headers

erankor2 September 04, 2014 04:38PM

Re: terminate a connection after sending headers

Maxim Dounin September 05, 2014 12:36AM

Re: terminate a connection after sending headers

erankor2 September 07, 2014 04:49PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 75
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready