changeset 2:13a2fbcc8bc4

Change Content-Length to match total requested length.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 29 Jun 2008 04:24:19 +0400
parents 6b995d5251ec
children 3e8648918913
files ngx_http_bytes_filter_module.c
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ngx_http_bytes_filter_module.c	Sat Jun 28 20:20:50 2008 +0400
+++ b/ngx_http_bytes_filter_module.c	Sun Jun 29 04:24:19 2008 +0400
@@ -83,7 +83,7 @@
 ngx_http_bytes_header_filter(ngx_http_request_t *r)
 {
     u_char                 *p, *last;
-    off_t                   start, end;
+    off_t                   start, end, len;
     ngx_uint_t              suffix, bad;
     ngx_http_bytes_t       *range;
     ngx_http_bytes_conf_t  *conf;
@@ -134,6 +134,7 @@
      */
 
     bad = 0;
+    len = 0;
 
     while (p < last) {
 
@@ -213,6 +214,7 @@
 
             range->start = start;
             range->end = end + 1;
+            len += range->end - range->start;
 
             if (*p == ',') {
                 p++;
@@ -251,6 +253,7 @@
 
         range->start = start;
         range->end = end + 1;
+        len += range->end - range->start;
 
         break;
 
@@ -262,10 +265,14 @@
     }
 
 done:
-    /* ... fix content-length */
+    r->headers_out.content_length_n = len;
 
     ngx_http_set_ctx(r, ctx, ngx_http_bytes_filter_module);
 
+    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                   "bytes header filter: new length %O",
+                   r->headers_out.content_length_n);
+
     return ngx_http_next_header_filter(r);
 }