Mercurial > hg > nginx-ranges
diff src/http/modules/ngx_http_headers_filter_module.c @ 397:05981f639d21 NGINX_0_7_9
nginx 0.7.9
*) Change: now ngx_http_charset_module works by default with following
MIME types: text/html, text/css, text/xml, text/plain,
text/vnd.wap.wml, application/x-javascript, and application/rss+xml.
*) Feature: the "charset_types" and "addition_types" directives.
*) Feature: now the "gzip_types", "ssi_types", and "sub_filter_types"
directives use hash.
*) Feature: the ngx_cpp_test_module.
*) Feature: the "expires" directive supports daily time.
*) Feature: the ngx_http_xslt_module improvements and bug fixing.
Thanks to Denis F. Latypoff and Maxim Dounin.
*) Bugfix: the "log_not_found" directive did not work for index files
tests.
*) Bugfix: HTTPS connections might hang, if kqueue, epoll, rtsig, or
eventport methods were used; the bug had appeared in 0.7.7.
*) Bugfix: if the "server_name", "valid_referers", and "map" directives
used an "*.domain.tld" wildcard and exact name "domain.tld" was not
set, then the exact name was matched by the wildcard; the bugs had
appeared in 0.3.18.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 12 Aug 2008 00:00:00 +0400 |
parents | 984bb0b1399b |
children | dac47e9ef0d5 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_headers_filter_module.c +++ b/src/http/modules/ngx_http_headers_filter_module.c @@ -36,6 +36,7 @@ struct ngx_http_header_val_s { #define NGX_HTTP_EXPIRES_MAX 2 #define NGX_HTTP_EXPIRES_ACCESS 3 #define NGX_HTTP_EXPIRES_MODIFIED 4 +#define NGX_HTTP_EXPIRES_DAILY 5 typedef struct { @@ -187,7 +188,7 @@ static ngx_int_t ngx_http_set_expires(ngx_http_request_t *r, ngx_http_headers_conf_t *conf) { size_t len; - time_t since; + time_t now, expires_time, max_age; ngx_uint_t i; ngx_table_elt_t *expires, *cc, **ccp; @@ -279,16 +280,24 @@ ngx_http_set_expires(ngx_http_request_t return NGX_OK; } + now = ngx_time(); + if (conf->expires == NGX_HTTP_EXPIRES_ACCESS || r->headers_out.last_modified_time == -1) { - since = ngx_time(); + expires_time = now + conf->expires_time; + max_age = conf->expires_time; + + } else if (conf->expires == NGX_HTTP_EXPIRES_DAILY) { + expires_time = ngx_next_time(conf->expires_time); + max_age = expires_time - now; } else { - since = r->headers_out.last_modified_time; + expires_time = r->headers_out.last_modified_time + conf->expires_time; + max_age = expires_time - now; } - ngx_http_time(expires->value.data, since + conf->expires_time); + ngx_http_time(expires->value.data, expires_time); if (conf->expires_time < 0) { cc->value.len = sizeof("no-cache") - 1; @@ -303,8 +312,7 @@ ngx_http_set_expires(ngx_http_request_t return NGX_ERROR; } - cc->value.len = ngx_sprintf(cc->value.data, "max-age=%T", - since + conf->expires_time - ngx_time()) + cc->value.len = ngx_sprintf(cc->value.data, "max-age=%T", max_age) - cc->value.data; return NGX_OK; @@ -514,7 +522,18 @@ ngx_http_headers_expires(ngx_conf_t *cf, n = 2; } - if (value[n].data[0] == '+') { + if (value[n].data[0] == '@') { + value[n].data++; + value[n].len--; + minus = 0; + + if (hcf->expires == NGX_HTTP_EXPIRES_MODIFIED) { + return "daily time can not be used with \"modified\" parameter"; + } + + hcf->expires = NGX_HTTP_EXPIRES_DAILY; + + } else if (value[n].data[0] == '+') { value[n].data++; value[n].len--; minus = 0; @@ -534,6 +553,12 @@ ngx_http_headers_expires(ngx_conf_t *cf, return "invalid value"; } + if (hcf->expires == NGX_HTTP_EXPIRES_DAILY + && hcf->expires_time > 24 * 60 * 60) + { + return "daily time value must be less than 24 hours"; + } + if (hcf->expires_time == NGX_PARSE_LARGE_TIME) { return "value must be less than 68 years"; }