Changeset 5621:345e4fd4bb64 in nginx


Ignore:
Timestamp:
03/21/14 15:33:21 (4 years ago)
Author:
Maxim Dounin <mdounin@…>
Branch:
default
Message:

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.

Location:
src/http
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/http/modules/ngx_http_mp4_module.c

    r5620 r5621  
    572572
    573573    if (start >= 0) {
    574         r->allow_ranges = 0;
     574        r->single_range = 1;
    575575
    576576        mp4 = ngx_pcalloc(r->pool, sizeof(ngx_http_mp4_file_t));
  • src/http/modules/ngx_http_range_filter_module.c

    r5558 r5621  
    149149    time_t                        if_range_time;
    150150    ngx_str_t                    *if_range, *etag;
     151    ngx_uint_t                    ranges;
    151152    ngx_http_core_loc_conf_t     *clcf;
    152153    ngx_http_range_filter_ctx_t  *ctx;
     
    228229    }
    229230
    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)) {
    231234
    232235    case NGX_OK:
  • src/http/ngx_http_request.h

    r5605 r5621  
    529529    unsigned                          filter_need_temporary:1;
    530530    unsigned                          allow_ranges:1;
     531    unsigned                          single_range:1;
    531532
    532533#if (NGX_STAT_STUB)
  • src/http/ngx_http_upstream.c

    r5581 r5621  
    41844184        r->allow_ranges = 1;
    41854185        return NGX_OK;
    4186 
     4186    }
     4187
     4188    if (r->upstream->cacheable) {
     4189        r->allow_ranges = 1;
     4190        r->single_range = 1;
     4191        return NGX_OK;
    41874192    }
    41884193
Note: See TracChangeset for help on using the changeset viewer.