nginx-0.0.3-2004-04-01-20:20:53 import
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 8f0336a..0dba23f 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -60,13 +60,6 @@
       0,
       NULL },
 
-    { ngx_string("proxy_request_buffer_size"),
-      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
-      ngx_conf_set_size_slot,
-      NGX_HTTP_LOC_CONF_OFFSET,
-      offsetof(ngx_http_proxy_loc_conf_t, request_buffer_size),
-      NULL },
-
     { ngx_string("proxy_connect_timeout"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
       ngx_conf_set_msec_slot,
@@ -781,7 +774,6 @@
 
     */
 
-    conf->request_buffer_size = NGX_CONF_UNSET_SIZE;
     conf->connect_timeout = NGX_CONF_UNSET_MSEC;
     conf->send_timeout = NGX_CONF_UNSET_MSEC;
 
@@ -822,8 +814,6 @@
     ngx_http_proxy_loc_conf_t *prev = parent;
     ngx_http_proxy_loc_conf_t *conf = child;
 
-    ngx_conf_merge_size_value(conf->request_buffer_size,
-                              prev->request_buffer_size, 8192);
     ngx_conf_merge_msec_value(conf->connect_timeout,
                               prev->connect_timeout, 60000);
     ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 30000);
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h
index d204cac..853aa76 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -48,7 +48,6 @@
 
 
 typedef struct {
-    size_t                           request_buffer_size;
     size_t                           header_buffer_size;
     size_t                           busy_buffers_size;
     size_t                           max_temp_file_size;
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index 00a0780..bd4befd 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -86,7 +86,6 @@
     tf->warn = "a client request body is buffered to a temporary file";
     /* tf->persistent = 0; */
 
-    rb->buf_size = p->lcf->request_buffer_size;
     rb->handler = ngx_http_proxy_init_upstream;
     rb->data = p;
     /* rb->bufs = NULL; */
@@ -1179,7 +1178,10 @@
     ep->temp_file->file.log = r->connection->log;
     ep->temp_file->path = p->lcf->temp_path;
     ep->temp_file->pool = r->pool;
-    if (!p->cachable) {
+
+    if (p->cachable) {
+        ep->temp_file->persistent = 1;
+    } else {
         ep->temp_file->warn = "an upstream response is buffered "
                               "to a temporary file";
     }
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 1f449e2..3ae6182 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -149,6 +149,13 @@
       offsetof(ngx_http_core_loc_conf_t, client_max_body_size),
       NULL },
 
+    { ngx_string("client_body_buffer_size"),
+      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+      ngx_conf_set_size_slot,
+      NGX_HTTP_LOC_CONF_OFFSET,
+      offsetof(ngx_http_core_loc_conf_t, client_body_buffer_size),
+      NULL },
+
     { ngx_string("client_body_timeout"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
       ngx_conf_set_msec_slot,
@@ -1181,6 +1188,7 @@
     */
 
     lcf->client_max_body_size = NGX_CONF_UNSET_SIZE;
+    lcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE;
     lcf->client_body_timeout = NGX_CONF_UNSET_MSEC;
     lcf->sendfile = NGX_CONF_UNSET;
     lcf->tcp_nopush = NGX_CONF_UNSET;
@@ -1261,6 +1269,8 @@
 
     ngx_conf_merge_size_value(conf->client_max_body_size,
                               prev->client_max_body_size, 10 * 1024 * 1024);
+    ngx_conf_merge_size_value(conf->client_body_buffer_size,
+                              prev->client_body_buffer_size, 8192);
     ngx_conf_merge_msec_value(conf->client_body_timeout,
                               prev->client_body_timeout, 60000);
     ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 3af3ed4..130106b 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -124,6 +124,7 @@
     size_t        client_max_body_size;    /* client_max_body_size */
     size_t        send_lowat;              /* send_lowat */
     size_t        discarded_buffer_size;   /* discarded_buffer_size */
+    size_t        client_body_buffer_size; /* client_body_buffer_size */
 
     ngx_msec_t    client_body_timeout;     /* client_body_timeout */
     ngx_msec_t    send_timeout;            /* send_timeout */
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index a316153..5e127e8 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -155,7 +155,6 @@
     ngx_chain_t       *bufs;
     ngx_hunk_t        *buf;
     size_t             rest;
-    size_t             buf_size;
     void             (*handler) (void *data); 
     void              *data;
 } ngx_http_request_body_t;
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index 9f1260c..c4aada5 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -11,10 +11,10 @@
 
 ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r)
 {
-    ssize_t       size;
-    ngx_hunk_t   *h;
-    ngx_chain_t  *cl;
-
+    ssize_t                    size;
+    ngx_hunk_t                *h;
+    ngx_chain_t               *cl;
+    ngx_http_core_loc_conf_t  *clcf;
 
     size = r->header_in->last - r->header_in->pos;
 
@@ -47,15 +47,18 @@
     }
 
 
+    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
     r->request_body->rest = r->headers_in.content_length_n - size;
 
     if (r->request_body->rest
-                < r->request_body->buf_size + (r->request_body->buf_size >> 2))
+                             < clcf->client_body_buffer_size
+                                        + (clcf->client_body_buffer_size >> 2))
     {
         size = r->request_body->rest;
 
     } else {
-        size = r->request_body->buf_size;
+        size = clcf->client_body_buffer_size;
     }
 
     ngx_test_null(r->request_body->buf, ngx_create_temp_hunk(r->pool, size),
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index 1091d75..5fa144f 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -62,7 +62,7 @@
     ngx_http_write_filter_commands,        /* module directives */
     NGX_HTTP_MODULE,                       /* module type */
     ngx_http_write_filter_init,            /* init module */
-    NULL                                   /* init child */
+    NULL                                   /* init process */
 };
 
 
@@ -82,7 +82,8 @@
                             sizeof(ngx_http_write_filter_ctx_t), NGX_ERROR);
     }
 
-    size = flush = 0;
+    size = 0;
+    flush = 0;
     last = 0;
     ll = &ctx->out;