mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
Ranges processing small optimization.
This commit is contained in:
parent
f2575bd878
commit
584703b84a
@ -270,20 +270,8 @@ ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx)
|
|||||||
while (*p == ' ') { p++; }
|
while (*p == ' ') { p++; }
|
||||||
|
|
||||||
if (*p == ',' || *p == '\0') {
|
if (*p == ',' || *p == '\0') {
|
||||||
range = ngx_array_push(&ctx->ranges);
|
end = r->headers_out.content_length_n;
|
||||||
if (range == NULL) {
|
goto found;
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
range->start = start;
|
|
||||||
range->end = r->headers_out.content_length_n;
|
|
||||||
size += range->end - start;
|
|
||||||
|
|
||||||
if (*p++ != ',') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} 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;
|
return NGX_HTTP_RANGE_NOT_SATISFIABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (end >= r->headers_out.content_length_n) {
|
||||||
|
/*
|
||||||
|
* Download Accelerator sends the last byte position
|
||||||
|
* that equals to the file length
|
||||||
|
*/
|
||||||
|
end = r->headers_out.content_length_n;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
end++;
|
||||||
|
}
|
||||||
|
|
||||||
|
found:
|
||||||
|
|
||||||
range = ngx_array_push(&ctx->ranges);
|
range = ngx_array_push(&ctx->ranges);
|
||||||
if (range == NULL) {
|
if (range == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
range->start = start;
|
range->start = start;
|
||||||
|
range->end = end;
|
||||||
|
|
||||||
if (end >= r->headers_out.content_length_n) {
|
size += end - start;
|
||||||
/*
|
|
||||||
* Download Accelerator sends the last byte position
|
|
||||||
* that equals to the file length
|
|
||||||
*/
|
|
||||||
range->end = r->headers_out.content_length_n;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
range->end = end + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
size += range->end - start;
|
|
||||||
|
|
||||||
if (*p++ != ',') {
|
if (*p++ != ',') {
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user