comparison src/http/ngx_http_core_module.c @ 198:e6da4931e0e0 NGINX_0_3_46

nginx 0.3.46 *) 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.
author Igor Sysoev <http://sysoev.ru>
date Thu, 11 May 2006 00:00:00 +0400
parents 003bd800ec2a
children d2ae1c9f1fd3
comparison
equal deleted inserted replaced
197:93658b91fad2 198:e6da4931e0e0
919 ngx_int_t 919 ngx_int_t
920 ngx_http_set_content_type(ngx_http_request_t *r) 920 ngx_http_set_content_type(ngx_http_request_t *r)
921 { 921 {
922 u_char c, *p, *exten; 922 u_char c, *p, *exten;
923 ngx_str_t *type; 923 ngx_str_t *type;
924 ngx_uint_t i; 924 ngx_uint_t i, hash;
925 ngx_http_core_loc_conf_t *clcf; 925 ngx_http_core_loc_conf_t *clcf;
926 926
927 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 927 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
928 928
929 if (r->exten.len) { 929 if (r->exten.len) {
930 930
931 if (!r->low_case_exten) { 931 hash = 0;
932 for (i = 0; i < r->exten.len; i++) { 932
933 c = r->exten.data[i]; 933 for (i = 0; i < r->exten.len; i++) {
934 if (c >= 'A' && c <= 'Z') { 934 c = r->exten.data[i];
935 break; 935
936 } 936 if (c >= 'A' && c <= 'Z') {
937 } 937
938
939 if (i < r->exten.len) {
940 p = ngx_palloc(r->pool, r->exten.len); 938 p = ngx_palloc(r->pool, r->exten.len);
941 if (p == NULL) { 939 if (p == NULL) {
942 return NGX_HTTP_INTERNAL_SERVER_ERROR; 940 return NGX_HTTP_INTERNAL_SERVER_ERROR;
943 } 941 }
944 942
943 hash = 0;
945 exten = p; 944 exten = p;
946 945
947 for (i = 0; i < r->exten.len; i++) { 946 for (i = 0; i < r->exten.len; i++) {
948 c = r->exten.data[i]; 947 c = ngx_tolower(r->exten.data[i]);
949 *p++ = ngx_tolower(c); 948 hash = ngx_hash(hash, c);
949 *p++ = c;
950 } 950 }
951 951
952 r->exten.data = exten; 952 r->exten.data = exten;
953
954 break;
953 } 955 }
954 956
955 r->low_case_exten = 1; 957 hash = ngx_hash(hash, c);
956 } 958 }
957 959
958 type = ngx_hash_find(&clcf->types_hash, 960 type = ngx_hash_find(&clcf->types_hash, hash,
959 ngx_hash_key(r->exten.data, r->exten.len),
960 r->exten.data, r->exten.len); 961 r->exten.data, r->exten.len);
961 962
962 if (type) { 963 if (type) {
963 r->headers_out.content_type = *type; 964 r->headers_out.content_type = *type;
964 return NGX_OK; 965 return NGX_OK;
979 r->exten.len = 0; 980 r->exten.len = 0;
980 r->exten.data = NULL; 981 r->exten.data = NULL;
981 982
982 for (i = r->uri.len - 1; i > 1; i--) { 983 for (i = r->uri.len - 1; i > 1; i--) {
983 if (r->uri.data[i] == '.' && r->uri.data[i - 1] != '/') { 984 if (r->uri.data[i] == '.' && r->uri.data[i - 1] != '/') {
985
984 r->exten.len = r->uri.len - i - 1; 986 r->exten.len = r->uri.len - i - 1;
985 987 r->exten.data = &r->uri.data[i + 1];
986 if (r->exten.len > 0) {
987 r->exten.data = ngx_palloc(r->pool, r->exten.len + 1);
988 if (r->exten.data == NULL) {
989 return NGX_ERROR;
990 }
991
992 ngx_cpystrn(r->exten.data, &r->uri.data[i + 1],
993 r->exten.len + 1);
994 }
995 988
996 break; 989 break;
997 990
998 } else if (r->uri.data[i] == '/') { 991 } else if (r->uri.data[i] == '/') {
999 break; 992 break;
1000 } 993 }
1001 } 994 }
1002
1003 r->low_case_exten = 0;
1004 995
1005 return NGX_OK; 996 return NGX_OK;
1006 } 997 }
1007 998
1008 999