summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2014-03-21 19:33:21 +0400
committerMaxim Dounin <mdounin@mdounin.ru>2014-03-21 19:33:21 +0400
commiteffbf466aa44df725a9f68761b2793065bba6756 (patch)
tree8231bd358e880f9b927634dfdfdad6846e913734 /src/http/modules
parentc6ca13592308badb125bdada372e33b4b24fd28c (diff)
downloadnginx-effbf466aa44df725a9f68761b2793065bba6756.tar.gz
nginx-effbf466aa44df725a9f68761b2793065bba6756.tar.bz2
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.
Diffstat (limited to 'src/http/modules')
-rw-r--r--src/http/modules/ngx_http_mp4_module.c2
-rw-r--r--src/http/modules/ngx_http_range_filter_module.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/src/http/modules/ngx_http_mp4_module.c b/src/http/modules/ngx_http_mp4_module.c
index 647dff457..d0a6a8e03 100644
--- a/src/http/modules/ngx_http_mp4_module.c
+++ b/src/http/modules/ngx_http_mp4_module.c
@@ -571,7 +571,7 @@ ngx_http_mp4_handler(ngx_http_request_t *r)
}
if (start >= 0) {
- r->allow_ranges = 0;
+ r->single_range = 1;
mp4 = ngx_pcalloc(r->pool, sizeof(ngx_http_mp4_file_t));
if (mp4 == NULL) {
diff --git a/src/http/modules/ngx_http_range_filter_module.c b/src/http/modules/ngx_http_range_filter_module.c
index bcc64fd30..6a65e4849 100644
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -148,6 +148,7 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
{
time_t if_range_time;
ngx_str_t *if_range, *etag;
+ ngx_uint_t ranges;
ngx_http_core_loc_conf_t *clcf;
ngx_http_range_filter_ctx_t *ctx;
@@ -227,7 +228,9 @@ parse:
return NGX_ERROR;
}
- switch (ngx_http_range_parse(r, ctx, clcf->max_ranges)) {
+ ranges = r->single_range ? 1 : clcf->max_ranges;
+
+ switch (ngx_http_range_parse(r, ctx, ranges)) {
case NGX_OK:
ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module);