nginx-0.0.11-2004-09-22-20:18:21 import
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 06f1565..325a8fe 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -96,6 +96,13 @@
       offsetof(ngx_http_core_srv_conf_t, client_header_buffer_size),
       NULL },
 
+    { ngx_string("client_large_buffers"),
+      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE2,
+      ngx_conf_set_bufs_slot,
+      NGX_HTTP_SRV_CONF_OFFSET,
+      offsetof(ngx_http_core_srv_conf_t, client_large_buffers),
+      NULL },
+
     { ngx_string("large_client_header"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
       ngx_conf_set_flag_slot,
@@ -1247,6 +1254,15 @@
                   ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t)),
                   NGX_CONF_ERROR);
 
+    /*
+
+    set by ngx_pcalloc():
+
+    conf->client_large_buffers.num = 0;
+
+    */
+
+
     ngx_init_array(cscf->locations, cf->pool,
                    5, sizeof(void *), NGX_CONF_ERROR);
     ngx_init_array(cscf->listen, cf->pool, 5, sizeof(ngx_http_listen_t),
@@ -1326,6 +1342,8 @@
                               prev->client_header_timeout, 60000);
     ngx_conf_merge_size_value(conf->client_header_buffer_size,
                               prev->client_header_buffer_size, 1024);
+    ngx_conf_merge_bufs_value(conf->client_large_buffers,
+                              prev->client_large_buffers, 4, ngx_pagesize);
     ngx_conf_merge_value(conf->large_client_header,
                          prev->large_client_header, 1);
     ngx_conf_merge_unsigned_value(conf->restrict_host_names,
@@ -1543,7 +1561,7 @@
         return NGX_CONF_OK;
     }
 
-    ls->port = port;
+    ls->port = (in_port_t) port;
 
     ls->addr = inet_addr((const char *) addr);
     if (ls->addr == INADDR_NONE) {
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 8385f48..0122b8b 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -66,6 +66,8 @@
     size_t                request_pool_size;
     size_t                client_header_buffer_size;
 
+    ngx_bufs_t            client_large_buffers;
+
     ngx_msec_t            post_accept_timeout;
     ngx_msec_t            client_header_timeout;
 
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index bb1cc7d..49ca93a 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -12,6 +12,8 @@
 static void ngx_http_process_request_line(ngx_event_t *rev);
 static void ngx_http_process_request_headers(ngx_event_t *rev);
 static ssize_t ngx_http_read_request_header(ngx_http_request_t *r);
+static ngx_int_t ngx_http_alloc_header_buf(ngx_http_request_t *r,
+                                           ngx_uint_t request_line);
 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r);
 
 static void ngx_http_set_write_handler(ngx_http_request_t *r);
@@ -935,6 +937,25 @@
 
         if (r->header_in->last == r->header_in->end) {
 
+#if 1
+            /* ngx_http_alloc_large_header_buffer() */
+
+            rc = ngx_http_alloc_header_buf(r, 0);
+
+            if (rc == NGX_ERROR) {
+                ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+                ngx_http_close_connection(c);
+                return;
+            }
+
+            if (rc == NGX_DECLINED) {
+                ngx_http_client_error(r, NGX_HTTP_PARSE_TOO_LONG_HEADER,
+                                      NGX_HTTP_BAD_REQUEST);
+                return;
+            }
+#endif
+
+#if 0
             /*
              * if the large client headers are enabled then
              * we need to compact r->header_in buf
@@ -964,6 +985,7 @@
                                       NGX_HTTP_BAD_REQUEST);
                 return;
             }
+#endif
         }
     }
 }
@@ -1023,6 +1045,92 @@
 }
 
 
+#if 1
+
+static ngx_int_t ngx_http_alloc_header_buf(ngx_http_request_t *r,
+                                           ngx_uint_t request_line)
+{
+    u_char                    *old, *new;
+    ngx_int_t                  offset;
+    ngx_buf_t                 *b;
+    ngx_http_connection_t     *hc;
+    ngx_http_core_srv_conf_t  *cscf;
+
+    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                   "http alloc large header buffer");
+
+    old = request_line ? r->request_start : r->header_name_start;
+
+    cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
+
+    if ((size_t) (r->header_in->pos - old) >= cscf->client_large_buffers.size) {
+        return NGX_DECLINED;
+    }
+
+    hc = r->http_connection;
+
+    if (hc->nfree) {
+        b = hc->free[--hc->nfree];
+
+    } else if (hc->nbusy < cscf->client_large_buffers.num) {
+
+        if (hc->busy == NULL) {
+            hc->busy = ngx_palloc(r->connection->pool,
+                         cscf->client_large_buffers.num * sizeof(ngx_buf_t *));
+            if (hc->busy == NULL) {
+                return NGX_ERROR;
+            }
+        }
+
+        b = ngx_create_temp_buf(r->connection->pool,
+                                cscf->client_large_buffers.size);
+        if (b == NULL) {
+            return NGX_ERROR;
+        }
+
+    } else {
+        return NGX_DECLINED;
+    }
+
+    hc->busy[hc->nbusy++] = b;
+
+    new = b->start;
+
+    ngx_memcpy(new, old, r->header_in->last - old);
+
+    b->pos = new + (r->header_in->pos - old);
+    b->last = new + (r->header_in->last - old);
+
+    if (request_line) {
+        r->request_start = new;
+        r->request_end = new + (r->request_end - old);
+
+        r->uri_start = new + (r->uri_start - old);
+        r->uri_end = new + (r->uri_end - old);
+
+        if (r->uri_ext) {
+            r->uri_ext = new + (r->uri_ext - old);
+        }
+
+        if (r->args_start) {
+            r->args_start = new + (r->args_start - old);
+        }
+
+    } else {
+        r->header_name_start = new;
+        r->header_name_end = new + (r->header_name_end - old);
+        r->header_start = new + (r->header_start - old);
+        r->header_end = new + (r->header_end - old);
+    }
+
+    r->header_in = b;
+
+    return NGX_OK;
+}
+
+#endif
+
+
 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
 {
     u_char                    *ua, *user_agent;
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 8ecdfd1..c719be8 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -221,10 +221,10 @@
     ngx_http_request_t   *request;
 
     ngx_buf_t           **busy;
-    ngx_uint_t            nbusy;
+    ngx_int_t             nbusy;
 
     ngx_buf_t           **free;
-    ngx_uint_t            nfree;
+    ngx_int_t             nfree;
 
     ngx_uint_t            pipeline;      /* unsigned  pipeline:1; */
 } ngx_http_connection_t;