diff src/http/modules/ngx_http_static_handler.c @ 61:4f3e2abcc2c4

nginx-0.0.1-2003-02-11-19:42:23 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 11 Feb 2003 16:42:23 +0000
parents e8cdc2989cee
children 36d2c25cc9bb
line wrap: on
line diff
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -141,6 +141,8 @@ int ngx_http_static_handler(ngx_http_req
     if (r->header_only)
         return rc;
 
+#if 0
+
     h->type = NGX_HUNK_FILE|NGX_HUNK_LAST;
     h->pos.file = 0;
     h->last.file = ngx_file_size(r->file.info);
@@ -152,5 +154,42 @@ int ngx_http_static_handler(ngx_http_req
 
     ngx_log_debug(r->connection->log, "0 output_filter: %d" _ rc);
 
+#else
+
+#define BLK 10000
+
+    {
+    int  i, s;
+    s = ngx_file_size(r->file.info);
+
+    for (i = 0; i < s; i += BLK) {
+        ngx_test_null(h, ngx_pcalloc(r->pool, sizeof(ngx_hunk_t)),
+                      NGX_HTTP_INTERNAL_SERVER_ERROR);
+
+        ngx_test_null(h->file, ngx_pcalloc(r->pool, sizeof(ngx_file_t)),
+                      NGX_HTTP_INTERNAL_SERVER_ERROR);
+
+        h->type = NGX_HUNK_FILE;
+        if (s - i <= BLK) {
+            h->type |= NGX_HUNK_LAST;
+        }
+
+        h->pos.file = i;
+        h->last.file = i + BLK;
+        if (h->last.file > s) {
+            h->last.file = s;
+        }
+
+        h->file->fd = r->file.fd;
+        h->file->log = r->connection->log;
+
+        rc = ngx_http_output_filter(r, h);
+
+        ngx_log_debug(r->connection->log, "0 output_filter: %d" _ rc);
+    }
+    }
+
+#endif
+
     return rc;
 }