diff src/http/ngx_http_request.c @ 230:38e7b94d63ac NGINX_0_4_0

nginx 0.4.0 *) Change in internal API: the HTTP modules initialization was moved from the init module phase to the HTTP postconfiguration phase. *) Change: now the request body is not read beforehand for the ngx_http_perl_module: it's required to start the reading using the $r->has_request_body method. *) Feature: the ngx_http_perl_module supports the DECLINED return code. *) Feature: the ngx_http_dav_module supports the incoming "Date" header line for the PUT method. *) Feature: the "ssi" directive is available inside the "if" block. *) Bugfix: a segmentation fault occurred if there was an "index" directive with variables and the first index name was without variables; bug appeared in 0.1.29.
author Igor Sysoev <http://sysoev.ru>
date Wed, 30 Aug 2006 00:00:00 +0400
parents 21f2ace7c936
children c982febb7588
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -140,6 +140,9 @@ ngx_http_header_t  ngx_http_headers_in[]
 
     { ngx_string("Destination"), offsetof(ngx_http_headers_in_t, destination),
                  ngx_http_process_header_line },
+
+    { ngx_string("Date"), offsetof(ngx_http_headers_in_t, date),
+                 ngx_http_process_header_line },
 #endif
 
     { ngx_string("Cookie"), 0, ngx_http_process_cookie },
@@ -933,9 +936,11 @@ ngx_http_read_request_header(ngx_http_re
 {
     ssize_t                    n;
     ngx_event_t               *rev;
+    ngx_connection_t          *c;
     ngx_http_core_srv_conf_t  *cscf;
 
-    rev = r->connection->read;
+    c = r->connection;
+    rev = c->read;
 
     n = r->header_in->last - r->header_in->pos;
 
@@ -944,8 +949,8 @@ ngx_http_read_request_header(ngx_http_re
     }
 
     if (rev->ready) {
-        n = r->connection->recv(r->connection, r->header_in->last,
-                                r->header_in->end - r->header_in->last);
+        n = c->recv(c, r->header_in->last,
+                    r->header_in->end - r->header_in->last);
     } else {
         n = NGX_AGAIN;
     }
@@ -966,11 +971,14 @@ ngx_http_read_request_header(ngx_http_re
     }
 
     if (n == 0) {
-        ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+        ngx_log_error(NGX_LOG_INFO, c->log, 0,
                       "client closed prematurely connection");
     }
 
     if (n == 0 || n == NGX_ERROR) {
+        c->error = rev->error;
+        c->log->action = "sending response to client";
+
         ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
         return NGX_ERROR;
     }
@@ -1155,8 +1163,9 @@ ngx_http_process_unique_header_line(ngx_
     }
 
     ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
-                  "client sent duplicate header line: \"%V: %V\"",
-                  &h->key, &h->value);
+                  "client sent duplicate header line: \"%V: %V\", "
+                  "previous value: \"%V: %V\"",
+                  &h->key, &h->value, &(*ph)->key, &(*ph)->value);
 
     ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
 
@@ -1460,6 +1469,13 @@ ngx_http_finalize_request(ngx_http_reque
                    "http finalize request: %d, \"%V?%V\"",
                    rc, &r->uri, &r->args);
 
+    if (rc == NGX_DECLINED) {
+        r->content_handler = NULL;
+        r->write_event_handler = ngx_http_core_run_phases;
+        ngx_http_core_run_phases(r);
+        return;
+    }
+
     if (r != r->main
         && rc != NGX_ERROR
         && !r->connection->error