[nginx] svn commit: r4746 - trunk/src/http/modules

mdounin at mdounin.ru mdounin at mdounin.ru
Sat Jul 7 21:21:16 UTC 2012


Author: mdounin
Date: 2012-07-07 21:21:15 +0000 (Sat, 07 Jul 2012)
New Revision: 4746
URL: http://trac.nginx.org/nginx/changeset/4746/nginx

Log:
Entity tags: support in If-Range header.


Modified:
   trunk/src/http/modules/ngx_http_range_filter_module.c

Modified: trunk/src/http/modules/ngx_http_range_filter_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_range_filter_module.c	2012-07-07 21:20:27 UTC (rev 4745)
+++ trunk/src/http/modules/ngx_http_range_filter_module.c	2012-07-07 21:21:15 UTC (rev 4746)
@@ -146,7 +146,8 @@
 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 @@
 
     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;



More information about the nginx-devel mailing list