diff src/http/modules/ngx_http_range_filter_module.c @ 464:c8cfb6c462ef NGINX_0_7_44

nginx 0.7.44 *) Feature: the ngx_http_proxy_module preliminary cache support. *) Feature: the --with-pcre option in the configure. *) Feature: the "try_files" directive is now allowed on the server block level. *) Bugfix: the "try_files" directive handled incorrectly a query string in a fallback parameter. *) Bugfix: the "try_files" directive might test incorrectly directories. *) Bugfix: if there is the single server for given address:port pair, then captures in regular expressions in a "server_name" directive did not work.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 Mar 2009 00:00:00 +0300
parents a8424ffa495c
children 499474178a11
line wrap: on
line diff
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -199,6 +199,7 @@ ngx_http_range_header_filter(ngx_http_re
         ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module);
 
         r->headers_out.status = NGX_HTTP_PARTIAL_CONTENT;
+        r->headers_out.status_line.len = 0;
 
         if (ctx->ranges.nelts == 1) {
             return ngx_http_range_singlepart_header(r, ctx);
@@ -708,6 +709,7 @@ static ngx_int_t
 ngx_http_range_multipart_body(ngx_http_request_t *r,
     ngx_http_range_filter_ctx_t *ctx, ngx_chain_t *in)
 {
+    off_t              body_start;
     ngx_buf_t         *b, *buf;
     ngx_uint_t         i;
     ngx_chain_t       *out, *hcl, *rcl, *dcl, **ll;
@@ -717,6 +719,12 @@ ngx_http_range_multipart_body(ngx_http_r
     buf = in->buf;
     range = ctx->ranges.elts;
 
+#if (NGX_HTTP_CACHE)
+    body_start = r->cached ? r->cache->body_start : 0;
+#else
+    body_start = 0;
+#endif
+
     for (i = 0; i < ctx->ranges.nelts; i++) {
 
         /*
@@ -777,8 +785,8 @@ ngx_http_range_multipart_body(ngx_http_r
         b->file = buf->file;
 
         if (buf->in_file) {
-            b->file_pos = range[i].start;
-            b->file_last = range[i].end;
+            b->file_pos = body_start + range[i].start;
+            b->file_last = body_start + range[i].end;
         }
 
         if (ngx_buf_in_memory(buf)) {