]> git.kaiwu.me - nginx.git/commitdiff
Added safety belt for the case of sending header twice.
authorSergey Kandaurov <pluknet@nginx.com>
Tue, 30 Jul 2013 11:04:46 +0000 (15:04 +0400)
committerSergey Kandaurov <pluknet@nginx.com>
Tue, 30 Jul 2013 11:04:46 +0000 (15:04 +0400)
The aforementioned situation is abnormal per se and as such it now forces
request termination with appropriate error message.

src/http/ngx_http_core_module.c

index ffe7fb4fe7ce51cc26af186de60186688d723eef..47e5ff789ec33dc5a5490ad46e9e6a84467efedc 100644 (file)
@@ -1933,6 +1933,12 @@ ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
 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;