changeset 416:b9bd635011de

nginx-0.0.10-2004-09-06-22:45:00 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 06 Sep 2004 18:45:00 +0000
parents 3c56e834be46
children 0526206251f6
files auto/sources src/core/ngx_array.h src/core/ngx_conf_file.c src/core/ngx_cycle.c src/core/ngx_list.c src/core/ngx_list.h src/http/modules/ngx_http_gzip_filter.c src/http/modules/ngx_http_headers_filter.c src/http/modules/ngx_http_range_filter.c src/http/modules/ngx_http_static_handler.c src/http/modules/ngx_http_status_handler.c src/http/modules/ngx_http_userid_filter.c src/http/modules/proxy/ngx_http_proxy_handler.h src/http/modules/proxy/ngx_http_proxy_header.c src/http/modules/proxy/ngx_http_proxy_upstream.c src/http/ngx_http.c src/http/ngx_http.h src/http/ngx_http_core_module.c src/http/ngx_http_header_filter.c src/http/ngx_http_headers.c src/http/ngx_http_request.c src/http/ngx_http_request.h src/http/ngx_http_special_response.c
diffstat 23 files changed, 138 insertions(+), 198 deletions(-) [+]
line wrap: on
line diff
--- a/auto/sources
+++ b/auto/sources
@@ -226,7 +226,6 @@ HTTP_SRCS="src/http/ngx_http.c \
             src/http/ngx_http_special_response.c \
             src/http/ngx_http_request.c \
             src/http/ngx_http_parse.c \
-            src/http/ngx_http_headers.c \
             src/http/ngx_http_header_filter.c \
             src/http/ngx_http_write_filter.c \
             src/http/ngx_http_copy_filter.c \
--- a/src/core/ngx_array.h
+++ b/src/core/ngx_array.h
@@ -20,7 +20,7 @@ void ngx_destroy_array(ngx_array_t *a);
 void *ngx_push_array(ngx_array_t *a);
 
 
