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_core_module.c | 43 ++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'src/http/ngx_http_core_module.c') diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 931be888f..5403fdbda 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -921,42 +921,43 @@ ngx_http_set_content_type(ngx_http_request_t *r) { u_char c, *p, *exten; ngx_str_t *type; - ngx_uint_t i; + ngx_uint_t i, hash; ngx_http_core_loc_conf_t *clcf; clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); if (r->exten.len) { - if (!r->low_case_exten) { - for (i = 0; i < r->exten.len; i++) { - c = r->exten.data[i]; - if (c >= 'A' && c <= 'Z') { - break; - } - } + hash = 0; + + for (i = 0; i < r->exten.len; i++) { + c = r->exten.data[i]; + + if (c >= 'A' && c <= 'Z') { - if (i < r->exten.len) { p = ngx_palloc(r->pool, r->exten.len); if (p == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } + hash = 0; exten = p; for (i = 0; i < r->exten.len; i++) { - c = r->exten.data[i]; - *p++ = ngx_tolower(c); + c = ngx_tolower(r->exten.data[i]); + hash = ngx_hash(hash, c); + *p++ = c; } r->exten.data = exten; + + break; } - r->low_case_exten = 1; + hash = ngx_hash(hash, c); } - type = ngx_hash_find(&clcf->types_hash, - ngx_hash_key(r->exten.data, r->exten.len), + type = ngx_hash_find(&clcf->types_hash, hash, r->exten.data, r->exten.len); if (type) { @@ -981,17 +982,9 @@ ngx_http_set_exten(ngx_http_request_t *r) for (i = r->uri.len - 1; i > 1; i--) { if (r->uri.data[i] == '.' && r->uri.data[i - 1] != '/') { - r->exten.len = r->uri.len - i - 1; - - if (r->exten.len > 0) { - r->exten.data = ngx_palloc(r->pool, r->exten.len + 1); - if (r->exten.data == NULL) { - return NGX_ERROR; - } - ngx_cpystrn(r->exten.data, &r->uri.data[i + 1], - r->exten.len + 1); - } + r->exten.len = r->uri.len - i - 1; + r->exten.data = &r->uri.data[i + 1]; break; @@ -1000,8 +993,6 @@ ngx_http_set_exten(ngx_http_request_t *r) } } - r->low_case_exten = 0; - return NGX_OK; } -- cgit