Welcome! Log In Create A New Profile

Advanced

Re: [nginx] slice module issue

Roman Arutyunyan
June 20, 2017 12:32PM
You can pass a mapped variable to "proxy_set_header Range" which falls back
to whatever you want for multi-range requests.

On Tue, Jun 20, 2017 at 03:47:02PM +0000, 洪志道 wrote:
> If we wan't to slice in the case of multi-page, how to achieve it?
>
> 洪志道 <hongzhidao@gmail.com>于2017年6月20日 周二23:21写道:
>
> > You said the module doesn't support multi-range, it means nothing to
> > support slice feature through $slice_range.
> > Anyway we can avoid it by access handle, but it's still unconvinient.
> >
> > Roman Arutyunyan <arut@nginx.com>于2017年6月20日 周二21:34写道:
> >
> >> That would disable slicing at all.
> >>
> >> On Tue, Jun 20, 2017 at 12:42:30PM +0000, 洪志道 wrote:
> >> > Do you think it's better to set $slice_range not found as if multi-range
> >> > request?
> >> >
> >> > Roman Arutyunyan <arut@nginx.com>于2017年6月20日 周二20:09写道:
> >> >
> >> > > Hi,
> >> > >
> >> > > On Tue, Jun 20, 2017 at 02:25:14AM +0800, 洪志道 wrote:
> >> > > > 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),
> >> > >
> >> > > Yes, the slice module does not support multi-range.
> >> > > The entire file is proxied and processed by the standard range module,
> >> > > which has limited multi-range support too. Particularly, multi-range
> >> is
> >> > > supported only when returning an entire file from disk.
> >> > >
> >> > > > 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
> >> > >
> >> > >
> >> > > --
> >> > > Roman Arutyunyan
> >> > > _______________________________________________
> >> > > nginx-devel mailing list
> >> > > nginx-devel@nginx.org
> >> > > http://mailman.nginx.org/mailman/listinfo/nginx-devel
> >>
> >> > _______________________________________________
> >> > nginx-devel mailing list
> >> > nginx-devel@nginx.org
> >> > http://mailman.nginx.org/mailman/listinfo/nginx-devel
> >>
> >>
> >> --
> >> Roman Arutyunyan
> >> _______________________________________________
> >> nginx-devel mailing list
> >> nginx-devel@nginx.org
> >> http://mailman.nginx.org/mailman/listinfo/nginx-devel
> >
> >

> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel


--
Roman Arutyunyan
_______________________________________________
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 901 June 19, 2017 02:26PM

Re: [nginx] slice module issue

Roman Arutyunyan 349 June 20, 2017 08:10AM

Re: [nginx] slice module issue

karton 421 June 20, 2017 08:44AM

Re: [nginx] slice module issue

Roman Arutyunyan 301 June 20, 2017 09:36AM

Re: [nginx] slice module issue

karton 385 June 20, 2017 11:24AM

Re: [nginx] slice module issue

karton 370 June 20, 2017 11:48AM

Re: [nginx] slice module issue

Roman Arutyunyan 321 June 20, 2017 12:32PM

Re: [nginx] slice module issue

karton 383 June 20, 2017 12:46PM

Re: [nginx] slice module issue

karton 412 June 20, 2017 01:24PM

Re: [nginx] slice module issue

Roman Arutyunyan 335 June 20, 2017 02:46PM

Re: [nginx] slice module issue

karton 435 June 20, 2017 03:12PM



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

Online Users

Guests: 163
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