Mercurial > hg > nginx-ranges
diff src/http/modules/ngx_http_range_filter_module.c @ 517:8fbdd980b527
Merge with current.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 13 Jul 2009 23:56:24 +0400 |
parents | 44a61c599bb2 499474178a11 |
children | e67b227c8dbb |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_range_filter_module.c +++ b/src/http/modules/ngx_http_range_filter_module.c @@ -222,7 +222,7 @@ ngx_http_range_header_filter(ngx_http_re } if (ngx_array_init(&ctx->ranges, r->pool, 1, sizeof(ngx_http_range_t)) - == NGX_ERROR) + != NGX_OK) { return NGX_ERROR; } @@ -234,6 +234,7 @@ ngx_http_range_header_filter(ngx_http_re ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module); r->headers_out.status = NGX_HTTP_PARTIAL_CONTENT; + r->headers_out.status_line.len = 0; if (ctx->ranges.nelts == 1) { return ngx_http_range_singlepart_header(r, ctx); @@ -490,6 +491,8 @@ ngx_http_range_multipart_header(ngx_http return NGX_ERROR; } + r->headers_out.content_type_lowcase = NULL; + /* "Content-Type: multipart/byteranges; boundary=0123456789" */ r->headers_out.content_type.len = @@ -498,6 +501,7 @@ ngx_http_range_multipart_header(ngx_http boundary) - r->headers_out.content_type.data; + r->headers_out.content_type_len = r->headers_out.content_type.len; /* the size of the last boundary CRLF "--0123456789--" CRLF */ @@ -748,6 +752,7 @@ ngx_http_range_multipart_body(ngx_http_r ngx_http_range_filter_ctx_t *ctx, ngx_chain_t *in, ngx_http_output_body_filter_pt ngx_http_next_body_filter) { + off_t body_start; ngx_buf_t *b, *buf; ngx_uint_t i; ngx_chain_t *out, *hcl, *rcl, *dcl, **ll; @@ -757,6 +762,12 @@ ngx_http_range_multipart_body(ngx_http_r buf = in->buf; range = ctx->ranges.elts; +#if (NGX_HTTP_CACHE) + body_start = r->cached ? r->cache->body_start : 0; +#else + body_start = 0; +#endif + for (i = 0; i < ctx->ranges.nelts; i++) { /* @@ -817,8 +828,8 @@ ngx_http_range_multipart_body(ngx_http_r b->file = buf->file; if (buf->in_file) { - b->file_pos = range[i].start; - b->file_last = range[i].end; + b->file_pos = body_start + range[i].start; + b->file_last = body_start + range[i].end; } if (ngx_buf_in_memory(buf)) {