# HG changeset patch # User Piotr Sikora <pi...@cloudflare.com> # Date 1416359232 28800 # Tue Nov 18 17:07:12 2014 -0800 # Node ID 3efade6bb02f7962a5120e1a1f95a1dc8f0b6a4c # Parent 2f7e557eab5b501ba71418febd3de9ef1c0ab4f1 Not Modified: prefer entity tags over date validators.
RFC7232 says: A recipient MUST ignore If-Modified-Since if the request contains an If-None-Match header field; the condition in If-None-Match is considered to be a more accurate replacement for the condition in If-Modified-Since, and the two are only combined for the sake of interoperating with older intermediaries that might not implement If-None-Match. and: A recipient MUST ignore If-Unmodified-Since if the request contains an If-Match header field; the condition in If-Match is considered to be a more accurate replacement for the condition in If-Unmodified-Since, and the two are only combined for the sake of interoperating with older intermediaries that might not implement If-Match. Signed-off-by: Piotr Sikora <pi...@cloudflare.com> diff -r 2f7e557eab5b -r 3efade6bb02f src/http/modules/ngx_http_not_modified_filter_module.c --- a/src/http/modules/ngx_http_not_modified_filter_module.c Tue Nov 18 20:41:12 2014 +0300 +++ b/src/http/modules/ngx_http_not_modified_filter_module.c Tue Nov 18 17:07:12 2014 -0800 @@ -61,48 +61,47 @@ ngx_http_not_modified_header_filter(ngx_ return ngx_http_next_header_filter(r); } - if (r->headers_in.if_unmodified_since - && !ngx_http_test_if_unmodified(r)) - { - return ngx_http_filter_finalize_request(r, NULL, - NGX_HTTP_PRECONDITION_FAILED); + if (r->headers_in.if_match) { + + if (!ngx_http_test_if_match(r, r->headers_in.if_match, 0)) { + return ngx_http_filter_finalize_request(r, NULL, + NGX_HTTP_PRECONDITION_FAILED); + } + + } else if (r->headers_in.if_unmodified_since) { + + if (!ngx_http_test_if_unmodified(r)) { + return ngx_http_filter_finalize_request(r, NULL, + NGX_HTTP_PRECONDITION_FAILED); + } } - if (r->headers_in.if_match - && !ngx_http_test_if_match(r, r->headers_in.if_match, 0)) - { - return ngx_http_filter_finalize_request(r, NULL, - NGX_HTTP_PRECONDITION_FAILED); + if (r->headers_in.if_none_match) { + + if (ngx_http_test_if_match(r, r->headers_in.if_none_match, 1)) { + goto not_modified; + } + + } else if (r->headers_in.if_modified_since) { + + if (!ngx_http_test_if_modified(r)) { + goto not_modified; + } } - if (r->headers_in.if_modified_since || r->headers_in.if_none_match) { + return ngx_http_next_header_filter(r); - if (r->headers_in.if_modified_since - && ngx_http_test_if_modified(r)) - { - return ngx_http_next_header_filter(r); - } +not_modified: - if (r->headers_in.if_none_match - && !ngx_http_test_if_match(r, r->headers_in.if_none_match, 1)) - { - return ngx_http_next_header_filter(r); - } + r->headers_out.status = NGX_HTTP_NOT_MODIFIED; + r->headers_out.status_line.len = 0; + r->headers_out.content_type.len = 0; + ngx_http_clear_content_length(r); + ngx_http_clear_accept_ranges(r); - /* not modified */ - - r->headers_out.status = NGX_HTTP_NOT_MODIFIED; - r->headers_out.status_line.len = 0; - r->headers_out.content_type.len = 0; - ngx_http_clear_content_length(r); - ngx_http_clear_accept_ranges(r); - - if (r->headers_out.content_encoding) { - r->headers_out.content_encoding->hash = 0; - r->headers_out.content_encoding = NULL; - } - - return ngx_http_next_header_filter(r); + if (r->headers_out.content_encoding) { + r->headers_out.content_encoding->hash = 0; + r->headers_out.content_encoding = NULL; } return ngx_http_next_header_filter(r); _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel