Klaus Demo nginx / d2ad924
Merge of r4468: Removed r->cache/r->cached dependencies in range filter. This is a layering violation, use correct offset calculations instead. Maxim Dounin 8 years ago
1 changed file(s) with 6 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
594594 buf = in->buf;
595595
596596 if (!buf->last_buf) {
597
598 if (buf->in_file) {
599 start = buf->file_pos + ctx->offset;
600 last = buf->file_last + ctx->offset;
601
602 } else {
603 start = buf->pos - buf->start + ctx->offset;
604 last = buf->last - buf->start + ctx->offset;
605 }
597 start = ctx->offset;
598 last = ctx->offset + ngx_buf_size(buf);
606599
607600 range = ctx->ranges.elts;
608601 for (i = 0; i < ctx->ranges.nelts; i++) {
715708 ngx_http_range_multipart_body(ngx_http_request_t *r,
716709 ngx_http_range_filter_ctx_t *ctx, ngx_chain_t *in)
717710 {
718 off_t body_start;
719711 ngx_buf_t *b, *buf;
720712 ngx_uint_t i;
721713 ngx_chain_t *out, *hcl, *rcl, *dcl, **ll;
724716 ll = &out;
725717 buf = in->buf;
726718 range = ctx->ranges.elts;
727
728 #if (NGX_HTTP_CACHE)
729 body_start = r->cached ? r->cache->body_start : 0;
730 #else
731 body_start = 0;
732 #endif
733719
734720 for (i = 0; i < ctx->ranges.nelts; i++) {
735721
791777 b->file = buf->file;
792778
793779 if (buf->in_file) {
794 b->file_pos = body_start + range[i].start;
795 b->file_last = body_start + range[i].end;
780 b->file_pos = buf->file_pos + range[i].start;
781 b->file_last = buf->file_pos + range[i].end;
796782 }
797783
798784 if (ngx_buf_in_memory(buf)) {
799 b->pos = buf->start + (size_t) range[i].start;
800 b->last = buf->start + (size_t) range[i].end;
785 b->pos = buf->pos + (size_t) range[i].start;
786 b->last = buf->pos + (size_t) range[i].end;
801787 }
802788
803789 dcl = ngx_alloc_chain_link(r->pool);