diff options
author | Igor Sysoev <igor@sysoev.ru> | 2011-08-30 12:45:24 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2011-08-30 12:45:24 +0000 |
commit | 584703b84a3dff36e7127c555248f9d024179f06 (patch) | |
tree | dca31d55843da2526d8de159aa76c618b0d63056 /src | |
parent | f2575bd8782e4709d8a75cfd6c095b4ffa1fcaaa (diff) | |
download | nginx-584703b84a3dff36e7127c555248f9d024179f06.tar.gz nginx-584703b84a3dff36e7127c555248f9d024179f06.zip |
Ranges processing small optimization.
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_range_filter_module.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/src/http/modules/ngx_http_range_filter_module.c b/src/http/modules/ngx_http_range_filter_module.c index 05d64a0d5..c0a835c3e 100644 --- a/src/http/modules/ngx_http_range_filter_module.c +++ b/src/http/modules/ngx_http_range_filter_module.c @@ -270,20 +270,8 @@ ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx) while (*p == ' ') { p++; } if (*p == ',' || *p == '\0') { - range = ngx_array_push(&ctx->ranges); - if (range == NULL) { - return NGX_ERROR; - } - - range->start = start; - range->end = r->headers_out.content_length_n; - size += range->end - start; - - if (*p++ != ',') { - break; - } - - continue; + end = r->headers_out.content_length_n; + goto found; } } else { @@ -314,25 +302,28 @@ ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx) return NGX_HTTP_RANGE_NOT_SATISFIABLE; } - range = ngx_array_push(&ctx->ranges); - if (range == NULL) { - return NGX_ERROR; - } - - range->start = start; - if (end >= r->headers_out.content_length_n) { /* * Download Accelerator sends the last byte position * that equals to the file length */ - range->end = r->headers_out.content_length_n; + end = r->headers_out.content_length_n; } else { - range->end = end + 1; + end++; } - size += range->end - start; + found: + + range = ngx_array_push(&ctx->ranges); + if (range == NULL) { + return NGX_ERROR; + } + + range->start = start; + range->end = end; + + size += end - start; if (*p++ != ',') { break; |