Mercurial > hg > nginx
comparison src/http/modules/ngx_http_not_modified_filter_module.c @ 2640:a69e3766f698 stable-0.6
r2362, r2497 merge:
if_modified_since
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 01 Apr 2009 15:58:21 +0000 |
parents | b67b75bb09b7 |
children |
comparison
equal
deleted
inserted
replaced
2639:8deee4408c94 | 2640:a69e3766f698 |
---|---|
48 | 48 |
49 | 49 |
50 static | 50 static |
51 ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r) | 51 ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r) |
52 { | 52 { |
53 time_t ims; | 53 time_t ims; |
54 ngx_http_core_loc_conf_t *clcf; | |
54 | 55 |
55 if (r->headers_out.status != NGX_HTTP_OK | 56 if (r->headers_out.status != NGX_HTTP_OK |
56 || r != r->main | 57 || r != r->main |
57 || r->headers_in.if_modified_since == NULL | 58 || r->headers_in.if_modified_since == NULL |
58 || r->headers_out.last_modified_time == -1) | 59 || r->headers_out.last_modified_time == -1) |
59 { | 60 { |
60 return ngx_http_next_header_filter(r); | 61 return ngx_http_next_header_filter(r); |
61 } | 62 } |
62 | 63 |
64 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
65 | |
66 if (clcf->if_modified_since == NGX_HTTP_IMS_OFF) { | |
67 return ngx_http_next_header_filter(r); | |
68 } | |
69 | |
63 ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data, | 70 ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data, |
64 r->headers_in.if_modified_since->value.len); | 71 r->headers_in.if_modified_since->value.len); |
65 | 72 |
66 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 73 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
67 "http ims:%d lm:%d", ims, r->headers_out.last_modified_time); | 74 "http ims:%d lm:%d", ims, r->headers_out.last_modified_time); |
68 | 75 |
69 /* | 76 if (ims != r->headers_out.last_modified_time) { |
70 * I think that the equality of the dates is correcter | |
71 */ | |
72 | 77 |
73 if (ims == r->headers_out.last_modified_time) { | 78 if (clcf->if_modified_since == NGX_HTTP_IMS_EXACT |
74 r->headers_out.status = NGX_HTTP_NOT_MODIFIED; | 79 || ims < r->headers_out.last_modified_time) |
75 r->headers_out.content_type.len = 0; | 80 { |
76 ngx_http_clear_content_length(r); | 81 return ngx_http_next_header_filter(r); |
77 ngx_http_clear_accept_ranges(r); | 82 } |
78 } | 83 } |
84 | |
85 r->headers_out.status = NGX_HTTP_NOT_MODIFIED; | |
86 r->headers_out.content_type.len = 0; | |
87 ngx_http_clear_content_length(r); | |
88 ngx_http_clear_accept_ranges(r); | |
79 | 89 |
80 return ngx_http_next_header_filter(r); | 90 return ngx_http_next_header_filter(r); |
81 } | 91 } |
82 | 92 |
83 | 93 |