Mercurial > hg > nginx
comparison src/http/modules/ngx_http_range_filter_module.c @ 5621:345e4fd4bb64
Range filter: single_range flag in request.
If set, it means that response body is going to be in more than one buffer,
hence only range requests with a single range should be honored.
The flag is now used by mp4 and cacheable upstream responses, thus allowing
range requests of mp4 files with start/end, as well as range processing
on a first request to a not-yet-cached files with proxy_cache.
Notably this makes it possible to play mp4 files (with proxy_cache, or with
mp4 module) on iOS devices, as byte-range support is required by Apple.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 21 Mar 2014 19:33:21 +0400 |
parents | eeb3c2719147 |
children | 9653092a79fd |
comparison
equal
deleted
inserted
replaced
5620:0a567878254b | 5621:345e4fd4bb64 |
---|---|
146 static ngx_int_t | 146 static ngx_int_t |
147 ngx_http_range_header_filter(ngx_http_request_t *r) | 147 ngx_http_range_header_filter(ngx_http_request_t *r) |
148 { | 148 { |
149 time_t if_range_time; | 149 time_t if_range_time; |
150 ngx_str_t *if_range, *etag; | 150 ngx_str_t *if_range, *etag; |
151 ngx_uint_t ranges; | |
151 ngx_http_core_loc_conf_t *clcf; | 152 ngx_http_core_loc_conf_t *clcf; |
152 ngx_http_range_filter_ctx_t *ctx; | 153 ngx_http_range_filter_ctx_t *ctx; |
153 | 154 |
154 if (r->http_version < NGX_HTTP_VERSION_10 | 155 if (r->http_version < NGX_HTTP_VERSION_10 |
155 || r->headers_out.status != NGX_HTTP_OK | 156 || r->headers_out.status != NGX_HTTP_OK |
225 != NGX_OK) | 226 != NGX_OK) |
226 { | 227 { |
227 return NGX_ERROR; | 228 return NGX_ERROR; |
228 } | 229 } |
229 | 230 |
230 switch (ngx_http_range_parse(r, ctx, clcf->max_ranges)) { | 231 ranges = r->single_range ? 1 : clcf->max_ranges; |
232 | |
233 switch (ngx_http_range_parse(r, ctx, ranges)) { | |
231 | 234 |
232 case NGX_OK: | 235 case NGX_OK: |
233 ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module); | 236 ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module); |
234 | 237 |
235 r->headers_out.status = NGX_HTTP_PARTIAL_CONTENT; | 238 r->headers_out.status = NGX_HTTP_PARTIAL_CONTENT; |