diff src/http/modules/ngx_http_not_modified_filter_module.c @ 384:09b703ae3ba5 NGINX_0_6_36

nginx 0.6.36 *) Change: now the "Invalid argument" error returned by setsockopt(TCP_NODELAY) on Solaris, is ignored. *) Change: now POSTs without "Content-Length" header line are allowed. *) Feature: the "try_files" directive. *) Feature: the --with-pcre option in the configure. *) Feature: the "if_modified_since" directive. *) Feature: the "$cookie_..." variables. *) Feature: the "$arg_..." variables. *) Bugfix: compatibility with Tru64 UNIX. Thanks to Dustin Marquess. *) Bugfix: a "ssl_engine" directive did not use a SSL-accelerator for asymmetric ciphers. Thanks to Marcin Gozdalik. *) Bugfix: in a redirect rewrite directive original arguments were concatenated with new arguments by a "?" rather than an "&"; the bug had appeared in 0.1.18. Thanks to Maxim Dounin. *) Bugfix: nginx could not be built on AIX. *) Bugfix: a double response might be returned if the epoll or rtsig methods are used and a redirect was returned to a request with body. Thanks to Eden Li. *) Bugfix: a segmentation fault might occur in worker process if "resolver" directive was used in SMTP proxy. *) Bugfix: fastcgi_store stored files not always. *) Bugfix: nginx did not process a FastCGI server response, if the server send too many messages to stderr before response.
author Igor Sysoev <http://sysoev.ru>
date Thu, 02 Apr 2009 00:00:00 +0400
parents 05693816539c
children
line wrap: on
line diff
--- a/src/http/modules/ngx_http_not_modified_filter_module.c
+++ b/src/http/modules/ngx_http_not_modified_filter_module.c
@@ -50,7 +50,8 @@ static ngx_http_output_header_filter_pt 
 static
 ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
 {
-    time_t  ims;
+    time_t                     ims;
+    ngx_http_core_loc_conf_t  *clcf;
 
     if (r->headers_out.status != NGX_HTTP_OK
         || r != r->main
@@ -60,23 +61,32 @@ ngx_int_t ngx_http_not_modified_header_f
         return ngx_http_next_header_filter(r);
     }
 
+    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
+    if (clcf->if_modified_since == NGX_HTTP_IMS_OFF) {
+        return ngx_http_next_header_filter(r);
+    }
+
     ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data,
                               r->headers_in.if_modified_since->value.len);
 
     ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                    "http ims:%d lm:%d", ims, r->headers_out.last_modified_time);
 
-    /*
-     * I think that the equality of the dates is correcter
-     */
+    if (ims != r->headers_out.last_modified_time) {
 
-    if (ims == r->headers_out.last_modified_time) {
-        r->headers_out.status = NGX_HTTP_NOT_MODIFIED;
-        r->headers_out.content_type.len = 0;
-        ngx_http_clear_content_length(r);
-        ngx_http_clear_accept_ranges(r);
+        if (clcf->if_modified_since == NGX_HTTP_IMS_EXACT
+            || ims < r->headers_out.last_modified_time)
+        {
+            return ngx_http_next_header_filter(r);
+        }
     }
 
+    r->headers_out.status = NGX_HTTP_NOT_MODIFIED;
+    r->headers_out.content_type.len = 0;
+    ngx_http_clear_content_length(r);
+    ngx_http_clear_accept_ranges(r);
+
     return ngx_http_next_header_filter(r);
 }