diff src/http/ngx_http_request.c @ 130:82d695e3d662 NGINX_0_3_12

nginx 0.3.12 *) Security: if nginx was built with the ngx_http_realip_module and the "satisfy_any on" directive was used, then access and authorization directives did not work. The ngx_http_realip_module was not built and is not built by default. *) Change: the "$time_gmt" variable name was changed to "$time_local". *) Change: the "proxy_header_buffer_size" and "fastcgi_header_buffer_size" directives was renamed to the "proxy_buffer_size" and "fastcgi_buffer_size" directives. *) Feature: the ngx_http_memcached_module. *) Feature: the "proxy_buffering" directive. *) Bugfix: the changes in accept mutex handling when the "rtsig" method was used; bug appeared in 0.3.0. *) Bugfix: if the client sent the "Transfer-Encoding: chunked" header line, then nginx returns the 411 error. *) Bugfix: if the "auth_basic" directive was inherited from the http level, then the realm in the "WWW-Authenticate" header line was without the "Basic realm" text. *) Bugfix: if the "combined" format was explicitly specified in the "access_log" directive, then the empty lines was written to the log; bug appeared in 0.3.8. *) Bugfix: nginx did not run on the sparc platform under any OS except Solaris. *) Bugfix: now it is not necessary to place space between the quoted string and closing bracket in the "if" directive.
author Igor Sysoev <http://sysoev.ru>
date Sat, 26 Nov 2005 00:00:00 +0300
parents df17fbafec8f
children 91372f004adf
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -95,6 +95,10 @@ ngx_http_header_t  ngx_http_headers_in[]
     { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range),
                  ngx_http_process_header_line },
 
+    { ngx_string("Transfer-Encoding"),
+                 offsetof(ngx_http_headers_in_t, transfer_encoding),
+                 ngx_http_process_header_line },
+
 #if (NGX_HTTP_GZIP)
     { ngx_string("Accept-Encoding"),
                  offsetof(ngx_http_headers_in_t, accept_encoding),
@@ -377,7 +381,8 @@ void ngx_http_init_request(ngx_event_t *
 
 
     if (ngx_list_init(&r->headers_out.headers, r->pool, 20,
-                      sizeof(ngx_table_elt_t)) == NGX_ERROR)
+                      sizeof(ngx_table_elt_t))
+        == NGX_ERROR)
     {
         ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
         return;
@@ -660,7 +665,8 @@ ngx_http_process_request_line(ngx_event_
 
 
             if (ngx_list_init(&r->headers_in.headers, r->pool, 20,
-                                         sizeof(ngx_table_elt_t)) == NGX_ERROR)
+                              sizeof(ngx_table_elt_t))
+                == NGX_ERROR)
             {
                 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
                 return;
@@ -668,7 +674,8 @@ ngx_http_process_request_line(ngx_event_
 
 
             if (ngx_array_init(&r->headers_in.cookies, r->pool, 2,
-                                       sizeof(ngx_table_elt_t *)) == NGX_ERROR)
+                               sizeof(ngx_table_elt_t *))
+                == NGX_ERROR)
             {
                 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
                 return;
@@ -1213,7 +1220,7 @@ ngx_http_process_request_header(ngx_http
         if (r->headers_in.content_length_n == NGX_ERROR) {
             ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
                           "client sent invalid \"Content-Length\" header");
-            ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+            ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
             return NGX_ERROR;
         }
     }
@@ -1221,7 +1228,16 @@ ngx_http_process_request_header(ngx_http
     if (r->method == NGX_HTTP_POST && r->headers_in.content_length_n == -1) {
         ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
                   "client sent POST method without \"Content-Length\" header");
-        ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+        ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
+        return NGX_ERROR;
+    }
+
+    if (r->headers_in.transfer_encoding
+        && ngx_strstr(r->headers_in.transfer_encoding->value.data, "chunked"))
+    {
+        ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+                      "client sent \"Transfer-Encoding: chunked\" header");
+        ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
         return NGX_ERROR;
     }
 
@@ -2095,7 +2111,10 @@ ngx_http_keepalive_handler(ngx_event_t *
 #if (NGX_HAVE_KQUEUE)
 
     if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
-        if (rev->pending_eof) {
+        if (rev->pending_eof
+            /* FreeBSD 5.x-6.x may erroneously report ETIMEDOUT */
+            && rev->kq_errno != NGX_ETIMEDOUT)
+        {
             c->log->handler = NULL;
             ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
                           "kevent() reported that client %V closed "
@@ -2312,7 +2331,7 @@ ngx_http_request_empty_handler(ngx_http_
 
 
 ngx_int_t
-ngx_http_send_last(ngx_http_request_t *r)
+ngx_http_send_special(ngx_http_request_t *r, ngx_uint_t flags)
 {
     ngx_buf_t    *b;
     ngx_chain_t   out;
@@ -2322,7 +2341,14 @@ ngx_http_send_last(ngx_http_request_t *r
         return NGX_ERROR;
     }
 
-    b->last_buf = 1;
+    if (flags & NGX_HTTP_LAST) {
+        b->last_buf = 1;
+    }
+
+    if (flags & NGX_HTTP_FLUSH) {
+        b->flush = 1;
+    }
+
     out.buf = b;
     out.next = NULL;
 
@@ -2354,8 +2380,10 @@ void
 ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error)
 {
     ngx_log_t                  *log;
+    ngx_uint_t                  i, n;
     struct linger               linger;
     ngx_http_log_ctx_t         *ctx;
+    ngx_http_handler_pt        *log_handler;
     ngx_http_core_loc_conf_t   *clcf;
     ngx_http_core_main_conf_t  *cmcf;
 
@@ -2386,8 +2414,10 @@ ngx_http_request_done(ngx_http_request_t
 
     cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
 
-    if (cmcf->log_handler) {
-        cmcf->log_handler(r);
+    log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts;
+    n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts;
+    for (i = 0; i < n; i++) {
+        log_handler[i](r);
     }
 
     if (r->connection->timedout) {