Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 523:2019117e6b38 release-0.1.36
nginx-0.1.36-RELEASE import
*) Change: if the request header has duplicate the "Host",
"Connection", "Content-Length", or "Authorization" lines, then nginx
now returns the 400 error.
*) Change: the "post_accept_timeout" directive was canceled.
*) Feature: the "default", "af=", "bl=", "deferred", and "bind"
parameters of the "listen" directive.
*) Feature: the FreeBSD accept filters support.
*) Feature: the Linux TCP_DEFER_ACCEPT support.
*) Bugfix: the ngx_http_autoindex_module did not support the file names
in UTF-8.
*) Bugfix: the new log file can be rotated by the -USR1 signal only if
the reconfiguration by the -HUP signal was made twice.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 15 Jun 2005 18:33:41 +0000 |
parents | 6f00349b98e5 |
children | 09b42134ac0c |
comparison
equal
deleted
inserted
replaced
522:b59b006291f3 | 523:2019117e6b38 |
---|---|
20 static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, | 20 static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, |
21 ngx_uint_t request_line); | 21 ngx_uint_t request_line); |
22 | 22 |
23 static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r, | 23 static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r, |
24 ngx_table_elt_t *h, ngx_uint_t offset); | 24 ngx_table_elt_t *h, ngx_uint_t offset); |
25 static ngx_int_t ngx_http_process_unique_header_line(ngx_http_request_t *r, | |
26 ngx_table_elt_t *h, ngx_uint_t offset); | |
25 static ngx_int_t ngx_http_process_cookie(ngx_http_request_t *r, | 27 static ngx_int_t ngx_http_process_cookie(ngx_http_request_t *r, |
26 ngx_table_elt_t *h, ngx_uint_t offset); | 28 ngx_table_elt_t *h, ngx_uint_t offset); |
27 | 29 |
28 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); | 30 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); |
29 static ngx_int_t ngx_http_find_virtual_server(ngx_http_request_t *r); | 31 static ngx_int_t ngx_http_find_virtual_server(ngx_http_request_t *r); |
60 }; | 62 }; |
61 | 63 |
62 | 64 |
63 ngx_http_header_t ngx_http_headers_in[] = { | 65 ngx_http_header_t ngx_http_headers_in[] = { |
64 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host), | 66 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host), |
65 ngx_http_process_header_line }, | 67 ngx_http_process_unique_header_line }, |
66 | 68 |
67 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection), | 69 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection), |
68 ngx_http_process_header_line }, | 70 ngx_http_process_unique_header_line }, |
69 | 71 |
70 { ngx_string("If-Modified-Since"), | 72 { ngx_string("If-Modified-Since"), |
71 offsetof(ngx_http_headers_in_t, if_modified_since), | 73 offsetof(ngx_http_headers_in_t, if_modified_since), |
72 ngx_http_process_header_line }, | 74 ngx_http_process_header_line }, |
73 | 75 |
77 { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer), | 79 { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer), |
78 ngx_http_process_header_line }, | 80 ngx_http_process_header_line }, |
79 | 81 |
80 { ngx_string("Content-Length"), | 82 { ngx_string("Content-Length"), |
81 offsetof(ngx_http_headers_in_t, content_length), | 83 offsetof(ngx_http_headers_in_t, content_length), |
82 ngx_http_process_header_line }, | 84 ngx_http_process_unique_header_line }, |
83 | 85 |
84 { ngx_string("Content-Type"), | 86 { ngx_string("Content-Type"), |
85 offsetof(ngx_http_headers_in_t, content_type), | 87 offsetof(ngx_http_headers_in_t, content_type), |
86 ngx_http_process_header_line }, | 88 ngx_http_process_header_line }, |
87 | 89 |
102 ngx_http_process_header_line }, | 104 ngx_http_process_header_line }, |
103 #endif | 105 #endif |
104 | 106 |
105 { ngx_string("Authorization"), | 107 { ngx_string("Authorization"), |
106 offsetof(ngx_http_headers_in_t, authorization), | 108 offsetof(ngx_http_headers_in_t, authorization), |
107 ngx_http_process_header_line }, | 109 ngx_http_process_unique_header_line }, |
108 | 110 |
109 { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive), | 111 { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive), |
110 ngx_http_process_header_line }, | 112 ngx_http_process_header_line }, |
111 | 113 |
112 #if (NGX_HTTP_PROXY) | 114 #if (NGX_HTTP_PROXY) |
113 { ngx_string("X-Forwarded-For"), | 115 { ngx_string("X-Forwarded-For"), |
114 offsetof(ngx_http_headers_in_t, x_forwarded_for), | 116 offsetof(ngx_http_headers_in_t, x_forwarded_for), |
115 ngx_http_process_header_line }, | |
116 | |
117 { ngx_string("X-Real-IP"), offsetof(ngx_http_headers_in_t, x_real_ip), | |
118 ngx_http_process_header_line }, | |
119 | |
120 { ngx_string("X-URL"), offsetof(ngx_http_headers_in_t, x_url), | |
121 ngx_http_process_header_line }, | 117 ngx_http_process_header_line }, |
122 #endif | 118 #endif |
123 | 119 |
124 #if (NGX_HTTP_HEADERS) | 120 #if (NGX_HTTP_HEADERS) |
125 { ngx_string("Accept"), offsetof(ngx_http_headers_in_t, accept), | 121 { ngx_string("Accept"), offsetof(ngx_http_headers_in_t, accept), |
904 | 900 |
905 if (n > 0) { | 901 if (n > 0) { |
906 return n; | 902 return n; |
907 } | 903 } |
908 | 904 |
909 if (!rev->ready) { | 905 if (rev->ready) { |
910 return NGX_AGAIN; | 906 n = r->connection->recv(r->connection, r->header_in->last, |
911 } | 907 r->header_in->end - r->header_in->last); |
912 | 908 } else { |
913 n = r->connection->recv(r->connection, r->header_in->last, | 909 n = NGX_AGAIN; |
914 r->header_in->end - r->header_in->last); | 910 } |
915 | 911 |
916 if (n == NGX_AGAIN) { | 912 if (n == NGX_AGAIN) { |
917 if (!r->header_timeout_set) { | 913 if (!r->header_timeout_set) { |
918 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | 914 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
919 ngx_add_timer(rev, cscf->client_header_timeout); | 915 ngx_add_timer(rev, cscf->client_header_timeout); |
1105 return NGX_OK; | 1101 return NGX_OK; |
1106 } | 1102 } |
1107 | 1103 |
1108 | 1104 |
1109 static ngx_int_t | 1105 static ngx_int_t |
1106 ngx_http_process_unique_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, | |
1107 ngx_uint_t offset) | |
1108 { | |
1109 ngx_table_elt_t **ph; | |
1110 | |
1111 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
1112 | |
1113 if (*ph == NULL) { | |
1114 *ph = h; | |
1115 return NGX_OK; | |
1116 } | |
1117 | |
1118 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
1119 "client sent duplicate header line: \"%V: %V\"", | |
1120 &h->key, &h->value); | |
1121 | |
1122 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
1123 | |
1124 return NGX_ERROR; | |
1125 } | |
1126 | |
1127 | |
1128 static ngx_int_t | |
1110 ngx_http_process_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, | 1129 ngx_http_process_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, |
1111 ngx_uint_t offset) | 1130 ngx_uint_t offset) |
1112 { | 1131 { |
1113 ngx_table_elt_t **cookie; | 1132 ngx_table_elt_t **cookie; |
1114 | 1133 |
1115 cookie = ngx_array_push(&r->headers_in.cookies); | 1134 cookie = ngx_array_push(&r->headers_in.cookies); |
1116 if (cookie == NULL) { | 1135 if (cookie) { |
1117 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 1136 *cookie = h; |
1118 ngx_http_close_connection(r->connection); | 1137 return NGX_OK; |
1119 return NGX_ERROR; | 1138 } |
1120 } | 1139 |
1121 | 1140 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1122 *cookie = h; | 1141 ngx_http_close_connection(r->connection); |
1123 | 1142 |
1124 return NGX_OK; | 1143 return NGX_ERROR; |
1125 } | 1144 } |
1126 | 1145 |
1127 | 1146 |
1128 static ngx_int_t | 1147 static ngx_int_t |
1129 ngx_http_process_request_header(ngx_http_request_t *r) | 1148 ngx_http_process_request_header(ngx_http_request_t *r) |