[nginx] Added safety belt for the case of sending header twice.

Sergey Kandaurov pluknet at nginx.com
Wed Aug 21 16:24:37 UTC 2013


details:   http://hg.nginx.org/nginx/rev/03ff14058272
branches:  
changeset: 5334:03ff14058272
user:      Sergey Kandaurov <pluknet at nginx.com>
date:      Tue Jul 30 15:04:46 2013 +0400
description:
Added safety belt for the case of sending header twice.

The aforementioned situation is abnormal per se and as such it now forces
request termination with appropriate error message.

diffstat:

 src/http/ngx_http_core_module.c |  6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (16 lines):

diff -r e8bca8397625 -r 03ff14058272 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c	Tue Jul 30 11:43:21 2013 +0400
+++ b/src/http/ngx_http_core_module.c	Tue Jul 30 15:04:46 2013 +0400
@@ -1933,6 +1933,12 @@ ngx_http_send_response(ngx_http_request_
 ngx_int_t
 ngx_http_send_header(ngx_http_request_t *r)
 {
+    if (r->header_sent) {
+        ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
+                      "header already sent");
+        return NGX_ERROR;
+    }
+
     if (r->err_status) {
         r->headers_out.status = r->err_status;
         r->headers_out.status_line.len = 0;



More information about the nginx-devel mailing list