mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
Entity tags: support in If-Range header.
This commit is contained in:
parent
13eb6898aa
commit
9c17e4cb66
@ -146,7 +146,8 @@ static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
||||
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;
|
||||
|
||||
@ -176,22 +177,45 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
|
||||
|
||||
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 (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 = ngx_http_parse_time(r->headers_in.if_range->value.data,
|
||||
r->headers_in.if_range->value.len);
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user