comparison src/http/modules/ngx_http_headers_filter_module.c @ 694:88a1b4797f2e NGINX_1_3_10

nginx 1.3.10 *) Change: domain names specified in configuration file are now resolved to IPv6 addresses as well as IPv4 ones. *) Change: now if the "include" directive with mask is used on Unix systems, included files are sorted in alphabetical order. *) Change: the "add_header" directive adds headers to 201 responses. *) Feature: the "geo" directive now supports IPv6 addresses in CIDR notation. *) Feature: the "flush" and "gzip" parameters of the "access_log" directive. *) Feature: variables support in the "auth_basic" directive. *) Bugfix: nginx could not be built with the ngx_http_perl_module in some cases. *) Bugfix: a segmentation fault might occur in a worker process if the ngx_http_xslt_module was used. *) Bugfix: nginx could not be built on MacOSX in some cases. Thanks to Piotr Sikora. *) Bugfix: the "limit_rate" directive with high rates might result in truncated responses on 32-bit platforms. Thanks to Alexey Antropov. *) Bugfix: a segmentation fault might occur in a worker process if the "if" directive was used. Thanks to Piotr Sikora. *) Bugfix: a "100 Continue" response was issued with "413 Request Entity Too Large" responses. *) Bugfix: the "image_filter", "image_filter_jpeg_quality" and "image_filter_sharpen" directives might be inherited incorrectly. Thanks to Ian Babrou. *) Bugfix: "crypt_r() failed" errors might appear if the "auth_basic" directive was used on Linux. *) Bugfix: in backup servers handling. Thanks to Thomas Chen. *) Bugfix: proxied HEAD requests might return incorrect response if the "gzip" directive was used.
author Igor Sysoev <http://sysoev.ru>
date Tue, 25 Dec 2012 00:00:00 +0400
parents 597573166f34
children
comparison
equal deleted inserted replaced
693:cfd4279acc6e 694:88a1b4797f2e
72 72
73 static ngx_http_set_header_t ngx_http_set_headers[] = { 73 static ngx_http_set_header_t ngx_http_set_headers[] = {
74 74
75 { ngx_string("Cache-Control"), 0, ngx_http_add_cache_control }, 75 { ngx_string("Cache-Control"), 0, ngx_http_add_cache_control },
76 76
77 { ngx_string("Last-Modified"), 0, ngx_http_set_last_modified }, 77 { ngx_string("Last-Modified"),
78 offsetof(ngx_http_headers_out_t, last_modified),
79 ngx_http_set_last_modified },
78 80
79 { ngx_string("ETag"), 81 { ngx_string("ETag"),
80 offsetof(ngx_http_headers_out_t, etag), 82 offsetof(ngx_http_headers_out_t, etag),
81 ngx_http_set_response_header }, 83 ngx_http_set_response_header },
82 84
151 conf = ngx_http_get_module_loc_conf(r, ngx_http_headers_filter_module); 153 conf = ngx_http_get_module_loc_conf(r, ngx_http_headers_filter_module);
152 154
153 if ((conf->expires == NGX_HTTP_EXPIRES_OFF && conf->headers == NULL) 155 if ((conf->expires == NGX_HTTP_EXPIRES_OFF && conf->headers == NULL)
154 || r != r->main 156 || r != r->main
155 || (r->headers_out.status != NGX_HTTP_OK 157 || (r->headers_out.status != NGX_HTTP_OK
158 && r->headers_out.status != NGX_HTTP_CREATED
156 && r->headers_out.status != NGX_HTTP_NO_CONTENT 159 && r->headers_out.status != NGX_HTTP_NO_CONTENT
157 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT 160 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT
158 && r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY 161 && r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY
159 && r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY 162 && r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY
160 && r->headers_out.status != NGX_HTTP_SEE_OTHER 163 && r->headers_out.status != NGX_HTTP_SEE_OTHER
370 373
371 static ngx_int_t 374 static ngx_int_t
372 ngx_http_set_last_modified(ngx_http_request_t *r, ngx_http_header_val_t *hv, 375 ngx_http_set_last_modified(ngx_http_request_t *r, ngx_http_header_val_t *hv,
373 ngx_str_t *value) 376 ngx_str_t *value)
374 { 377 {
375 ngx_table_elt_t *h; 378 if (ngx_http_set_response_header(r, hv, value) != NGX_OK) {
376
377 ngx_http_clear_last_modified(r);
378
379 if (value->len == 0) {
380 return NGX_OK;
381 }
382
383 r->headers_out.last_modified_time = ngx_http_parse_time(value->data,
384 value->len);
385
386 h = ngx_list_push(&r->headers_out.headers);
387 if (h == NULL) {
388 return NGX_ERROR; 379 return NGX_ERROR;
389 } 380 }
390 381
391 r->headers_out.last_modified = h; 382 r->headers_out.last_modified_time =
392 383 (value->len) ? ngx_http_parse_time(value->data, value->len) : -1;
393 h->hash = 1;
394 h->key = hv->key;
395 h->value = *value;
396 384
397 return NGX_OK; 385 return NGX_OK;
398 } 386 }
399 387
400 388
404 { 392 {
405 ngx_table_elt_t *h, **old; 393 ngx_table_elt_t *h, **old;
406 394
407 old = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset); 395 old = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset);
408 396
397 if (value->len == 0) {
398 if (*old) {
399 (*old)->hash = 0;
400 *old = NULL;
401 }
402
403 return NGX_OK;
404 }
405
409 if (*old) { 406 if (*old) {
410 (*old)->hash = 0; 407 h = *old;
411 *old = NULL; 408
412 } 409 } else {
413 410 h = ngx_list_push(&r->headers_out.headers);
414 if (value->len == 0) { 411 if (h == NULL) {
415 return NGX_OK; 412 return NGX_ERROR;
416 } 413 }
417 414
418 h = ngx_list_push(&r->headers_out.headers); 415 *old = h;
419 if (h == NULL) { 416 }
420 return NGX_ERROR;
421 }
422
423 *old = h;
424 417
425 h->hash = 1; 418 h->hash = 1;
426 h->key = hv->key; 419 h->key = hv->key;
427 h->value = *value; 420 h->value = *value;
428 421