If we wan't to slice in the case of multi-page, how to achieve it? 洪志道 <hongzhi...@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 <a...@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 <a...@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