-ngx_inline static ngx_int_t ngx_init_array0(ngx_array_t *array, ngx_pool_t *pool,
+ngx_inline static ngx_int_t ngx_array_init(ngx_array_t *array, ngx_pool_t *pool,
                                            ngx_uint_t n, size_t size)
 {
     if (!(array->elts = ngx_palloc(pool, n * size))) {
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -600,7 +600,7 @@ ngx_open_file_t *ngx_conf_open_file(ngx_
         }
     }
 
-    if (!(file = ngx_push_list(&cycle->open_files))) {
+    if (!(file = ngx_list_push(&cycle->open_files))) {
         return NULL;
     }
 
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -81,7 +81,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t 
         n = 20;
     }
 
-    if (ngx_init_list(&cycle->open_files, pool, n, sizeof(ngx_open_file_t))
+    if (ngx_list_init(&cycle->open_files, pool, n, sizeof(ngx_open_file_t))
                                                                   == NGX_ERROR)
     {
         ngx_destroy_pool(pool);
--- a/src/core/ngx_list.c
+++ b/src/core/ngx_list.c
@@ -3,7 +3,7 @@
 #include <ngx_core.h>
 
 
-void *ngx_push_list(ngx_list_t *l)
+void *ngx_list_push(ngx_list_t *l)
 {
     void             *elt;
     ngx_list_part_t  *last;
--- a/src/core/ngx_list.h
+++ b/src/core/ngx_list.h
@@ -24,7 +24,7 @@ typedef struct {
 } ngx_list_t;
 
 
-ngx_inline static ngx_int_t ngx_init_list(ngx_list_t *list, ngx_pool_t *pool,
+ngx_inline static ngx_int_t ngx_list_init(ngx_list_t *list, ngx_pool_t *pool,
                                           ngx_uint_t n, size_t size)
 {
     if (!(list->part.elts = ngx_palloc(pool, n * size))) {
@@ -67,7 +67,7 @@ ngx_inline static ngx_int_t ngx_init_lis
  */
 
 
-void *ngx_push_list(ngx_list_t *list);
+void *ngx_list_push(ngx_list_t *list);
 
 
 #endif /* _NGX_LIST_H_INCLUDED_ */
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -297,7 +297,7 @@ static ngx_int_t ngx_http_gzip_header_fi
                         sizeof(ngx_http_gzip_ctx_t), NGX_ERROR);
     ctx->request = r;
 
-    r->headers_out.content_encoding = ngx_push_list(&r->headers_out.headers);
+    r->headers_out.content_encoding = ngx_list_push(&r->headers_out.headers);
     if (r->headers_out.content_encoding == NULL) {
         return NGX_ERROR;
     }
--- a/src/http/modules/ngx_http_headers_filter.c
+++ b/src/http/modules/ngx_http_headers_filter.c
@@ -75,13 +75,13 @@ static ngx_int_t ngx_http_headers_filter
 
     if (conf->expires != NGX_HTTP_EXPIRES_OFF) {
 
-        if (!(expires = ngx_push_list(&r->headers_out.headers))) {
+        if (!(expires = ngx_list_push(&r->headers_out.headers))) {
             return NGX_ERROR;
         }
 
         r->headers_out.expires = expires;
 
-        if (!(cc = ngx_push_list(&r->headers_out.headers))) {
+        if (!(cc = ngx_list_push(&r->headers_out.headers))) {
             return NGX_ERROR;
         }
 
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter.c
@@ -123,7 +123,7 @@ static ngx_int_t ngx_http_range_header_f
         || ngx_strncasecmp(r->headers_in.range->value.data, "bytes=", 6) != 0)
     {
 
-        r->headers_out.accept_ranges = ngx_push_list(&r->headers_out.headers);
+        r->headers_out.accept_ranges = ngx_list_push(&r->headers_out.headers);
         if (r->headers_out.accept_ranges == NULL) {
             return NGX_ERROR;
         }
@@ -244,7 +244,7 @@ static ngx_int_t ngx_http_range_header_f
         r->headers_out.status = rc;
         r->headers_out.ranges.nelts = 0;
 
-        r->headers_out.content_range = ngx_push_list(&r->headers_out.headers);
+        r->headers_out.content_range = ngx_list_push(&r->headers_out.headers);
         if (r->headers_out.content_range == NULL) {
             return NGX_ERROR;
         }
@@ -277,7 +277,7 @@ static ngx_int_t ngx_http_range_header_f
         if (r->headers_out.ranges.nelts == 1) {
 
             r->headers_out.content_range =
-                                        ngx_push_list(&r->headers_out.headers);
+                                        ngx_list_push(&r->headers_out.headers);
             if (r->headers_out.content_range == NULL) {
                 return NGX_ERROR;
             }
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -341,8 +341,8 @@ static ngx_int_t ngx_http_static_handler
         *last++ = '/';
         *last = '\0';
 
-        if (!(r->headers_out.location = ngx_push_list(&r->headers_out.headers)))
-        {
+        r->headers_out.location = ngx_list_push(&r->headers_out.headers);
+        if (r->headers_out.location == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
 
--- a/src/http/modules/ngx_http_status_handler.c
+++ b/src/http/modules/ngx_http_status_handler.c
@@ -70,8 +70,8 @@ static ngx_int_t ngx_http_status_handler
         return rc;
     }
 
-    if (!(r->headers_out.content_type = ngx_push_list(&r->headers_out.headers)))
-    {
+    r->headers_out.content_type = ngx_list_push(&r->headers_out.headers);
+    if (r->headers_out.content_type == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     } 
 
--- a/src/http/modules/ngx_http_userid_filter.c
+++ b/src/http/modules/ngx_http_userid_filter.c
@@ -381,7 +381,7 @@ static ngx_int_t ngx_http_userid_set_uid
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                    "uid cookie: \"%s\"", cookie);
 
-    if (!(set_cookie = ngx_push_list(&r->headers_out.headers))) {
+    if (!(set_cookie = ngx_list_push(&r->headers_out.headers))) {
         return NGX_ERROR;
     }
 
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -107,7 +107,10 @@ typedef struct {
 
 
 typedef struct {
+    ngx_list_t                       headers;
+#if 0
     ngx_table_t                      headers;   /* it must be first field */
+#endif
 
     ngx_table_elt_t                 *date;
     ngx_table_elt_t                 *server;
--- a/src/http/modules/proxy/ngx_http_proxy_header.c
+++ b/src/http/modules/proxy/ngx_http_proxy_header.c
@@ -12,13 +12,31 @@ int ngx_http_proxy_copy_header(ngx_http_
                                ngx_http_proxy_headers_in_t *headers_in)
 {
     ngx_uint_t           i;
+    ngx_list_part_t     *part;
     ngx_table_elt_t     *ho, *h;
     ngx_http_request_t  *r;
 
     r = p->request;
 
+    part = &headers_in->headers.part;
+    h = part->elts;
+
+#if 0
     h = headers_in->headers.elts;
     for (i = 0; i < headers_in->headers.nelts; i++) {
+#endif
+
+    for (i = 0 ; /* void */; i++) {
+  
+        if (i >= part->nelts) {
+            if (part->next == NULL) {
+                break;
+            }
+  
+            part = part->next;
+            h = part->elts;
+            i = 0;
+        }
 
         /* ignore some headers */
 
@@ -69,8 +87,7 @@ int ngx_http_proxy_copy_header(ngx_http_
 
         /* copy some header pointers and set up r->headers_out */
 
-        if (!(ho = ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
-        {
+        if (!(ho = ngx_list_push(&r->headers_out.headers))) {
             return NGX_ERROR;
         }
 
@@ -138,8 +155,7 @@ static int ngx_http_proxy_rewrite_locati
     r = p->request;
     uc = p->lcf->upstream;
 
-    location = ngx_http_add_header(&r->headers_out, ngx_http_headers_out);
-    if (location == NULL) {
+    if (!(location = ngx_list_push(&r->headers_out.headers))) {
         return NGX_ERROR;
     }
 
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -954,20 +954,22 @@ static void ngx_http_proxy_process_upstr
 
     /* init or reinit the p->upstream->headers_in.headers table */
 
-    if (p->upstream->headers_in.headers.elts) {
-        p->upstream->headers_in.headers.nelts = 0;
+    if (p->upstream->headers_in.headers.part.elts) {
+        p->upstream->headers_in.headers.part.nelts = 0;
+        p->upstream->headers_in.headers.part.next = NULL;
+        p->upstream->headers_in.headers.last =
+                                         &p->upstream->headers_in.headers.part;
+
+        ngx_memzero(&p->upstream->headers_in.date,
+                    sizeof(ngx_http_proxy_headers_in_t) - sizeof(ngx_list_t));
 
     } else {
-        p->upstream->headers_in.headers.elts = ngx_pcalloc(p->request->pool,
-                                                 20 * sizeof(ngx_table_elt_t));
-        if (p->upstream->headers_in.headers.elts == NULL) {
+        if (ngx_list_init(&p->upstream->headers_in.headers, p->request->pool,
+                                     20, sizeof(ngx_table_elt_t)) == NGX_ERROR)
+        {
             ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
             return;
         }
-        /* p->upstream->headers_in.headers.nelts = 0; */
-        p->upstream->headers_in.headers.nalloc = 20;
-        p->upstream->headers_in.headers.size = sizeof(ngx_table_elt_t);
-        p->upstream->headers_in.headers.pool = p->request->pool;
     }
 
 
@@ -1025,9 +1027,7 @@ static void ngx_http_proxy_process_upstr
 
             /* a header line has been parsed successfully */
 
-            h = ngx_http_add_header(&p->upstream->headers_in,
-                                    ngx_http_proxy_headers_in);
-            if (h == NULL) {
+            if (!(h = ngx_list_push(&p->upstream->headers_in.headers))) {
                 ngx_http_proxy_finalize_request(p,
                                                 NGX_HTTP_INTERNAL_SERVER_ERROR);
                 return;
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -500,13 +500,16 @@ static char *ngx_http_block(ngx_conf_t *
         in_addr = in_port[p].addrs.elts;
         while (a < in_port[p].addrs.nelts) {
 
-            ngx_test_null(ls, ngx_push_array(&cf->cycle->listening),
-                          NGX_CONF_ERROR);
+            if (!(ls = ngx_push_array(&cf->cycle->listening))) {
+                return NGX_CONF_ERROR;
+            }
+
             ngx_memzero(ls, sizeof(ngx_listening_t));
 
-            ngx_test_null(addr_in,
-                          ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in)),
-                          NGX_CONF_ERROR);
+            addr_in = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in));
+            if (addr_in == NULL) {
+                return NGX_CONF_ERROR;
+            }
 
 #if (HAVE_SIN_LEN)
             addr_in->sin_len = sizeof(struct sockaddr_in);
@@ -515,17 +518,18 @@ static char *ngx_http_block(ngx_conf_t *
             addr_in->sin_addr.s_addr = in_addr[a].addr;
             addr_in->sin_port = htons((u_short) in_port[p].port);
 
-            ngx_test_null(ls->addr_text.data,
-                          ngx_palloc(cf->pool, INET_ADDRSTRLEN + 6),
-                          NGX_CONF_ERROR);
+            ls->addr_text.data = ngx_palloc(cf->pool, INET_ADDRSTRLEN + 6);
+            if (ls->addr_text.data == NULL) {
+                return NGX_CONF_ERROR;
+            }
 
-            ls->addr_text.len =
-                        ngx_snprintf((char *) ls->addr_text.data
-                                     + ngx_inet_ntop(AF_INET,
-                                                     &in_addr[a].addr,
-                                                     ls->addr_text.data,
-                                                     INET_ADDRSTRLEN),
-                                     6, ":%d", in_port[p].port);
+            ls->addr_text.len = ngx_inet_ntop(AF_INET, &in_addr[a].addr,
+                                              ls->addr_text.data,
+                                              INET_ADDRSTRLEN),
+
+            ls->addr_text.len += ngx_snprintf((char *) ls->addr_text.data
+                                                           + ls->addr_text.len,
+                                               6, ":%d", in_port[p].port);
 
             ls->fd = (ngx_socket_t) -1;
             ls->family = AF_INET;
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -81,8 +81,6 @@ ngx_int_t ngx_http_special_response_hand
 
 time_t ngx_http_parse_time(u_char *value, size_t len);
 size_t ngx_http_get_time(char *buf, time_t t);
-ngx_table_elt_t *ngx_http_add_header(void *header,
-                                     ngx_http_header_t *http_headers);
 
 
 
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -531,8 +531,8 @@ ngx_int_t ngx_http_find_location_config(
 
 
     if (rc == NGX_HTTP_LOCATION_AUTO_REDIRECT) {
-        if (!(r->headers_out.location = ngx_push_list(&r->headers_out.headers)))
-        {
+        r->headers_out.location = ngx_list_push(&r->headers_out.headers);
+        if (r->headers_out.location == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
 
@@ -673,8 +673,8 @@ ngx_int_t ngx_http_set_content_type(ngx_
     ngx_http_type_t           *type;
     ngx_http_core_loc_conf_t  *clcf;
 
-    if (!(r->headers_out.content_type = ngx_push_list(&r->headers_out.headers)))
-    {
+    r->headers_out.content_type = ngx_list_push(&r->headers_out.headers);
+    if (r->headers_out.content_type == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -89,6 +89,28 @@ static ngx_str_t http_codes[] = {
 };
 
 
+ngx_http_header_t  ngx_http_headers_out[] = {
+    { ngx_string("Server"), offsetof(ngx_http_headers_out_t, server) },
+    { ngx_string("Date"), offsetof(ngx_http_headers_out_t, date) },
+    { ngx_string("Content-Type"),
+                             offsetof(ngx_http_headers_out_t, content_type) },
+    { ngx_string("Content-Length"),
+                           offsetof(ngx_http_headers_out_t, content_length) },
+    { ngx_string("Content-Encoding"),
+                         offsetof(ngx_http_headers_out_t, content_encoding) },
+    { ngx_string("Location"), offsetof(ngx_http_headers_out_t, location) },
+    { ngx_string("Last-Modified"),
+                            offsetof(ngx_http_headers_out_t, last_modified) },
+    { ngx_string("Accept-Ranges"),
+                            offsetof(ngx_http_headers_out_t, accept_ranges) },
+    { ngx_string("Expires"), offsetof(ngx_http_headers_out_t, expires) },
+    { ngx_string("Cache-Control"),
+                            offsetof(ngx_http_headers_out_t, cache_control) },
+    { ngx_string("ETag"), offsetof(ngx_http_headers_out_t, etag) },
+
+    { ngx_null_string, 0 }
+};
+
 
 static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
 {
deleted file mode 100644
--- a/src/http/ngx_http_headers.c
+++ /dev/null
@@ -1,116 +0,0 @@
-
-#include <ngx_config.h>
-#include <ngx_core.h>
-#include <ngx_http.h>
-
-
-ngx_http_header_t  ngx_http_headers_in[] = {
-    { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host) },
-    { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection) },
-    { ngx_string("If-Modified-Since"),
-                         offsetof(ngx_http_headers_in_t, if_modified_since) },
-    { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent) },
-    { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer) },
-    { ngx_string("Content-Length"),
-                            offsetof(ngx_http_headers_in_t, content_length) },
-
-    { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range) },
-#if 0
-    { ngx_string("If-Range"), offsetof(ngx_http_headers_in_t, if_range) },
-#endif
-
-#if (NGX_HTTP_GZIP)
-    { ngx_string("Accept-Encoding"),
-                           offsetof(ngx_http_headers_in_t, accept_encoding) },
-    { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via) },
-#endif
-
-    { ngx_string("Authorization"),
-                             offsetof(ngx_http_headers_in_t, authorization) },
-
-    { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive) },
-
-#if (NGX_HTTP_PROXY)
-    { ngx_string("X-Forwarded-For"),
-                           offsetof(ngx_http_headers_in_t, x_forwarded_for) },
-#endif
-
-    { ngx_null_string, 0 }
-};
-
-
-ngx_http_header_t  ngx_http_headers_out[] = {
-    { ngx_string("Server"), offsetof(ngx_http_headers_out_t, server) },
-    { ngx_string("Date"), offsetof(ngx_http_headers_out_t, date) },
-    { ngx_string("Content-Type"),
-                             offsetof(ngx_http_headers_out_t, content_type) },
-    { ngx_string("Content-Length"),
-                           offsetof(ngx_http_headers_out_t, content_length) },
-    { ngx_string("Content-Encoding"),
-                         offsetof(ngx_http_headers_out_t, content_encoding) },
-    { ngx_string("Location"), offsetof(ngx_http_headers_out_t, location) },
-    { ngx_string("Last-Modified"),
-                            offsetof(ngx_http_headers_out_t, last_modified) },
-    { ngx_string("Accept-Ranges"),
-                            offsetof(ngx_http_headers_out_t, accept_ranges) },
-    { ngx_string("Expires"), offsetof(ngx_http_headers_out_t, expires) },
-    { ngx_string("Cache-Control"),
-                            offsetof(ngx_http_headers_out_t, cache_control) },
-    { ngx_string("ETag"), offsetof(ngx_http_headers_out_t, etag) },
-
-    { ngx_null_string, 0 }
-};
-
-
-ngx_table_elt_t *ngx_http_add_header(void *header,
-                                     ngx_http_header_t *http_headers)
-{
-    void             *prev;
-    ngx_uint_t        i, j;
-    ngx_table_t      *headers;
-    ngx_table_elt_t  *h, *new;
-
-    headers = header;
-
-    prev = headers->elts;
-
-    if (!(new = ngx_push_table(headers))) {
-        return NULL;
-    }
-
-    if (prev == headers->elts) {
-        return new;
-    }
-
-    /*
-     * When table is relocated we need to update pointers in r->headers_in,
-     * r->headers_out, etc.  However this relocation should be very rare
-     * because we preallocate enough space for the number of the real world
-     * HTTP headers.
-     */
-
-    ngx_log_error(NGX_LOG_ALERT, headers->pool->log, 0,
-                  "header table is small, %d elements", headers->nelts - 1);
-
-    h = headers->elts;
-    for (i = 0; i < headers->nelts - 1; i++) {
-        if (h[i].key.len == 0) {
-            continue;
-        }
-
-        for (j = 0; http_headers[j].name.len != 0; j++) {
-            if (http_headers[j].name.len != h[i].key.len) {
-                continue;
-            }
-
-            if (ngx_strcasecmp(http_headers[j].name.data, h[i].key.data) == 0) {
-                *((ngx_table_elt_t **)
-                      ((char *) header + http_headers[j].offset)) = &h[i];
-                break;
-            }
-        }
-    }
-
-    return new;
-}
-
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -49,6 +49,41 @@ static char *client_header_errors[] = {
 };
 
 
+ngx_http_header_t  ngx_http_headers_in[] = {
+    { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host) },
+    { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection) },
+    { ngx_string("If-Modified-Since"),
+                         offsetof(ngx_http_headers_in_t, if_modified_since) },
+    { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent) },
+    { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer) },
+    { ngx_string("Content-Length"),
+                            offsetof(ngx_http_headers_in_t, content_length) },
+
+    { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range) },
+#if 0
+    { ngx_string("If-Range"), offsetof(ngx_http_headers_in_t, if_range) },
+#endif
+
+#if (NGX_HTTP_GZIP)
+    { ngx_string("Accept-Encoding"),
+                           offsetof(ngx_http_headers_in_t, accept_encoding) },
+    { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via) },
+#endif
+
+    { ngx_string("Authorization"),
+                             offsetof(ngx_http_headers_in_t, authorization) },
+
+    { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive) },
+
+#if (NGX_HTTP_PROXY)
+    { ngx_string("X-Forwarded-For"),
+                           offsetof(ngx_http_headers_in_t, x_forwarded_for) },
+#endif
+    
+    { ngx_null_string, 0 }
+};
+
+
 #if 0
 static void ngx_http_dummy(ngx_event_t *wev)
 {
@@ -310,7 +345,7 @@ static void ngx_http_init_request(ngx_ev
     r->cleanup.pool = r->pool;
 
 
-    if (ngx_init_list(&r->headers_out.headers, r->pool, 2,
+    if (ngx_list_init(&r->headers_out.headers, r->pool, 20,
                                          sizeof(ngx_table_elt_t)) == NGX_ERROR)
     {
         ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -319,23 +354,6 @@ static void ngx_http_init_request(ngx_ev
     }
 
 
-#if 0
-    /* init the r->headers_out.headers table */
-
-    r->headers_out.headers.elts = ngx_pcalloc(r->pool,
-                                              20 * sizeof(ngx_table_elt_t));
-    if (r->headers_out.headers.elts == NULL) {
-        ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
-        ngx_http_close_connection(c);
-        return;
-    }
-    /* r->headers_out.headers.nelts = 0; */
-    r->headers_out.headers.nalloc = 20;
-    r->headers_out.headers.size = sizeof(ngx_table_elt_t);
-    r->headers_out.headers.pool = r->pool;
-#endif
-
-
     r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
     if (r->ctx == NULL) {
         ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -619,7 +637,7 @@ static void ngx_http_process_request_lin
         }
 
 
-        if (ngx_init_list(&r->headers_in.headers, r->pool, 2,
+        if (ngx_list_init(&r->headers_in.headers, r->pool, 20,
                                          sizeof(ngx_table_elt_t)) == NGX_ERROR)
         {
             ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -628,7 +646,7 @@ static void ngx_http_process_request_lin
         }
 
 
-        if (ngx_init_array0(&r->headers_in.cookies, r->pool, 5,
+        if (ngx_array_init(&r->headers_in.cookies, r->pool, 5,
                                        sizeof(ngx_table_elt_t *)) == NGX_ERROR)
         {
             ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -772,7 +790,7 @@ static void ngx_http_process_request_hea
 
             r->headers_n++;
 
-            if (!(h = ngx_push_list(&r->headers_in.headers))) {
+            if (!(h = ngx_list_push(&r->headers_in.headers))) {
                 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
                 ngx_http_close_connection(c);
                 return;
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -160,9 +160,6 @@ typedef struct {
 
 typedef struct {
     ngx_list_t        headers;
-#if 0
-    ngx_table_t       headers;   /* it must be first field */
-#endif
 
     ngx_uint_t        status;
     ngx_str_t         status_line;
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -282,9 +282,8 @@ ngx_int_t ngx_http_special_response_hand
             msie_padding = 1;
         }
 
-        if (!(r->headers_out.content_type =
-                                       ngx_push_list(&r->headers_out.headers)))
-        {
+        r->headers_out.content_type = ngx_list_push(&r->headers_out.headers);
+        if (r->headers_out.content_type == NULL) {
             return NGX_ERROR;
         }