comparison src/http/ngx_http_core_module.c @ 680:597573166f34 NGINX_1_3_3

nginx 1.3.3 *) Feature: entity tags support and the "etag" directive. *) Bugfix: trailing dot in a source value was not ignored if the "map" directive was used with the "hostnames" parameter. *) Bugfix: incorrect location might be used to process a request if a URI was changed via a "rewrite" directive before an internal redirect to a named location.
author Igor Sysoev <http://sysoev.ru>
date Tue, 10 Jul 2012 00:00:00 +0400
parents bfa81a0490a2
children 5cb5db9975ba
comparison
equal deleted inserted replaced
679:cad34cec7d3b 680:597573166f34
648 ngx_conf_set_flag_slot, 648 ngx_conf_set_flag_slot,
649 NGX_HTTP_LOC_CONF_OFFSET, 649 NGX_HTTP_LOC_CONF_OFFSET,
650 offsetof(ngx_http_core_loc_conf_t, chunked_transfer_encoding), 650 offsetof(ngx_http_core_loc_conf_t, chunked_transfer_encoding),
651 NULL }, 651 NULL },
652 652
653 { ngx_string("etag"),
654 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
655 ngx_conf_set_flag_slot,
656 NGX_HTTP_LOC_CONF_OFFSET,
657 offsetof(ngx_http_core_loc_conf_t, etag),
658 NULL },
659
653 { ngx_string("error_page"), 660 { ngx_string("error_page"),
654 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF 661 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
655 |NGX_CONF_2MORE, 662 |NGX_CONF_2MORE,
656 ngx_http_core_error_page, 663 ngx_http_core_error_page,
657 NGX_HTTP_LOC_CONF_OFFSET, 664 NGX_HTTP_LOC_CONF_OFFSET,
1807 return; 1814 return;
1808 } 1815 }
1809 1816
1810 1817
1811 ngx_int_t 1818 ngx_int_t
1819 ngx_http_set_etag(ngx_http_request_t *r)
1820 {
1821 ngx_table_elt_t *etag;
1822 ngx_http_core_loc_conf_t *clcf;
1823
1824 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1825
1826 if (!clcf->etag) {
1827 return NGX_OK;
1828 }
1829
1830 etag = ngx_list_push(&r->headers_out.headers);
1831 if (etag == NULL) {
1832 return NGX_ERROR;
1833 }
1834
1835 etag->hash = 1;
1836 ngx_str_set(&etag->key, "ETag");
1837
1838 etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3);
1839 if (etag->value.data == NULL) {
1840 return NGX_ERROR;
1841 }
1842
1843 etag->value.len = ngx_sprintf(etag->value.data, "\"%xT-%xO\"",
1844 r->headers_out.last_modified_time,
1845 r->headers_out.content_length_n)
1846 - etag->value.data;
1847
1848 r->headers_out.etag = etag;
1849
1850 return NGX_OK;
1851 }
1852
1853
1854 ngx_int_t
1812 ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status, 1855 ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
1813 ngx_str_t *ct, ngx_http_complex_value_t *cv) 1856 ngx_str_t *ct, ngx_http_complex_value_t *cv)
1814 { 1857 {
1815 ngx_int_t rc; 1858 ngx_int_t rc;
1816 ngx_str_t val; 1859 ngx_str_t val;
2586 "using location: %V \"%V?%V\"", 2629 "using location: %V \"%V?%V\"",
2587 name, &r->uri, &r->args); 2630 name, &r->uri, &r->args);
2588 2631
2589 r->internal = 1; 2632 r->internal = 1;
2590 r->content_handler = NULL; 2633 r->content_handler = NULL;
2634 r->uri_changed = 0;
2591 r->loc_conf = (*clcfp)->loc_conf; 2635 r->loc_conf = (*clcfp)->loc_conf;
2592 2636
2593 /* clear the modules contexts */ 2637 /* clear the modules contexts */
2594 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module); 2638 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
2595 2639
3507 clcf->log_not_found = NGX_CONF_UNSET; 3551 clcf->log_not_found = NGX_CONF_UNSET;
3508 clcf->log_subrequest = NGX_CONF_UNSET; 3552 clcf->log_subrequest = NGX_CONF_UNSET;
3509 clcf->recursive_error_pages = NGX_CONF_UNSET; 3553 clcf->recursive_error_pages = NGX_CONF_UNSET;
3510 clcf->server_tokens = NGX_CONF_UNSET; 3554 clcf->server_tokens = NGX_CONF_UNSET;
3511 clcf->chunked_transfer_encoding = NGX_CONF_UNSET; 3555 clcf->chunked_transfer_encoding = NGX_CONF_UNSET;
3556 clcf->etag = NGX_CONF_UNSET;
3512 clcf->types_hash_max_size = NGX_CONF_UNSET_UINT; 3557 clcf->types_hash_max_size = NGX_CONF_UNSET_UINT;
3513 clcf->types_hash_bucket_size = NGX_CONF_UNSET_UINT; 3558 clcf->types_hash_bucket_size = NGX_CONF_UNSET_UINT;
3514 3559
3515 clcf->open_file_cache = NGX_CONF_UNSET_PTR; 3560 clcf->open_file_cache = NGX_CONF_UNSET_PTR;
3516 clcf->open_file_cache_valid = NGX_CONF_UNSET; 3561 clcf->open_file_cache_valid = NGX_CONF_UNSET;
3768 ngx_conf_merge_value(conf->recursive_error_pages, 3813 ngx_conf_merge_value(conf->recursive_error_pages,
3769 prev->recursive_error_pages, 0); 3814 prev->recursive_error_pages, 0);
3770 ngx_conf_merge_value(conf->server_tokens, prev->server_tokens, 1); 3815 ngx_conf_merge_value(conf->server_tokens, prev->server_tokens, 1);
3771 ngx_conf_merge_value(conf->chunked_transfer_encoding, 3816 ngx_conf_merge_value(conf->chunked_transfer_encoding,
3772 prev->chunked_transfer_encoding, 1); 3817 prev->chunked_transfer_encoding, 1);
3818 ngx_conf_merge_value(conf->etag, prev->etag, 1);
3773 3819
3774 ngx_conf_merge_ptr_value(conf->open_file_cache, 3820 ngx_conf_merge_ptr_value(conf->open_file_cache,
3775 prev->open_file_cache, NULL); 3821 prev->open_file_cache, NULL);
3776 3822
3777 ngx_conf_merge_sec_value(conf->open_file_cache_valid, 3823 ngx_conf_merge_sec_value(conf->open_file_cache_valid,