comparison src/http/modules/ngx_http_headers_filter_module.c @ 4350:ea0f2e1f84d4 stable-1.0

Merge of r4217, r4218: Fixed "expires @00h". Fixed "expires @time" with unknown last modified time (ticket #32).
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 13 Dec 2011 18:46:07 +0000
parents d3568507db51
children 9c4acdf9b276
comparison
equal deleted inserted replaced
4349:e04fdb54dd71 4350:ea0f2e1f84d4
251 expires->value.data = ngx_pnalloc(r->pool, len); 251 expires->value.data = ngx_pnalloc(r->pool, len);
252 if (expires->value.data == NULL) { 252 if (expires->value.data == NULL) {
253 return NGX_ERROR; 253 return NGX_ERROR;
254 } 254 }
255 255
256 if (conf->expires_time == 0) { 256 if (conf->expires_time == 0 && conf->expires != NGX_HTTP_EXPIRES_DAILY) {
257 ngx_memcpy(expires->value.data, ngx_cached_http_time.data, 257 ngx_memcpy(expires->value.data, ngx_cached_http_time.data,
258 ngx_cached_http_time.len + 1); 258 ngx_cached_http_time.len + 1);
259 ngx_str_set(&cc->value, "max-age=0"); 259 ngx_str_set(&cc->value, "max-age=0");
260 return NGX_OK; 260 return NGX_OK;
261 } 261 }
262 262
263 now = ngx_time(); 263 now = ngx_time();
264 264
265 if (conf->expires == NGX_HTTP_EXPIRES_ACCESS 265 if (conf->expires == NGX_HTTP_EXPIRES_DAILY) {
266 || r->headers_out.last_modified_time == -1) 266 expires_time = ngx_next_time(conf->expires_time);
267 max_age = expires_time - now;
268
269 } else if (conf->expires == NGX_HTTP_EXPIRES_ACCESS
270 || r->headers_out.last_modified_time == -1)
267 { 271 {
268 expires_time = now + conf->expires_time; 272 expires_time = now + conf->expires_time;
269 max_age = conf->expires_time; 273 max_age = conf->expires_time;
270
271 } else if (conf->expires == NGX_HTTP_EXPIRES_DAILY) {
272 expires_time = ngx_next_time(conf->expires_time);
273 max_age = expires_time - now;
274 274
275 } else { 275 } else {
276 expires_time = r->headers_out.last_modified_time + conf->expires_time; 276 expires_time = r->headers_out.last_modified_time + conf->expires_time;
277 max_age = expires_time - now; 277 max_age = expires_time - now;
278 } 278 }