comparison 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
comparison
equal deleted inserted replaced
383:3d40b0260a84 384:09b703ae3ba5
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