summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2011-08-30 13:06:12 +0000
committerIgor Sysoev <igor@sysoev.ru>2011-08-30 13:06:12 +0000
commit9162057731da9b8e731316a4e49a2cdf29a3dd31 (patch)
tree6f6cd4a0bbd69a05603273c07a6cdb49a8605d9d /src
parent451df22b3f07d4e11ea8b32cc932630ae383d280 (diff)
downloadnginx-9162057731da9b8e731316a4e49a2cdf29a3dd31.tar.gz
nginx-9162057731da9b8e731316a4e49a2cdf29a3dd31.tar.bz2
Ranges processing small optimization.
Diffstat (limited to 'src')
-rw-r--r--src/http/modules/ngx_http_range_filter_module.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/http/modules/ngx_http_range_filter_module.c b/src/http/modules/ngx_http_range_filter_module.c
index 6b45e2bea..52e45ae45 100644
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -234,12 +234,13 @@ ngx_int_t
ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx)
{
u_char *p;
- off_t start, end, size;
+ off_t start, end, size, content_length;
ngx_uint_t suffix;
ngx_http_range_t *range;
p = r->headers_in.range->value.data + 6;
size = 0;
+ content_length = r->headers_out.content_length_n;
for ( ;; ) {
start = 0;
@@ -263,14 +264,14 @@ ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx)
return NGX_HTTP_RANGE_NOT_SATISFIABLE;
}
- if (start >= r->headers_out.content_length_n) {
+ if (start >= content_length) {
goto skip;
}
while (*p == ' ') { p++; }
if (*p == ',' || *p == '\0') {
- end = r->headers_out.content_length_n;
+ end = content_length;
goto found;
}
@@ -294,16 +295,16 @@ ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx)
}
if (suffix) {
- start = r->headers_out.content_length_n - end;
- end = r->headers_out.content_length_n - 1;
+ start = content_length - end;
+ end = content_length - 1;
}
if (start > end) {
goto skip;
}
- if (end >= r->headers_out.content_length_n) {
- end = r->headers_out.content_length_n;
+ if (end >= content_length) {
+ end = content_length;
} else {
end++;
@@ -332,7 +333,7 @@ ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx)
return NGX_HTTP_RANGE_NOT_SATISFIABLE;
}
- if (size > r->headers_out.content_length_n) {
+ if (size > content_length) {
return NGX_DECLINED;
}