]> git.kaiwu.me - nginx.git/commitdiff
Range filter: only initialize ctx->ranges in main request.
authorhucongcong <hucong.c@foxmail.com>
Thu, 10 Nov 2016 02:44:52 +0000 (10:44 +0800)
committerhucongcong <hucong.c@foxmail.com>
Thu, 10 Nov 2016 02:44:52 +0000 (10:44 +0800)
It is not necessary to initialize ctx->ranges in all request, because
ctx->ranges in subrequest will be reassigned to ctx->ranges of main
request.

src/http/modules/ngx_http_range_filter_module.c

index 095ef0621b7ad6e1c593184b9f974280047e43f8..951a00de1ea90e0d5282c5a7909f09e641813a38 100644 (file)
@@ -224,12 +224,6 @@ parse:
 
     ctx->offset = r->headers_out.content_offset;
 
-    if (ngx_array_init(&ctx->ranges, r->pool, 1, sizeof(ngx_http_range_t))
-        != NGX_OK)
-    {
-        return NGX_ERROR;
-    }
-
     ranges = r->single_range ? 1 : clcf->max_ranges;
 
     switch (ngx_http_range_parse(r, ctx, ranges)) {
@@ -291,6 +285,12 @@ ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx,
         }
     }
 
+    if (ngx_array_init(&ctx->ranges, r->pool, 1, sizeof(ngx_http_range_t))
+        != NGX_OK)
+    {
+        return NGX_ERROR;
+    }
+
     p = r->headers_in.range->value.data + 6;
     size = 0;
     content_length = r->headers_out.content_length_n;