comparison src/http/modules/ngx_http_headers_filter_module.c @ 570:8246d8a2c2be NGINX_0_8_37

nginx 0.8.37 *) Feature: the ngx_http_split_clients_module. *) Feature: the "map" directive supports keys more than 255 characters. *) Bugfix: nginx ignored the "private" and "no-store" values in the "Cache-Control" backend response header line. *) Bugfix: a "stub" parameter of an "include" SSI directive was not used, if empty response has 200 status code. *) Bugfix: if a proxied or FastCGI request was internally redirected to another proxied or FastCGI location, then a segmentation fault might occur in a worker process; the bug had appeared in 0.8.33. Thanks to Yichun Zhang. *) Bugfix: IMAP connections may hang until they timed out while talking to Zimbra server. Thanks to Alan Batie.
author Igor Sysoev <http://sysoev.ru>
date Mon, 17 May 2010 00:00:00 +0400
parents daf4847b43ff
children eb208e0cf44d
comparison
equal deleted inserted replaced
569:19b134bf21c0 570:8246d8a2c2be
194 } 194 }
195 195
196 r->headers_out.expires = expires; 196 r->headers_out.expires = expires;
197 197
198 expires->hash = 1; 198 expires->hash = 1;
199 expires->key.len = sizeof("Expires") - 1; 199 ngx_str_set(&expires->key, "Expires");
200 expires->key.data = (u_char *) "Expires";
201 } 200 }
202 201
203 len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT"); 202 len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT");
204 expires->value.len = len - 1; 203 expires->value.len = len - 1;
205 204
223 if (cc == NULL) { 222 if (cc == NULL) {
224 return NGX_ERROR; 223 return NGX_ERROR;
225 } 224 }
226 225
227 cc->hash = 1; 226 cc->hash = 1;
228 cc->key.len = sizeof("Cache-Control") - 1; 227 ngx_str_set(&cc->key, "Cache-Control");
229 cc->key.data = (u_char *) "Cache-Control";
230
231 *ccp = cc; 228 *ccp = cc;
232 229
233 } else { 230 } else {
234 for (i = 1; i < r->headers_out.cache_control.nelts; i++) { 231 for (i = 1; i < r->headers_out.cache_control.nelts; i++) {
235 ccp[i]->hash = 0; 232 ccp[i]->hash = 0;
238 cc = ccp[0]; 235 cc = ccp[0];
239 } 236 }
240 237
241 if (conf->expires == NGX_HTTP_EXPIRES_EPOCH) { 238 if (conf->expires == NGX_HTTP_EXPIRES_EPOCH) {
242 expires->value.data = (u_char *) "Thu, 01 Jan 1970 00:00:01 GMT"; 239 expires->value.data = (u_char *) "Thu, 01 Jan 1970 00:00:01 GMT";
243 240 ngx_str_set(&cc->value, "no-cache");
244 cc->value.len = sizeof("no-cache") - 1;
245 cc->value.data = (u_char *) "no-cache";
246
247 return NGX_OK; 241 return NGX_OK;
248 } 242 }
249 243
250 if (conf->expires == NGX_HTTP_EXPIRES_MAX) { 244 if (conf->expires == NGX_HTTP_EXPIRES_MAX) {
251 expires->value.data = (u_char *) "Thu, 31 Dec 2037 23:55:55 GMT"; 245 expires->value.data = (u_char *) "Thu, 31 Dec 2037 23:55:55 GMT";
252
253 /* 10 years */ 246 /* 10 years */
254 cc->value.len = sizeof("max-age=315360000") - 1; 247 ngx_str_set(&cc->value, "max-age=315360000");
255 cc->value.data = (u_char *) "max-age=315360000";
256
257 return NGX_OK; 248 return NGX_OK;
258 } 249 }
259 250
260 expires->value.data = ngx_pnalloc(r->pool, len); 251 expires->value.data = ngx_pnalloc(r->pool, len);
261 if (expires->value.data == NULL) { 252 if (expires->value.data == NULL) {
263 } 254 }
264 255
265 if (conf->expires_time == 0) { 256 if (conf->expires_time == 0) {
266 ngx_memcpy(expires->value.data, ngx_cached_http_time.data, 257 ngx_memcpy(expires->value.data, ngx_cached_http_time.data,
267 ngx_cached_http_time.len + 1); 258 ngx_cached_http_time.len + 1);
268 259 ngx_str_set(&cc->value, "max-age=0");
269 cc->value.len = sizeof("max-age=0") - 1;
270 cc->value.data = (u_char *) "max-age=0";
271
272 return NGX_OK; 260 return NGX_OK;
273 } 261 }
274 262
275 now = ngx_time(); 263 now = ngx_time();
276 264
290 } 278 }
291 279
292 ngx_http_time(expires->value.data, expires_time); 280 ngx_http_time(expires->value.data, expires_time);
293 281
294 if (conf->expires_time < 0 || max_age < 0) { 282 if (conf->expires_time < 0 || max_age < 0) {
295 cc->value.len = sizeof("no-cache") - 1; 283 ngx_str_set(&cc->value, "no-cache");
296 cc->value.data = (u_char *) "no-cache";
297
298 return NGX_OK; 284 return NGX_OK;
299 } 285 }
300 286
301 cc->value.data = ngx_pnalloc(r->pool, 287 cc->value.data = ngx_pnalloc(r->pool,
302 sizeof("max-age=") + NGX_TIME_T_LEN + 1); 288 sizeof("max-age=") + NGX_TIME_T_LEN + 1);
359 if (cc == NULL) { 345 if (cc == NULL) {
360 return NGX_ERROR; 346 return NGX_ERROR;
361 } 347 }
362 348
363 cc->hash = 1; 349 cc->hash = 1;
364 cc->key.len = sizeof("Cache-Control") - 1; 350 ngx_str_set(&cc->key, "Cache-Control");
365 cc->key.data = (u_char *) "Cache-Control";
366 cc->value = *value; 351 cc->value = *value;
367 352
368 *ccp = cc; 353 *ccp = cc;
369 354
370 return NGX_OK; 355 return NGX_OK;