From 3338cfdfbc5522ca96319ece6d21ddc4d1dce45d Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Thu, 11 May 2006 14:43:47 +0000 Subject: nginx-0.3.46-RELEASE import *) Feature: the "proxy_hide_header", "proxy_pass_header", "fastcgi_hide_header", and "fastcgi_pass_header" directives. *) Change: the "proxy_pass_x_powered_by", "fastcgi_x_powered_by", and "proxy_pass_server" directives were canceled. *) Feature: the "X-Accel-Buffering" response header line is supported in proxy mode. *) Bugfix: the reconfiguration bug and memory leaks in the ngx_http_perl_module. --- src/http/ngx_http_parse.c | 50 +++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'src/http/ngx_http_parse.c') diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c index 1b1e963ad..426aa8a0e 100644 --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -9,6 +9,8 @@ #include +/* gcc, icc, msvc and others compile these switches as an jump table */ + ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b) { @@ -43,8 +45,6 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b) for (p = b->pos; p < b->last; p++) { ch = *p; - /* gcc 2.95.2 and msvc 6.0 compile this switch as an jump table */ - switch (state) { /* HTTP methods: GET, HEAD, POST */ @@ -528,7 +528,7 @@ ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b) { u_char c, ch, *p; - ngx_uint_t hash; + ngx_uint_t hash, i; enum { sw_start = 0, sw_name, @@ -540,8 +540,19 @@ ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b) sw_header_almost_done } state; + 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\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" + "\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"; + state = r->state; hash = r->header_hash; + i = r->lowcase_index; for (p = b->pos; p < b->last; p++) { ch = *p; @@ -564,14 +575,12 @@ ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b) state = sw_name; r->header_name_start = p; - c = (u_char) (ch | 0x20); - if (c >= 'a' && c <= 'z') { - hash = c; - break; - } + c = lowcase[ch]; - if (ch >= '0' && ch <= '9') { - hash = ch; + if (c) { + hash = ngx_hash(0, c); + r->lowcase_header[0] = c; + i = 1; break; } @@ -584,9 +593,12 @@ ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b) /* header name */ case sw_name: - c = (u_char) (ch | 0x20); - if (c >= 'a' && c <= 'z') { - hash += c; + c = lowcase[ch]; + + if (c) { + hash = ngx_hash(hash, c); + r->lowcase_header[i++] = c; + i &= ~NGX_HTTP_LC_HEADER_LEN; break; } @@ -596,16 +608,6 @@ ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b) break; } - if (ch == '-') { - hash += ch; - break; - } - - if (ch >= '0' && ch <= '9') { - hash += ch; - break; - } - if (ch == CR) { r->header_name_end = p; r->header_start = p; @@ -726,6 +728,7 @@ ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b) b->pos = p; r->state = state; r->header_hash = hash; + r->lowcase_index = i; return NGX_AGAIN; @@ -734,6 +737,7 @@ done: b->pos = p + 1; r->state = sw_start; r->header_hash = hash; + r->lowcase_index = i; return NGX_OK; -- cgit