Mercurial > hg > nginx-ranges
comparison src/http/ngx_http_request.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 | 8759b346e431 |
children | d2ae1c9f1fd3 |
comparison
equal
deleted
inserted
replaced
197:93658b91fad2 | 198:e6da4931e0e0 |
---|---|
23 ngx_table_elt_t *h, ngx_uint_t offset); | 23 ngx_table_elt_t *h, ngx_uint_t offset); |
24 static ngx_int_t ngx_http_process_cookie(ngx_http_request_t *r, | 24 static ngx_int_t ngx_http_process_cookie(ngx_http_request_t *r, |
25 ngx_table_elt_t *h, ngx_uint_t offset); | 25 ngx_table_elt_t *h, ngx_uint_t offset); |
26 | 26 |
27 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); | 27 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); |
28 static void ngx_http_find_virtual_server(ngx_http_request_t *r); | 28 static void ngx_http_find_virtual_server(ngx_http_request_t *r, |
29 ngx_http_virtual_names_t *vn, ngx_uint_t hash); | |
29 | 30 |
30 static void ngx_http_request_handler(ngx_event_t *ev); | 31 static void ngx_http_request_handler(ngx_event_t *ev); |
31 static ngx_int_t ngx_http_set_write_handler(ngx_http_request_t *r); | 32 static ngx_int_t ngx_http_set_write_handler(ngx_http_request_t *r); |
32 static void ngx_http_writer(ngx_http_request_t *r); | 33 static void ngx_http_writer(ngx_http_request_t *r); |
33 | 34 |
737 static void | 738 static void |
738 ngx_http_process_request_headers(ngx_event_t *rev) | 739 ngx_http_process_request_headers(ngx_event_t *rev) |
739 { | 740 { |
740 ssize_t n; | 741 ssize_t n; |
741 ngx_int_t rc, rv; | 742 ngx_int_t rc, rv; |
742 ngx_uint_t key; | |
743 ngx_str_t header; | 743 ngx_str_t header; |
744 ngx_uint_t i; | |
744 ngx_table_elt_t *h; | 745 ngx_table_elt_t *h; |
745 ngx_connection_t *c; | 746 ngx_connection_t *c; |
746 ngx_http_header_t *hh; | 747 ngx_http_header_t *hh; |
747 ngx_http_request_t *r; | 748 ngx_http_request_t *r; |
748 ngx_http_core_srv_conf_t *cscf; | 749 ngx_http_core_srv_conf_t *cscf; |
761 return; | 762 return; |
762 } | 763 } |
763 | 764 |
764 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | 765 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
765 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | 766 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
766 hh = (ngx_http_header_t *) cmcf->headers_in_hash.buckets; | |
767 | 767 |
768 rc = NGX_AGAIN; | 768 rc = NGX_AGAIN; |
769 | 769 |
770 for ( ;; ) { | 770 for ( ;; ) { |
771 | 771 |
839 | 839 |
840 h->value.len = r->header_end - r->header_start; | 840 h->value.len = r->header_end - r->header_start; |
841 h->value.data = r->header_start; | 841 h->value.data = r->header_start; |
842 h->value.data[h->value.len] = '\0'; | 842 h->value.data[h->value.len] = '\0'; |
843 | 843 |
844 key = h->hash % cmcf->headers_in_hash.hash_size; | 844 h->lowcase_key = ngx_palloc(r->pool, h->key.len); |
845 | 845 if (h->lowcase_key == NULL) { |
846 if (hh[key].name.len == h->key.len | 846 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
847 && ngx_strcasecmp(hh[key].name.data, h->key.data) == 0) | 847 return; |
848 { | 848 } |
849 if (hh[key].handler(r, h, hh[key].offset) != NGX_OK) { | 849 |
850 return; | 850 if (h->key.len == r->lowcase_index) { |
851 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
852 | |
853 } else { | |
854 for (i = 0; i < h->key.len; i++) { | |
855 h->lowcase_key[i] = ngx_tolower(h->lowcase_key[i]); | |
851 } | 856 } |
857 } | |
858 | |
859 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, | |
860 h->lowcase_key, h->key.len); | |
861 | |
862 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | |
863 return; | |
852 } | 864 } |
853 | 865 |
854 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 866 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
855 "http header: \"%V: %V\"", | 867 "http header: \"%V: %V\"", |
856 &h->key, &h->value); | 868 &h->key, &h->value); |
1172 static ngx_int_t | 1184 static ngx_int_t |
1173 ngx_http_process_request_header(ngx_http_request_t *r) | 1185 ngx_http_process_request_header(ngx_http_request_t *r) |
1174 { | 1186 { |
1175 size_t len; | 1187 size_t len; |
1176 u_char *ua, *user_agent, ch; | 1188 u_char *ua, *user_agent, ch; |
1189 ngx_uint_t hash; | |
1177 #if (NGX_HTTP_SSL) | 1190 #if (NGX_HTTP_SSL) |
1178 long rc; | 1191 long rc; |
1179 ngx_http_ssl_srv_conf_t *sscf; | 1192 ngx_http_ssl_srv_conf_t *sscf; |
1180 #endif | 1193 #endif |
1181 | 1194 |
1182 if (r->headers_in.host) { | 1195 if (r->headers_in.host) { |
1196 | |
1197 hash = 0; | |
1198 | |
1183 for (len = 0; len < r->headers_in.host->value.len; len++) { | 1199 for (len = 0; len < r->headers_in.host->value.len; len++) { |
1184 ch = r->headers_in.host->value.data[len]; | 1200 ch = r->headers_in.host->value.data[len]; |
1185 | 1201 |
1186 if (ch == ':') { | 1202 if (ch == ':') { |
1187 break; | 1203 break; |
1188 } | 1204 } |
1189 | 1205 |
1190 r->headers_in.host->value.data[len] = ngx_tolower(ch); | 1206 ch = ngx_tolower(ch); |
1191 } | 1207 r->headers_in.host->value.data[len] = ch; |
1192 | 1208 hash = ngx_hash(hash, ch); |
1193 if (r->headers_in.host->value.data[len - 1] == '.') { | 1209 } |
1210 | |
1211 if (len && r->headers_in.host->value.data[len - 1] == '.') { | |
1194 len--; | 1212 len--; |
1213 hash = ngx_hash_key(r->headers_in.host->value.data, len); | |
1195 } | 1214 } |
1196 | 1215 |
1197 r->headers_in.host_name_len = len; | 1216 r->headers_in.host_name_len = len; |
1198 | 1217 |
1199 ngx_http_find_virtual_server(r); | 1218 if (r->virtual_names) { |
1219 ngx_http_find_virtual_server(r, r->virtual_names, hash); | |
1220 } | |
1200 | 1221 |
1201 } else { | 1222 } else { |
1202 if (r->http_version > NGX_HTTP_VERSION_10) { | 1223 if (r->http_version > NGX_HTTP_VERSION_10) { |
1203 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | 1224 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1204 "client sent HTTP/1.1 request without \"Host\" header"); | 1225 "client sent HTTP/1.1 request without \"Host\" header"); |
1343 return NGX_OK; | 1364 return NGX_OK; |
1344 } | 1365 } |
1345 | 1366 |
1346 | 1367 |
1347 static void | 1368 static void |
1348 ngx_http_find_virtual_server(ngx_http_request_t *r) | 1369 ngx_http_find_virtual_server(ngx_http_request_t *r, |
1370 ngx_http_virtual_names_t *vn, ngx_uint_t hash) | |
1349 { | 1371 { |
1350 size_t len; | 1372 size_t len; |
1351 u_char *host; | 1373 u_char *host; |
1352 ngx_http_virtual_names_t *vn; | |
1353 ngx_http_core_loc_conf_t *clcf; | 1374 ngx_http_core_loc_conf_t *clcf; |
1354 ngx_http_core_srv_conf_t *cscf; | 1375 ngx_http_core_srv_conf_t *cscf; |
1355 | 1376 |
1356 vn = r->virtual_names; | |
1357 | |
1358 if (vn == NULL) { | |
1359 return; | |
1360 } | |
1361 | |
1362 host = r->headers_in.host->value.data; | 1377 host = r->headers_in.host->value.data; |
1363 len = r->headers_in.host_name_len; | 1378 len = r->headers_in.host_name_len; |
1364 | 1379 |
1365 /* STUB: ngx_hash_key() here is STUB */ | |
1366 | |
1367 if (vn->hash.buckets) { | 1380 if (vn->hash.buckets) { |
1368 cscf = ngx_hash_find(&vn->hash, ngx_hash_key(host, len), host, len); | 1381 cscf = ngx_hash_find(&vn->hash, hash, host, len); |
1369 if (cscf) { | 1382 if (cscf) { |
1370 goto found; | 1383 goto found; |
1371 } | 1384 } |
1372 } | 1385 } |
1373 | 1386 |