nginx-0.0.1-2003-04-15-19:06:52 import
diff --git a/src/http/modules/proxy/ngx_http_event_proxy_handler.c b/src/http/modules/proxy/ngx_http_event_proxy_handler.c
index 3d76668..874295c 100644
--- a/src/http/modules/proxy/ngx_http_event_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_event_proxy_handler.c
@@ -871,7 +871,7 @@
         ep->number = 10;
         ep->random = 5;
 
-        ep->max_temp_size = 6000;
+        ep->max_temp_size = p->lcf->max_temp_file_size;
         ep->temp_file_warn = "an upstream response is buffered "
                              "to a temporary file";
 
@@ -1763,9 +1763,18 @@
     conf->send_timeout = 10000;
     conf->read_timeout = 10000;
     conf->header_size = 1024;
+
+#if 0
     conf->block_size = 4096;
     conf->max_block_size = 4096 * 3;
-    conf->file_block_size = 4096;
+    conf->max_temp_file_size = 4096 * 5;
+    conf->file_block_size = 4096 * 2;
+#else
+    conf->block_size = 2048;
+    conf->max_block_size = 4096 * 6;
+    conf->max_temp_file_size = 4096 * 5;
+    conf->file_block_size = 4096 * 5;
+#endif
 
     ngx_test_null(conf->temp_path, ngx_pcalloc(pool, sizeof(ngx_path_t)), NULL);
 
diff --git a/src/http/modules/proxy/ngx_http_event_proxy_handler.h b/src/http/modules/proxy/ngx_http_event_proxy_handler.h
index bf159d6..f0fcd97 100644
--- a/src/http/modules/proxy/ngx_http_event_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_event_proxy_handler.h
@@ -71,6 +71,7 @@
 
     int   block_size;
     int   max_block_size;
+    int   max_temp_file_size;
     int   file_block_size;
 
     ngx_path_t  *temp_path;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 310f940..3ae8017 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -157,7 +157,7 @@
 
     r->connection->unexpected_eof = 0;
 
-    r->keepalive = 1;
+    r->keepalive = 0;
     r->lingering_close = 1;
 
 #if 0
diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c
index 426e921..485aae3 100644
--- a/src/http/ngx_http_output_filter.c
+++ b/src/http/ngx_http_output_filter.c
@@ -65,7 +65,7 @@
 
 #define need_to_copy(r, hunk)                                             \
             (((r->filter & NGX_HTTP_FILTER_NEED_IN_MEMORY)                \
-               && (hunk->type & NGX_HUNK_FILE))                           \
+               && (hunk->type & NGX_HUNK_IN_MEMORY) == 0)                 \
              || ((r->filter & NGX_HTTP_FILTER_NEED_TEMP)                  \
                   && (hunk->type & (NGX_HUNK_MEMORY|NGX_HUNK_MMAP))))
 
@@ -257,12 +257,12 @@
     }
 
     if (src->type & NGX_HUNK_IN_MEMORY) {
-        ngx_memcpy(src->pos, dst->pos, size);
+        ngx_memcpy(dst->pos, src->pos, size);
         src->pos += size;
         dst->last += size;
 
         if (src->type & NGX_HUNK_FILE) {
-            src->file_pos += n;
+            src->file_pos += size;
         }
 
         if ((src->type & NGX_HUNK_LAST) && src->pos == src->last) {