Welcome! Log In Create A New Profile

Advanced

[nginx] slice module issue

June 19, 2017 02:26PM
Hi!

Have a look at the following example first.

server {
listen 80;

location / {
slice 10;
proxy_set_header Range $slice_range;
proxy_pass http://127.0.0.1:81;
}
}


server {
listen 81;
root html;
}

Then we start a request with curl.
> curl http://my.test.com/ -x 127.1:80 -H "range: bytes=1-50, 2-51"

We get a response of the whole file that differs from expectation (1-50,
2-51).

It seems that slice module doesn't support multi-range (separated by
commas),
but it's confused $slice_range variable is valid.

Please confirm this question and the following patch, thanks!


diff -r 5e05118678af src/http/modules/ngx_http_slice_filter_module.c
--- a/src/http/modules/ngx_http_slice_filter_module.c Mon May 29 23:33:38
2017 +0300
+++ b/src/http/modules/ngx_http_slice_filter_module.c Mon Jun 19 09:35:24
2017 -0400
@@ -389,6 +389,7 @@
ngx_http_variable_value_t *v, uintptr_t data)
{
u_char *p;
+ off_t start;
ngx_http_slice_ctx_t *ctx;
ngx_http_slice_loc_conf_t *slcf;

@@ -407,6 +408,13 @@
return NGX_OK;
}

+ start = ngx_http_slice_get_start(r);
+
+ if (start == -1) {
+ v->not_found = 1;
+ return NGX_OK;
+ }
+
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_slice_ctx_t));
if (ctx == NULL) {
return NGX_ERROR;
@@ -419,7 +427,7 @@
return NGX_ERROR;
}

- ctx->start = slcf->size * (ngx_http_slice_get_start(r) /
slcf->size);
+ ctx->start = slcf->size * (start / slcf->size);

ctx->range.data = p;
ctx->range.len = ngx_sprintf(p, "bytes=%O-%O", ctx->start,
@@ -460,7 +468,7 @@
p = h->value.data + 6;

if (ngx_strchr(p, ',')) {
- return 0;
+ return -1;
}

while (*p == ' ') { p++; }


And this is a better conf.

map $slice_range $x_slice_range {
default $http_range;
~ $slice_range;
}

server {
listen 80;

location / {
slice 10;
proxy_set_header Range $x_slice_range;
proxy_pass http://127.0.0.1:81;
}
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] slice module issue

karton 892 June 19, 2017 02:26PM

Re: [nginx] slice module issue

Roman Arutyunyan 345 June 20, 2017 08:10AM

Re: [nginx] slice module issue

karton 415 June 20, 2017 08:44AM

Re: [nginx] slice module issue

Roman Arutyunyan 297 June 20, 2017 09:36AM

Re: [nginx] slice module issue

karton 380 June 20, 2017 11:24AM

Re: [nginx] slice module issue

karton 366 June 20, 2017 11:48AM

Re: [nginx] slice module issue

Roman Arutyunyan 318 June 20, 2017 12:32PM

Re: [nginx] slice module issue

karton 378 June 20, 2017 12:46PM

Re: [nginx] slice module issue

karton 405 June 20, 2017 01:24PM

Re: [nginx] slice module issue

Roman Arutyunyan 331 June 20, 2017 02:46PM

Re: [nginx] slice module issue

karton 431 June 20, 2017 03:12PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 280
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready