Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
If-Range support
Здравствуйте.
Скажите, пожалуйста, возможно ли поддержать
заголовок If-Range в nginx? Возникшую потребность
в этом заголовке я решил с помощью присоединённого
патча (относительно версии 0.5.30), но может быть
есть какой-нибудь более подходящий способ?
Спасибо.
diff --git a/src/http/modules/ngx_http_range_filter_module.c
b/src/http/modules/ngx_http_range_filter_module.c
index 11da43d..7eb248f 100644
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -150,6 +150,20 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
return ngx_http_next_header_filter(r);
}
+ if (r->headers_in.if_range != NULL
+ && r->headers_out.last_modified_time != -1)
+ {
+ time_t ir;
+ ir = ngx_http_parse_time(r->headers_in.if_range->value.data,
+ r->headers_in.if_range->value.len);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http ir:%d lm:%d", ir,
r->headers_out.last_modified_time);
+ if (ir != r->headers_out.last_modified_time)
+ {
+ return ngx_http_next_header_filter(r);
+ }
+ }
+
if (r->headers_in.range == NULL
|| r->headers_in.range->value.len < 7
|| ngx_strncasecmp(r->headers_in.range->value.data,
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 0306bf6..8b9bfbe 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -77,6 +77,10 @@ ngx_http_header_t ngx_http_headers_in[] = {
offsetof(ngx_http_headers_in_t, if_modified_since),
ngx_http_process_header_line },
+ { ngx_string("If-Range"),
+ offsetof(ngx_http_headers_in_t, if_range),
+ ngx_http_process_header_line },
+
{ ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent),
ngx_http_process_header_line },
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index a380ac0..8e567bf 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -162,6 +162,7 @@ typedef struct {
ngx_table_elt_t *host;
ngx_table_elt_t *connection;
ngx_table_elt_t *if_modified_since;
+ ngx_table_elt_t *if_range;
ngx_table_elt_t *user_agent;
ngx_table_elt_t *referer;
ngx_table_elt_t *content_length;
|