Mercurial > hg > nginx-vendor-current
diff src/http/modules/ngx_http_range_filter_module.c @ 680:597573166f34 NGINX_1_3_3
nginx 1.3.3
*) Feature: entity tags support and the "etag" directive.
*) Bugfix: trailing dot in a source value was not ignored if the "map"
directive was used with the "hostnames" parameter.
*) Bugfix: incorrect location might be used to process a request if a
URI was changed via a "rewrite" directive before an internal redirect
to a named location.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 10 Jul 2012 00:00:00 +0400 |
parents | e5fa0a4a7d27 |
children |
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 @@ -146,7 +146,8 @@ static ngx_http_output_body_filter_pt static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r) { - time_t if_range; + time_t if_range_time; + ngx_str_t *if_range, *etag; ngx_http_core_loc_conf_t *clcf; ngx_http_range_filter_ctx_t *ctx; @@ -174,20 +175,47 @@ ngx_http_range_header_filter(ngx_http_re goto next_filter; } - if (r->headers_in.if_range && r->headers_out.last_modified_time != -1) { + if (r->headers_in.if_range) { + + if_range = &r->headers_in.if_range->value; + + if (if_range->len >= 2 && if_range->data[if_range->len - 1] == '"') { + + if (r->headers_out.etag == NULL) { + goto next_filter; + } + + etag = &r->headers_out.etag->value; + + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http ir:%V etag:%V", if_range, etag); - if_range = ngx_http_parse_time(r->headers_in.if_range->value.data, - r->headers_in.if_range->value.len); + if (if_range->len != etag->len + || ngx_strncmp(if_range->data, etag->data, etag->len) != 0) + { + goto next_filter; + } + + goto parse; + } + + if (r->headers_out.last_modified_time == (time_t) -1) { + goto next_filter; + } + + if_range_time = ngx_http_parse_time(if_range->data, if_range->len); ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http ir:%d lm:%d", - if_range, r->headers_out.last_modified_time); + if_range_time, r->headers_out.last_modified_time); - if (if_range != r->headers_out.last_modified_time) { + if (if_range_time != r->headers_out.last_modified_time) { goto next_filter; } } +parse: + ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_range_filter_ctx_t)); if (ctx == NULL) { return NGX_ERROR;