comparison src/http/modules/ngx_http_not_modified_filter_module.c @ 2361:c59485781f0a

if_modified_since
author Igor Sysoev <igor@sysoev.ru>
date Mon, 01 Dec 2008 14:22:51 +0000
parents b67b75bb09b7
children 9081bbdccda1
comparison
equal deleted inserted replaced
2360:64854406b1f9 2361:c59485781f0a
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)
64 r->headers_in.if_modified_since->value.len); 65 r->headers_in.if_modified_since->value.len);
65 66
66 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 67 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
67 "http ims:%d lm:%d", ims, r->headers_out.last_modified_time); 68 "http ims:%d lm:%d", ims, r->headers_out.last_modified_time);
68 69
69 /* 70 if (ims != r->headers_out.last_modified_time) {
70 * I think that the equality of the dates is correcter
71 */
72 71
73 if (ims == r->headers_out.last_modified_time) { 72 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
74 r->headers_out.status = NGX_HTTP_NOT_MODIFIED; 73
75 r->headers_out.content_type.len = 0; 74 if (clcf->if_modified_since == 0
76 ngx_http_clear_content_length(r); 75 || ims < r->headers_out.last_modified_time)
77 ngx_http_clear_accept_ranges(r); 76 {
77 return ngx_http_next_header_filter(r);
78 }
78 } 79 }
80
81 r->headers_out.status = NGX_HTTP_NOT_MODIFIED;
82 r->headers_out.content_type.len = 0;
83 ngx_http_clear_content_length(r);
84 ngx_http_clear_accept_ranges(r);
79 85
80 return ngx_http_next_header_filter(r); 86 return ngx_http_next_header_filter(r);
81 } 87 }
82 88
83 89