Mercurial > hg > nginx-quic
changeset 2256:8c17cfe63d2c
underscores_in_headers
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 24 Sep 2008 14:02:50 +0000 |
parents | fb7995c7bdd9 |
children | 74d270c8821e |
files | src/http/modules/ngx_http_fastcgi_module.c src/http/modules/ngx_http_proxy_module.c src/http/ngx_http.h src/http/ngx_http_core_module.c src/http/ngx_http_core_module.h src/http/ngx_http_parse.c src/http/ngx_http_request.c |
diffstat | 7 files changed, 35 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -1031,7 +1031,7 @@ ngx_http_fastcgi_process_header(ngx_http part_start = u->buffer.pos; - rc = ngx_http_parse_header_line(r, &u->buffer); + rc = ngx_http_parse_header_line(r, &u->buffer, 1); ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http fastcgi parser: %d", rc); @@ -1076,7 +1076,7 @@ ngx_http_fastcgi_process_header(ngx_http f->split_parts->nelts = 0; - rc = ngx_http_parse_header_line(r, &buf); + rc = ngx_http_parse_header_line(r, &buf, 1); h->key.len = r->header_name_end - r->header_name_start; h->key.data = r->header_name_start;
--- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -1214,7 +1214,7 @@ ngx_http_proxy_process_header(ngx_http_r for ( ;; ) { - rc = ngx_http_parse_header_line(r, &r->upstream->buffer); + rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1); if (rc == NGX_OK) {
--- a/src/http/ngx_http.h +++ b/src/http/ngx_http.h @@ -72,7 +72,8 @@ ngx_int_t ngx_http_parse_complex_uri(ngx ngx_uint_t merge_slashes); ngx_int_t ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri, ngx_str_t *args, ngx_uint_t *flags); -ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b); +ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b, + ngx_uint_t allow_underscores); ngx_int_t ngx_http_parse_multi_header_lines(ngx_array_t *headers, ngx_str_t *name, ngx_str_t *value);
--- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -231,6 +231,13 @@ static ngx_command_t ngx_http_core_comm offsetof(ngx_http_core_srv_conf_t, merge_slashes), NULL }, + { ngx_string("underscores_in_headers"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, + ngx_conf_set_flag_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_core_srv_conf_t, underscores_in_headers), + NULL }, + { ngx_string("location"), NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE12, ngx_http_core_location, @@ -2527,6 +2534,7 @@ ngx_http_core_create_srv_conf(ngx_conf_t cscf->client_header_buffer_size = NGX_CONF_UNSET_SIZE; cscf->ignore_invalid_headers = NGX_CONF_UNSET; cscf->merge_slashes = NGX_CONF_UNSET; + cscf->underscores_in_headers = NGX_CONF_UNSET; return cscf; } @@ -2605,6 +2613,9 @@ ngx_http_core_merge_srv_conf(ngx_conf_t ngx_conf_merge_value(conf->merge_slashes, prev->merge_slashes, 1); + ngx_conf_merge_value(conf->underscores_in_headers, + prev->underscores_in_headers, 0); + return NGX_CONF_OK; }
--- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -155,6 +155,7 @@ typedef struct { ngx_flag_t ignore_invalid_headers; ngx_flag_t merge_slashes; + ngx_flag_t underscores_in_headers; ngx_http_core_loc_conf_t **named_locations; } ngx_http_core_srv_conf_t;
--- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -700,7 +700,8 @@ done: ngx_int_t -ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b) +ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b, + ngx_uint_t allow_underscores) { u_char c, ch, *p; ngx_uint_t hash, i; @@ -720,7 +721,7 @@ ngx_http_parse_header_line(ngx_http_requ static u_char lowcase[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0-\0\0" "0123456789\0\0\0\0\0\0" - "\0abcdefghijklmnopqrstuvwxyz\0\0\0\0_" + "\0abcdefghijklmnopqrstuvwxyz\0\0\0\0\0" "\0abcdefghijklmnopqrstuvwxyz\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" @@ -779,6 +780,19 @@ ngx_http_parse_header_line(ngx_http_requ break; } + if (ch == '_') { + if (allow_underscores) { + hash = ngx_hash(hash, ch); + r->lowcase_header[i++] = ch; + i &= (NGX_HTTP_LC_HEADER_LEN - 1); + + } else { + r->invalid_header = 1; + } + + break; + } + if (ch == ':') { r->header_name_end = p; state = sw_space_before_value;