Mercurial > hg > nginx-quic
annotate src/http/ngx_http_request.c @ 5260:e088695737c3
Core: consolidated log-related code.
The stderr redirection code is moved to ngx_log_redirect_stderr().
The opening of the default log code is moved to ngx_log_open_default().
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Fri, 28 Jun 2013 17:24:54 +0400 |
parents | ea2ba6dbe361 |
children | aadfadd5af2b |
rev | line source |
---|---|
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1 |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
439
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
439
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
439
diff
changeset
|
6 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
439
diff
changeset
|
7 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
9 #include <ngx_core.h> |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
11 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
13 static void ngx_http_wait_request_handler(ngx_event_t *ev); |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
14 static void ngx_http_process_request_line(ngx_event_t *rev); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
15 static void ngx_http_process_request_headers(ngx_event_t *rev); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
16 static ssize_t ngx_http_read_request_header(ngx_http_request_t *r); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
17 static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, |
501 | 18 ngx_uint_t request_line); |
509 | 19 |
20 static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r, | |
21 ngx_table_elt_t *h, ngx_uint_t offset); | |
523 | 22 static ngx_int_t ngx_http_process_unique_header_line(ngx_http_request_t *r, |
23 ngx_table_elt_t *h, ngx_uint_t offset); | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
24 static ngx_int_t ngx_http_process_multi_header_lines(ngx_http_request_t *r, |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
25 ngx_table_elt_t *h, ngx_uint_t offset); |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
26 static ngx_int_t ngx_http_process_host(ngx_http_request_t *r, |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
27 ngx_table_elt_t *h, ngx_uint_t offset); |
1467
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
28 static ngx_int_t ngx_http_process_connection(ngx_http_request_t *r, |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
29 ngx_table_elt_t *h, ngx_uint_t offset); |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
30 static ngx_int_t ngx_http_process_user_agent(ngx_http_request_t *r, |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
31 ngx_table_elt_t *h, ngx_uint_t offset); |
509 | 32 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
33 static ngx_int_t ngx_http_validate_host(ngx_str_t *host, ngx_pool_t *pool, |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
34 ngx_uint_t alloc); |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
35 static ngx_int_t ngx_http_set_virtual_server(ngx_http_request_t *r, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
36 ngx_str_t *host); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
37 static ngx_int_t ngx_http_find_virtual_server(ngx_connection_t *c, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
38 ngx_http_virtual_names_t *virtual_names, ngx_str_t *host, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
39 ngx_http_request_t *r, ngx_http_core_srv_conf_t **cscfp); |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
40 |
509 | 41 static void ngx_http_request_handler(ngx_event_t *ev); |
3049 | 42 static void ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc); |
43 static void ngx_http_terminate_handler(ngx_http_request_t *r); | |
44 static void ngx_http_finalize_connection(ngx_http_request_t *r); | |
525 | 45 static ngx_int_t ngx_http_set_write_handler(ngx_http_request_t *r); |
509 | 46 static void ngx_http_writer(ngx_http_request_t *r); |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
47 static void ngx_http_request_finalizer(ngx_http_request_t *r); |
509 | 48 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
49 static void ngx_http_set_keepalive(ngx_http_request_t *r); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
50 static void ngx_http_keepalive_handler(ngx_event_t *ev); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
51 static void ngx_http_set_lingering_close(ngx_http_request_t *r); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
52 static void ngx_http_lingering_close_handler(ngx_event_t *ev); |
613 | 53 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r); |
531 | 54 static void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error); |
2261 | 55 static void ngx_http_log_request(ngx_http_request_t *r); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
56 |
483 | 57 static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len); |
665 | 58 static u_char *ngx_http_log_error_handler(ngx_http_request_t *r, |
59 ngx_http_request_t *sr, u_char *buf, size_t len); | |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
60 |
539 | 61 #if (NGX_HTTP_SSL) |
62 static void ngx_http_ssl_handshake(ngx_event_t *rev); | |
547 | 63 static void ngx_http_ssl_handshake_handler(ngx_connection_t *c); |
539 | 64 #endif |
65 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
66 |
505 | 67 static char *ngx_http_client_errors[] = { |
68 | |
69 /* NGX_HTTP_PARSE_INVALID_METHOD */ | |
70 "client sent invalid method", | |
71 | |
72 /* NGX_HTTP_PARSE_INVALID_REQUEST */ | |
73 "client sent invalid request", | |
74 | |
75 /* NGX_HTTP_PARSE_INVALID_09_METHOD */ | |
76 "client sent invalid method in HTTP/0.9 request" | |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
77 }; |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
78 |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
79 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
80 ngx_http_header_t ngx_http_headers_in[] = { |
2193
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
81 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host), |
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
82 ngx_http_process_host }, |
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
83 |
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
84 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection), |
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
85 ngx_http_process_connection }, |
509 | 86 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
87 { ngx_string("If-Modified-Since"), |
509 | 88 offsetof(ngx_http_headers_in_t, if_modified_since), |
1434
0f0ce9a8eee9
If-Modified-Since should be unique header line
Igor Sysoev <igor@sysoev.ru>
parents:
1427
diff
changeset
|
89 ngx_http_process_unique_header_line }, |
509 | 90 |
3814
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
91 { ngx_string("If-Unmodified-Since"), |
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
92 offsetof(ngx_http_headers_in_t, if_unmodified_since), |
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
93 ngx_http_process_unique_header_line }, |
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
94 |
4744
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
95 { ngx_string("If-Match"), |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
96 offsetof(ngx_http_headers_in_t, if_match), |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
97 ngx_http_process_unique_header_line }, |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
98 |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
99 { ngx_string("If-None-Match"), |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
100 offsetof(ngx_http_headers_in_t, if_none_match), |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
101 ngx_http_process_unique_header_line }, |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
102 |
2193
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
103 { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent), |
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
104 ngx_http_process_user_agent }, |
509 | 105 |
106 { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer), | |
107 ngx_http_process_header_line }, | |
108 | |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
109 { ngx_string("Content-Length"), |
509 | 110 offsetof(ngx_http_headers_in_t, content_length), |
523 | 111 ngx_http_process_unique_header_line }, |
509 | 112 |
479 | 113 { ngx_string("Content-Type"), |
509 | 114 offsetof(ngx_http_headers_in_t, content_type), |
115 ngx_http_process_header_line }, | |
116 | |
117 { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range), | |
118 ngx_http_process_header_line }, | |
119 | |
1630 | 120 { ngx_string("If-Range"), |
121 offsetof(ngx_http_headers_in_t, if_range), | |
122 ngx_http_process_unique_header_line }, | |
123 | |
581 | 124 { ngx_string("Transfer-Encoding"), |
125 offsetof(ngx_http_headers_in_t, transfer_encoding), | |
126 ngx_http_process_header_line }, | |
127 | |
2067 | 128 { ngx_string("Expect"), |
129 offsetof(ngx_http_headers_in_t, expect), | |
130 ngx_http_process_unique_header_line }, | |
131 | |
5072
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
132 { ngx_string("Upgrade"), |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
133 offsetof(ngx_http_headers_in_t, upgrade), |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
134 ngx_http_process_header_line }, |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
135 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
136 #if (NGX_HTTP_GZIP) |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
137 { ngx_string("Accept-Encoding"), |
509 | 138 offsetof(ngx_http_headers_in_t, accept_encoding), |
139 ngx_http_process_header_line }, | |
140 | |
141 { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via), | |
142 ngx_http_process_header_line }, | |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
143 #endif |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
144 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
145 { ngx_string("Authorization"), |
509 | 146 offsetof(ngx_http_headers_in_t, authorization), |
523 | 147 ngx_http_process_unique_header_line }, |
509 | 148 |
149 { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive), | |
150 ngx_http_process_header_line }, | |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
151 |
4697
09187f9b0950
Fixed compile-time conditionals used to detect if X-Forwarded-For support
Ruslan Ermilov <ru@nginx.com>
parents:
4675
diff
changeset
|
152 #if (NGX_HTTP_X_FORWARDED_FOR) |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
153 { ngx_string("X-Forwarded-For"), |
509 | 154 offsetof(ngx_http_headers_in_t, x_forwarded_for), |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
155 ngx_http_process_multi_header_lines }, |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
156 #endif |
479 | 157 |
573 | 158 #if (NGX_HTTP_REALIP) |
159 { ngx_string("X-Real-IP"), | |
160 offsetof(ngx_http_headers_in_t, x_real_ip), | |
161 ngx_http_process_header_line }, | |
162 #endif | |
163 | |
489 | 164 #if (NGX_HTTP_HEADERS) |
509 | 165 { ngx_string("Accept"), offsetof(ngx_http_headers_in_t, accept), |
166 ngx_http_process_header_line }, | |
167 | |
489 | 168 { ngx_string("Accept-Language"), |
509 | 169 offsetof(ngx_http_headers_in_t, accept_language), |
170 ngx_http_process_header_line }, | |
489 | 171 #endif |
172 | |
637 | 173 #if (NGX_HTTP_DAV) |
174 { ngx_string("Depth"), offsetof(ngx_http_headers_in_t, depth), | |
175 ngx_http_process_header_line }, | |
176 | |
177 { ngx_string("Destination"), offsetof(ngx_http_headers_in_t, destination), | |
178 ngx_http_process_header_line }, | |
681 | 179 |
1059 | 180 { ngx_string("Overwrite"), offsetof(ngx_http_headers_in_t, overwrite), |
181 ngx_http_process_header_line }, | |
182 | |
681 | 183 { ngx_string("Date"), offsetof(ngx_http_headers_in_t, date), |
184 ngx_http_process_header_line }, | |
637 | 185 #endif |
186 | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
187 { ngx_string("Cookie"), offsetof(ngx_http_headers_in_t, cookies), |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
188 ngx_http_process_multi_header_lines }, |
509 | 189 |
190 { ngx_null_string, 0, NULL } | |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
191 }; |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
192 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
193 |
501 | 194 void |
195 ngx_http_init_connection(ngx_connection_t *c) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 { |
5085
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
197 ngx_uint_t i; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
198 ngx_event_t *rev; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
199 struct sockaddr_in *sin; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
200 ngx_http_port_t *port; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
201 ngx_http_in_addr_t *addr; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
202 ngx_http_log_ctx_t *ctx; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
203 ngx_http_connection_t *hc; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
204 #if (NGX_HAVE_INET6) |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
205 struct sockaddr_in6 *sin6; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
206 ngx_http_in6_addr_t *addr6; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
207 #endif |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
208 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
209 hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)); |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
210 if (hc == NULL) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
211 ngx_http_close_connection(c); |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
212 return; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
213 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
214 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
215 c->data = hc; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
216 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
217 /* find the server configuration for the address:port */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
218 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
219 port = c->listening->servers; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
220 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
221 if (port->naddrs > 1) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
222 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
223 /* |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
224 * there are several addresses on this port and one of them |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
225 * is an "*:port" wildcard so getsockname() in ngx_http_server_addr() |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
226 * is required to determine a server address |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
227 */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
228 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
229 if (ngx_connection_local_sockaddr(c, NULL, 0) != NGX_OK) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
230 ngx_http_close_connection(c); |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
231 return; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
232 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
233 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
234 switch (c->local_sockaddr->sa_family) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
235 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
236 #if (NGX_HAVE_INET6) |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
237 case AF_INET6: |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
238 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
239 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
240 addr6 = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
241 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
242 /* the last address is "*" */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
243 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
244 for (i = 0; i < port->naddrs - 1; i++) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
245 if (ngx_memcmp(&addr6[i].addr6, &sin6->sin6_addr, 16) == 0) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
246 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
247 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
248 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
249 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
250 hc->addr_conf = &addr6[i].conf; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
251 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
252 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
253 #endif |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
254 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
255 default: /* AF_INET */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
256 sin = (struct sockaddr_in *) c->local_sockaddr; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
257 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
258 addr = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
259 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
260 /* the last address is "*" */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
261 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
262 for (i = 0; i < port->naddrs - 1; i++) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
263 if (addr[i].addr == sin->sin_addr.s_addr) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
264 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
265 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
266 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
267 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
268 hc->addr_conf = &addr[i].conf; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
269 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
270 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
271 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
272 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
273 } else { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
274 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
275 switch (c->local_sockaddr->sa_family) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
276 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
277 #if (NGX_HAVE_INET6) |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
278 case AF_INET6: |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
279 addr6 = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
280 hc->addr_conf = &addr6[0].conf; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
281 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
282 #endif |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
283 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
284 default: /* AF_INET */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
285 addr = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
286 hc->addr_conf = &addr[0].conf; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
287 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
288 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
289 } |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
290 |
5089
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
291 /* the default server configuration for the address:port */ |
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
292 hc->conf_ctx = hc->addr_conf->default_server->ctx; |
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
293 |
501 | 294 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); |
295 if (ctx == NULL) { | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
296 ngx_http_close_connection(c); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
297 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
298 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
299 |
1810 | 300 ctx->connection = c; |
461 | 301 ctx->request = NULL; |
665 | 302 ctx->current_request = NULL; |
483 | 303 |
304 c->log->connection = c->number; | |
305 c->log->handler = ngx_http_log_error; | |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
189
diff
changeset
|
306 c->log->data = ctx; |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
307 c->log->action = "waiting for request"; |
483 | 308 |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
309 c->log_error = NGX_ERROR_INFO; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
310 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
311 rev = c->read; |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
312 rev->handler = ngx_http_wait_request_handler; |
569 | 313 c->write->handler = ngx_http_empty_handler; |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
314 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
315 #if (NGX_HTTP_SPDY) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
316 if (hc->addr_conf->spdy) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
317 rev->handler = ngx_http_spdy_init; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
318 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
319 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
320 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
321 #if (NGX_HTTP_SSL) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
322 { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
323 ngx_http_ssl_srv_conf_t *sscf; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
324 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
325 sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
326 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
327 if (sscf->enable || hc->addr_conf->ssl) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
328 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
329 c->log->action = "SSL handshaking"; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
330 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
331 if (hc->addr_conf->ssl && sscf->ssl.ctx == NULL) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
332 ngx_log_error(NGX_LOG_ERR, c->log, 0, |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
333 "no \"ssl_certificate\" is defined " |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
334 "in server listening on SSL port"); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
335 ngx_http_close_connection(c); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
336 return; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
337 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
338 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
339 hc->ssl = 1; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
340 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
341 rev->handler = ngx_http_ssl_handshake; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
342 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
343 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
344 #endif |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
345 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
346 if (rev->ready) { |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
347 /* the deferred accept(), rtsig, aio, iocp */ |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
348 |
611 | 349 if (ngx_use_accept_mutex) { |
563 | 350 ngx_post_event(rev, &ngx_posted_events); |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
351 return; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
352 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
353 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
354 rev->handler(rev); |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
355 return; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
55
diff
changeset
|
356 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
357 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
358 ngx_add_timer(rev, c->listening->post_accept_timeout); |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
359 ngx_reusable_connection(c, 1); |
53
d1e42f1b8fd4
nginx-0.0.1-2003-01-27-00:08:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
52
diff
changeset
|
360 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
361 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
362 ngx_http_close_connection(c); |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
363 return; |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
364 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
365 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
366 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
367 |
641 | 368 static void |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
369 ngx_http_wait_request_handler(ngx_event_t *rev) |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
370 { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
371 size_t size; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
372 ssize_t n; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
373 ngx_buf_t *b; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
374 ngx_connection_t *c; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
375 ngx_http_connection_t *hc; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
376 ngx_http_core_srv_conf_t *cscf; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
377 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
378 c = rev->data; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
379 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
380 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http wait request handler"); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
381 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
382 if (rev->timedout) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
383 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
384 ngx_http_close_connection(c); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
385 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
386 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
387 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
388 if (c->close) { |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
389 ngx_http_close_connection(c); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
390 return; |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
391 } |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
392 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
393 hc = c->data; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
394 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
395 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
396 size = cscf->client_header_buffer_size; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
397 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
398 b = c->buffer; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
399 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
400 if (b == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
401 b = ngx_create_temp_buf(c->pool, size); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
402 if (b == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
403 ngx_http_close_connection(c); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
404 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
405 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
406 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
407 c->buffer = b; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
408 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
409 } else if (b->start == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
410 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
411 b->start = ngx_palloc(c->pool, size); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
412 if (b->start == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
413 ngx_http_close_connection(c); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
414 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
415 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
416 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
417 b->pos = b->start; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
418 b->last = b->start; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
419 b->end = b->last + size; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
420 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
421 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
422 n = c->recv(c, b->last, size); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
423 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
424 if (n == NGX_AGAIN) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
425 |
5103
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
426 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
427 if (c->listening->deferred_accept |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
428 #if (NGX_HTTP_SSL) |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
429 && c->ssl == NULL |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
430 #endif |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
431 ) |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
432 { |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
433 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
434 "client timed out in deferred accept"); |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
435 ngx_http_close_connection(c); |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
436 return; |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
437 } |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
438 #endif |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
439 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
440 if (!rev->timer_set) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
441 ngx_add_timer(rev, c->listening->post_accept_timeout); |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
442 ngx_reusable_connection(c, 1); |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
443 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
444 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
445 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
446 ngx_http_close_connection(c); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
447 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
448 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
449 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
450 /* |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
451 * We are trying to not hold c->buffer's memory for an idle connection. |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
452 */ |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
453 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
454 if (ngx_pfree(c->pool, b->start) == NGX_OK) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
455 b->start = NULL; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
456 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
457 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
458 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
459 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
460 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
461 if (n == NGX_ERROR) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
462 ngx_http_close_connection(c); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
463 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
464 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
465 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
466 if (n == 0) { |
5109
44bd04fbbb4f
Fixed logging in ngx_http_wait_request_handler().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5105
diff
changeset
|
467 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
468 "client closed connection"); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
469 ngx_http_close_connection(c); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
470 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
471 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
472 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
473 b->last += n; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
474 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
475 c->log->action = "reading client request line"; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
476 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
477 ngx_reusable_connection(c, 0); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
478 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
479 c->data = ngx_http_create_request(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
480 if (c->data == NULL) { |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
481 ngx_http_close_connection(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
482 return; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
483 } |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
484 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
485 rev->handler = ngx_http_process_request_line; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
486 ngx_http_process_request_line(rev); |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
487 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
488 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
489 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
490 ngx_http_request_t * |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
491 ngx_http_create_request(ngx_connection_t *c) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
492 { |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
493 ngx_pool_t *pool; |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
494 ngx_time_t *tp; |
573 | 495 ngx_http_request_t *r; |
496 ngx_http_log_ctx_t *ctx; | |
497 ngx_http_connection_t *hc; | |
498 ngx_http_core_srv_conf_t *cscf; | |
499 ngx_http_core_loc_conf_t *clcf; | |
500 ngx_http_core_main_conf_t *cmcf; | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
501 |
2888 | 502 c->requests++; |
503 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
504 hc = c->data; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
505 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
506 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module); |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
507 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
508 pool = ngx_create_pool(cscf->request_pool_size, c->log); |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
509 if (pool == NULL) { |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
510 return NULL; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
511 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
512 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
513 r = ngx_pcalloc(pool, sizeof(ngx_http_request_t)); |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
514 if (r == NULL) { |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
515 ngx_destroy_pool(pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
516 return NULL; |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
517 } |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
518 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
519 r->pool = pool; |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
520 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
521 r->http_connection = hc; |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
522 r->signature = NGX_HTTP_MODULE; |
1805 | 523 r->connection = c; |
524 | |
5089
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
525 r->main_conf = hc->conf_ctx->main_conf; |
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
526 r->srv_conf = hc->conf_ctx->srv_conf; |
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
527 r->loc_conf = hc->conf_ctx->loc_conf; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
528 |
3000
66ef86affbb8
fix segfault if 400 or 414 errors are handled intricately
Igor Sysoev <igor@sysoev.ru>
parents:
2994
diff
changeset
|
529 r->read_event_handler = ngx_http_block_reading; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
530 |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
531 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
5086
1b204b8ea9a3
Introduced the ngx_http_set_connection_log() macro.
Valentin Bartenev <vbart@nginx.com>
parents:
5085
diff
changeset
|
532 |
1b204b8ea9a3
Introduced the ngx_http_set_connection_log() macro.
Valentin Bartenev <vbart@nginx.com>
parents:
5085
diff
changeset
|
533 ngx_http_set_connection_log(r->connection, clcf->error_log); |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
534 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
535 r->header_in = hc->nbusy ? hc->busy[0] : c->buffer; |
294
5cfd65b8b0a7
nginx-0.0.3-2004-03-23-09:01:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
293
diff
changeset
|
536 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
537 if (ngx_list_init(&r->headers_out.headers, r->pool, 20, |
581 | 538 sizeof(ngx_table_elt_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2534
diff
changeset
|
539 != NGX_OK) |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
540 { |
2902
a1a1c7e3fb8d
fix "out of memory" case handling
Igor Sysoev <igor@sysoev.ru>
parents:
2888
diff
changeset
|
541 ngx_destroy_pool(r->pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
542 return NULL; |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
543 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
544 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
545 r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
546 if (r->ctx == NULL) { |
2902
a1a1c7e3fb8d
fix "out of memory" case handling
Igor Sysoev <igor@sysoev.ru>
parents:
2888
diff
changeset
|
547 ngx_destroy_pool(r->pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
548 return NULL; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
549 } |
10
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
550 |
573 | 551 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
552 | |
553 r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts | |
554 * sizeof(ngx_http_variable_value_t)); | |
555 if (r->variables == NULL) { | |
2902
a1a1c7e3fb8d
fix "out of memory" case handling
Igor Sysoev <igor@sysoev.ru>
parents:
2888
diff
changeset
|
556 ngx_destroy_pool(r->pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
557 return NULL; |
573 | 558 } |
559 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
560 #if (NGX_HTTP_SSL) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
561 if (c->ssl) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
562 r->main_filter_need_in_memory = 1; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
563 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
564 #endif |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
565 |
553 | 566 r->main = r; |
3049 | 567 r->count = 1; |
553 | 568 |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
569 tp = ngx_timeofday(); |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
570 r->start_sec = tp->sec; |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
571 r->start_msec = tp->msec; |
497 | 572 |
631 | 573 r->method = NGX_HTTP_UNKNOWN; |
574 | |
82
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
575 r->headers_in.content_length_n = -1; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
576 r->headers_in.keep_alive_n = -1; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
577 r->headers_out.content_length_n = -1; |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
578 r->headers_out.last_modified_time = -1; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
579 |
675 | 580 r->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1; |
581 r->subrequests = NGX_HTTP_MAX_SUBREQUESTS + 1; | |
582 | |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
583 r->http_state = NGX_HTTP_READING_REQUEST_STATE; |
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
584 |
505 | 585 ctx = c->log->data; |
586 ctx->request = r; | |
665 | 587 ctx->current_request = r; |
509 | 588 r->log_handler = ngx_http_log_error_handler; |
505 | 589 |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
590 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
591 (void) ngx_atomic_fetch_add(ngx_stat_reading, 1); |
477 | 592 r->stat_reading = 1; |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
593 (void) ngx_atomic_fetch_add(ngx_stat_requests, 1); |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
594 #endif |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
595 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
596 return r; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
597 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
598 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
599 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
600 #if (NGX_HTTP_SSL) |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
601 |
501 | 602 static void |
603 ngx_http_ssl_handshake(ngx_event_t *rev) | |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
604 { |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
605 u_char buf[1]; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
606 ssize_t n; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
607 ngx_err_t err; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
608 ngx_int_t rc; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
609 ngx_connection_t *c; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
610 ngx_http_connection_t *hc; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
611 ngx_http_ssl_srv_conf_t *sscf; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
612 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
613 c = rev->data; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
614 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
615 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
616 "http check ssl handshake"); |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
617 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
618 if (rev->timedout) { |
505 | 619 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
620 ngx_http_close_connection(c); |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
621 return; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
622 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
623 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
624 if (c->close) { |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
625 ngx_http_close_connection(c); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
626 return; |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
627 } |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
628 |
583 | 629 n = recv(c->fd, (char *) buf, 1, MSG_PEEK); |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
630 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
631 err = ngx_socket_errno; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
632 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
633 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http recv(): %d", n); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
634 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
635 if (n == -1) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
636 if (err == NGX_EAGAIN) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
637 |
5103
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
638 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
639 if (c->listening->deferred_accept) { |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
640 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
641 "client timed out in deferred accept"); |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
642 ngx_http_close_connection(c); |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
643 return; |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
644 } |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
645 #endif |
05a56ebb084a
Respect the new behavior of TCP_DEFER_ACCEPT.
Valentin Bartenev <vbart@nginx.com>
parents:
5102
diff
changeset
|
646 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
647 if (!rev->timer_set) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
648 ngx_add_timer(rev, c->listening->post_accept_timeout); |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
649 ngx_reusable_connection(c, 1); |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
650 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
651 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
652 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
653 ngx_http_close_connection(c); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
654 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
655 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
656 return; |
1855 | 657 } |
658 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
659 ngx_connection_error(c, err, "recv() failed"); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
660 ngx_http_close_connection(c); |
1858 | 661 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
662 return; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
663 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
664 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
665 if (n == 1) { |
3674
37715361263a
fix recognition of SSLv2 Client Hello Packet large than 255 bytes
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
666 if (buf[0] & 0x80 /* SSLv2 */ || buf[0] == 0x16 /* SSLv3/TLSv1 */) { |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
667 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
461 | 668 "https ssl handshake: 0x%02Xd", buf[0]); |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
669 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
670 hc = c->data; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
671 sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
672 ngx_http_ssl_module); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
673 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
674 if (ngx_ssl_create_connection(&sscf->ssl, c, NGX_SSL_BUFFER) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
675 != NGX_OK) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
676 { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
677 ngx_http_close_connection(c); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
678 return; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
679 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
680 |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
681 rc = ngx_ssl_handshake(c); |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
682 |
547 | 683 if (rc == NGX_AGAIN) { |
1829
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
684 |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
685 if (!rev->timer_set) { |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
686 ngx_add_timer(rev, c->listening->post_accept_timeout); |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
687 } |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
688 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
689 ngx_reusable_connection(c, 0); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
690 |
547 | 691 c->ssl->handler = ngx_http_ssl_handshake_handler; |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
692 return; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
693 } |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
694 |
547 | 695 ngx_http_ssl_handshake_handler(c); |
696 | |
697 return; | |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
698 } |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
699 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
700 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "plain http"); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
701 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
702 c->log->action = "waiting for request"; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
703 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
704 rev->handler = ngx_http_wait_request_handler; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
705 ngx_http_wait_request_handler(rev); |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
706 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
707 return; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
708 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
709 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
710 ngx_log_error(NGX_LOG_INFO, c->log, 0, "client closed connection"); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
711 ngx_http_close_connection(c); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
712 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
713 |
547 | 714 |
715 static void | |
716 ngx_http_ssl_handshake_handler(ngx_connection_t *c) | |
717 { | |
718 if (c->ssl->handshaked) { | |
719 | |
720 /* | |
721 * The majority of browsers do not send the "close notify" alert. | |
722 * Among them are MSIE, old Mozilla, Netscape 4, Konqueror, | |
723 * and Links. And what is more, MSIE ignores the server's alert. | |
724 * | |
725 * Opera and recent Mozilla send the alert. | |
726 */ | |
727 | |
728 c->ssl->no_wait_shutdown = 1; | |
729 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
730 #if (NGX_HTTP_SPDY && defined TLSEXT_TYPE_next_proto_neg) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
731 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
732 unsigned int len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
733 const unsigned char *data; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
734 static const ngx_str_t spdy = ngx_string(NGX_SPDY_NPN_NEGOTIATED); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
735 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
736 SSL_get0_next_proto_negotiated(c->ssl->connection, &data, &len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
737 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
738 if (len == spdy.len && ngx_strncmp(data, spdy.data, spdy.len) == 0) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
739 ngx_http_spdy_init(c->read); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
740 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
741 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
742 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
743 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
744 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
745 c->log->action = "waiting for request"; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
746 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
747 c->read->handler = ngx_http_wait_request_handler; |
547 | 748 /* STUB: epoll edge */ c->write->handler = ngx_http_empty_handler; |
749 | |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
750 ngx_reusable_connection(c, 1); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
751 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
752 ngx_http_wait_request_handler(c->read); |
547 | 753 |
754 return; | |
755 } | |
756 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
757 if (c->read->timedout) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
758 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
759 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
760 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
761 ngx_http_close_connection(c); |
547 | 762 } |
763 | |
1219 | 764 #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME |
765 | |
766 int | |
767 ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg) | |
768 { | |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
769 ngx_str_t host; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
770 const char *servername; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
771 ngx_connection_t *c; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
772 ngx_http_connection_t *hc; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
773 ngx_http_ssl_srv_conf_t *sscf; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
774 ngx_http_core_loc_conf_t *clcf; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
775 ngx_http_core_srv_conf_t *cscf; |
1219 | 776 |
777 servername = SSL_get_servername(ssl_conn, TLSEXT_NAMETYPE_host_name); | |
778 | |
779 if (servername == NULL) { | |
780 return SSL_TLSEXT_ERR_NOACK; | |
781 } | |
782 | |
783 c = ngx_ssl_get_connection(ssl_conn); | |
784 | |
785 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
786 "SSL server name: \"%s\"", servername); | |
787 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
788 host.len = ngx_strlen(servername); |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
789 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
790 if (host.len == 0) { |
2195 | 791 return SSL_TLSEXT_ERR_NOACK; |
792 } | |
793 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
794 host.data = (u_char *) servername; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
795 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
796 if (ngx_http_validate_host(&host, c->pool, 1) != NGX_OK) { |
3152 | 797 return SSL_TLSEXT_ERR_NOACK; |
798 } | |
799 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
800 hc = c->data; |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
801 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
802 if (ngx_http_find_virtual_server(c, hc->addr_conf->virtual_names, &host, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
803 NULL, &cscf) |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
804 != NGX_OK) |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
805 { |
1219 | 806 return SSL_TLSEXT_ERR_NOACK; |
807 } | |
808 | |
5093
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
809 hc->ssl_servername = ngx_palloc(c->pool, sizeof(ngx_str_t)); |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
810 if (hc->ssl_servername == NULL) { |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
811 return SSL_TLSEXT_ERR_NOACK; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
812 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
813 |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
814 *hc->ssl_servername = host; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
815 |
5089
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
816 hc->conf_ctx = cscf->ctx; |
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
817 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
818 clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module); |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
819 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
820 ngx_http_set_connection_log(c, clcf->error_log); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
821 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
822 sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module); |
1219 | 823 |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
824 if (sscf->ssl.ctx) { |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
825 SSL_set_SSL_CTX(ssl_conn, sscf->ssl.ctx); |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
826 |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
827 /* |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
828 * SSL_set_SSL_CTX() only changes certs as of 1.0.0d |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
829 * adjust other things we care about |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
830 */ |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
831 |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
832 SSL_set_verify(ssl_conn, SSL_CTX_get_verify_mode(sscf->ssl.ctx), |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
833 SSL_CTX_get_verify_callback(sscf->ssl.ctx)); |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
834 |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
835 SSL_set_verify_depth(ssl_conn, SSL_CTX_get_verify_depth(sscf->ssl.ctx)); |
4033
4e1a489c26cd
Better handling of various per-server ssl options with SNI.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3985
diff
changeset
|
836 |
4e1a489c26cd
Better handling of various per-server ssl options with SNI.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3985
diff
changeset
|
837 #ifdef SSL_CTRL_CLEAR_OPTIONS |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
838 /* only in 0.9.8m+ */ |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
839 SSL_clear_options(ssl_conn, SSL_get_options(ssl_conn) & |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
840 ~SSL_CTX_get_options(sscf->ssl.ctx)); |
4033
4e1a489c26cd
Better handling of various per-server ssl options with SNI.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3985
diff
changeset
|
841 #endif |
4e1a489c26cd
Better handling of various per-server ssl options with SNI.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3985
diff
changeset
|
842 |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
843 SSL_set_options(ssl_conn, SSL_CTX_get_options(sscf->ssl.ctx)); |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
844 } |
4033
4e1a489c26cd
Better handling of various per-server ssl options with SNI.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3985
diff
changeset
|
845 |
1219 | 846 return SSL_TLSEXT_ERR_OK; |
847 } | |
848 | |
849 #endif | |
547 | 850 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
851 #endif |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
852 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
853 |
501 | 854 static void |
855 ngx_http_process_request_line(ngx_event_t *rev) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
856 { |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
857 ssize_t n; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
858 ngx_int_t rc, rv; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
859 ngx_str_t host; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
860 ngx_connection_t *c; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
861 ngx_http_request_t *r; |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
862 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
863 c = rev->data; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
864 r = c->data; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
865 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
866 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
867 "http process request line"); |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
868 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
869 if (rev->timedout) { |
505 | 870 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
871 c->timedout = 1; | |
872 ngx_http_close_request(r, NGX_HTTP_REQUEST_TIME_OUT); | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
873 return; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
874 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
875 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
876 rc = NGX_AGAIN; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
877 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
878 for ( ;; ) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
879 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
880 if (rc == NGX_AGAIN) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
881 n = ngx_http_read_request_header(r); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
882 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
883 if (n == NGX_AGAIN || n == NGX_ERROR) { |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
884 return; |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
885 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
886 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
887 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
888 rc = ngx_http_parse_request_line(r, r->header_in); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
889 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
890 if (rc == NGX_OK) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
891 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
892 /* the request line has been parsed successfully */ |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
893 |
461 | 894 r->request_line.len = r->request_end - r->request_start; |
895 r->request_line.data = r->request_start; | |
4739
986cc869b09d
Corrected $request_length calculation for pipelined requests.
Andrey Belov <defan@nginx.com>
parents:
4697
diff
changeset
|
896 r->request_length = r->header_in->pos - r->request_start; |
461 | 897 |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
898 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
899 "http request line: \"%V\"", &r->request_line); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
900 |
509 | 901 r->method_name.len = r->method_end - r->request_start + 1; |
902 r->method_name.data = r->request_line.data; | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
903 |
479 | 904 if (r->http_protocol.data) { |
905 r->http_protocol.len = r->request_end - r->http_protocol.data; | |
906 } | |
907 | |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
908 if (ngx_http_process_request_uri(r) != NGX_OK) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
909 return; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
910 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
911 |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
912 if (r->host_start && r->host_end) { |
3152 | 913 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
914 host.len = r->host_end - r->host_start; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
915 host.data = r->host_start; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
916 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
917 rc = ngx_http_validate_host(&host, r->pool, 0); |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
918 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
919 if (rc == NGX_DECLINED) { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
920 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
921 "client sent invalid host in request line"); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
922 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
923 return; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
924 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
925 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
926 if (rc == NGX_ERROR) { |
3152 | 927 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
928 return; | |
929 } | |
930 | |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
931 if (ngx_http_set_virtual_server(r, &host) == NGX_ERROR) { |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
932 return; |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
933 } |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
934 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
935 r->headers_in.server = host; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
936 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
937 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
938 if (r->http_version < NGX_HTTP_VERSION_10) { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
939 |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
940 if (r->headers_in.server.len == 0 |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
941 && ngx_http_set_virtual_server(r, &r->headers_in.server) |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
942 == NGX_ERROR) |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
943 { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
944 return; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
945 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
946 |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
947 ngx_http_process_request(r); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
948 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
949 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
950 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
951 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
952 if (ngx_list_init(&r->headers_in.headers, r->pool, 20, |
581 | 953 sizeof(ngx_table_elt_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2534
diff
changeset
|
954 != NGX_OK) |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
955 { |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
956 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
957 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
958 } |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
959 |
483 | 960 c->log->action = "reading client request headers"; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
961 |
509 | 962 rev->handler = ngx_http_process_request_headers; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
963 ngx_http_process_request_headers(rev); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
964 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
965 return; |
505 | 966 } |
967 | |
968 if (rc != NGX_AGAIN) { | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
969 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
970 /* there was error while a request line parsing */ |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
971 |
505 | 972 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
973 ngx_http_client_errors[rc - NGX_HTTP_CLIENT_ERROR]); | |
974 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
975 return; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
976 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
977 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
978 /* NGX_AGAIN: a request line parsing is still incomplete */ |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
979 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
980 if (r->header_in->pos == r->header_in->end) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
981 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
982 rv = ngx_http_alloc_large_header_buffer(r, 1); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
983 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
984 if (rv == NGX_ERROR) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
985 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
986 return; |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
987 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
988 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
989 if (rv == NGX_DECLINED) { |
505 | 990 r->request_line.len = r->header_in->end - r->request_start; |
991 r->request_line.data = r->request_start; | |
992 | |
993 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
994 "client sent too long URI"); | |
995 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_URI_TOO_LARGE); | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
996 return; |
66
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
997 } |
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
998 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
999 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1000 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1001 |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
1002 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1003 ngx_int_t |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1004 ngx_http_process_request_uri(ngx_http_request_t *r) |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1005 { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1006 ngx_http_core_srv_conf_t *cscf; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1007 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1008 if (r->args_start) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1009 r->uri.len = r->args_start - 1 - r->uri_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1010 } else { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1011 r->uri.len = r->uri_end - r->uri_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1012 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1013 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1014 if (r->complex_uri || r->quoted_uri) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1015 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1016 r->uri.data = ngx_pnalloc(r->pool, r->uri.len + 1); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1017 if (r->uri.data == NULL) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1018 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1019 return NGX_ERROR; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1020 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1021 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1022 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1023 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1024 if (ngx_http_parse_complex_uri(r, cscf->merge_slashes) != NGX_OK) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1025 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1026 "client sent invalid request"); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1027 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1028 return NGX_ERROR; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1029 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1030 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1031 } else { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1032 r->uri.data = r->uri_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1033 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1034 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1035 r->unparsed_uri.len = r->uri_end - r->uri_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1036 r->unparsed_uri.data = r->uri_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1037 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1038 r->valid_unparsed_uri = r->space_in_uri ? 0 : 1; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1039 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1040 if (r->uri_ext) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1041 if (r->args_start) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1042 r->exten.len = r->args_start - 1 - r->uri_ext; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1043 } else { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1044 r->exten.len = r->uri_end - r->uri_ext; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1045 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1046 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1047 r->exten.data = r->uri_ext; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1048 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1049 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1050 if (r->args_start && r->uri_end > r->args_start) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1051 r->args.len = r->uri_end - r->args_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1052 r->args.data = r->args_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1053 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1054 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1055 #if (NGX_WIN32) |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1056 { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1057 u_char *p, *last; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1058 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1059 p = r->uri.data; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1060 last = r->uri.data + r->uri.len; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1061 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1062 while (p < last) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1063 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1064 if (*p++ == ':') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1065 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1066 /* |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1067 * this check covers "::$data", "::$index_allocation" and |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1068 * ":$i30:$index_allocation" |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1069 */ |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1070 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1071 if (p < last && *p == '$') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1072 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1073 "client sent unsafe win32 URI"); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1074 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1075 return NGX_ERROR; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1076 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1077 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1078 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1079 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1080 p = r->uri.data + r->uri.len - 1; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1081 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1082 while (p > r->uri.data) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1083 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1084 if (*p == ' ') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1085 p--; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1086 continue; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1087 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1088 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1089 if (*p == '.') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1090 p--; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1091 continue; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1092 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1093 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1094 break; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1095 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1096 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1097 if (p != r->uri.data + r->uri.len - 1) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1098 r->uri.len = p + 1 - r->uri.data; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1099 ngx_http_set_exten(r); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1100 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1101 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1102 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1103 #endif |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1104 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1105 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1106 "http uri: \"%V\"", &r->uri); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1107 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1108 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1109 "http args: \"%V\"", &r->args); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1110 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1111 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1112 "http exten: \"%V\"", &r->exten); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1113 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1114 return NGX_OK; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1115 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1116 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1117 |
501 | 1118 static void |
1119 ngx_http_process_request_headers(ngx_event_t *rev) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1120 { |
3076 | 1121 u_char *p; |
1122 size_t len; | |
507 | 1123 ssize_t n; |
1124 ngx_int_t rc, rv; | |
509 | 1125 ngx_table_elt_t *h; |
507 | 1126 ngx_connection_t *c; |
1127 ngx_http_header_t *hh; | |
1128 ngx_http_request_t *r; | |
511 | 1129 ngx_http_core_srv_conf_t *cscf; |
507 | 1130 ngx_http_core_main_conf_t *cmcf; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
1131 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1132 c = rev->data; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1133 r = c->data; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1134 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1135 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1136 "http process request header line"); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1137 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1138 if (rev->timedout) { |
505 | 1139 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
1140 c->timedout = 1; | |
1141 ngx_http_close_request(r, NGX_HTTP_REQUEST_TIME_OUT); | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1142 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1143 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1144 |
507 | 1145 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
1146 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1147 rc = NGX_AGAIN; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1148 |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
1149 for ( ;; ) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1150 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1151 if (rc == NGX_AGAIN) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1152 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1153 if (r->header_in->pos == r->header_in->end) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1154 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1155 rv = ngx_http_alloc_large_header_buffer(r, 0); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1156 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1157 if (rv == NGX_ERROR) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1158 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1159 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1160 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1161 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1162 if (rv == NGX_DECLINED) { |
3076 | 1163 p = r->header_name_start; |
1164 | |
3848
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1165 r->lingering_close = 1; |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1166 |
3287
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1167 if (p == NULL) { |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1168 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1169 "client sent too large request"); |
3848
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1170 ngx_http_finalize_request(r, |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1171 NGX_HTTP_REQUEST_HEADER_TOO_LARGE); |
3287
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1172 return; |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1173 } |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1174 |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1175 len = r->header_in->end - p; |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1176 |
3076 | 1177 if (len > NGX_MAX_ERROR_STR - 300) { |
1178 len = NGX_MAX_ERROR_STR - 300; | |
1179 p[len++] = '.'; p[len++] = '.'; p[len++] = '.'; | |
531 | 1180 } |
1181 | |
505 | 1182 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
3076 | 1183 "client sent too long header line: \"%*s\"", |
1184 len, r->header_name_start); | |
3848
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1185 |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1186 ngx_http_finalize_request(r, |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1187 NGX_HTTP_REQUEST_HEADER_TOO_LARGE); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1188 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1189 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1190 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1191 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1192 n = ngx_http_read_request_header(r); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1193 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1194 if (n == NGX_AGAIN || n == NGX_ERROR) { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1195 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1196 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1197 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1198 |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1199 /* the host header could change the server configuration context */ |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1200 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1201 |
2256 | 1202 rc = ngx_http_parse_header_line(r, r->header_in, |
1203 cscf->underscores_in_headers); | |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
1204 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1205 if (rc == NGX_OK) { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1206 |
4739
986cc869b09d
Corrected $request_length calculation for pipelined requests.
Andrey Belov <defan@nginx.com>
parents:
4697
diff
changeset
|
1207 r->request_length += r->header_in->pos - r->header_name_start; |
986cc869b09d
Corrected $request_length calculation for pipelined requests.
Andrey Belov <defan@nginx.com>
parents:
4697
diff
changeset
|
1208 |
511 | 1209 if (r->invalid_header && cscf->ignore_invalid_headers) { |
503 | 1210 |
1211 /* there was error while a header line parsing */ | |
1212 | |
505 | 1213 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
3076 | 1214 "client sent invalid header line: \"%*s\"", |
1215 r->header_end - r->header_name_start, | |
1216 r->header_name_start); | |
503 | 1217 continue; |
1218 } | |
1219 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1220 /* a header line has been parsed successfully */ |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1221 |
501 | 1222 h = ngx_list_push(&r->headers_in.headers); |
1223 if (h == NULL) { | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1224 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1225 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1226 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1227 |
507 | 1228 h->hash = r->header_hash; |
1229 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1230 h->key.len = r->header_name_end - r->header_name_start; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1231 h->key.data = r->header_name_start; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1232 h->key.data[h->key.len] = '\0'; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1233 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1234 h->value.len = r->header_end - r->header_start; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1235 h->value.data = r->header_start; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1236 h->value.data[h->value.len] = '\0'; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
1237 |
2049 | 1238 h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); |
649 | 1239 if (h->lowcase_key == NULL) { |
1240 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
1241 return; | |
1242 } | |
1243 | |
1244 if (h->key.len == r->lowcase_index) { | |
1245 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1246 | |
1247 } else { | |
2135 | 1248 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1249 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1250 |
649 | 1251 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, |
1252 h->lowcase_key, h->key.len); | |
1253 | |
1254 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | |
1255 return; | |
1256 } | |
1257 | |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
1258 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 1259 "http header: \"%V: %V\"", |
1260 &h->key, &h->value); | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1261 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
1262 continue; |
505 | 1263 } |
1264 | |
1265 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
1266 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1267 /* a whole header has been parsed successfully */ |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
1268 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
1269 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
1270 "http header done"); |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
1271 |
4739
986cc869b09d
Corrected $request_length calculation for pipelined requests.
Andrey Belov <defan@nginx.com>
parents:
4697
diff
changeset
|
1272 r->request_length += r->header_in->pos - r->header_name_start; |
475 | 1273 |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
1274 r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE; |
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
1275 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1276 rc = ngx_http_process_request_header(r); |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
1277 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1278 if (rc != NGX_OK) { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1279 return; |
82
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
1280 } |
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
1281 |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1282 ngx_http_process_request(r); |
537 | 1283 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1284 return; |
505 | 1285 } |
1286 | |
1287 if (rc == NGX_AGAIN) { | |
1288 | |
1289 /* a header line parsing is still not complete */ | |
1290 | |
1291 continue; | |
66
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
1292 } |
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
1293 |
505 | 1294 /* rc == NGX_HTTP_PARSE_INVALID_HEADER: "\r" is not followed by "\n" */ |
1295 | |
1296 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
3076 | 1297 "client sent invalid header line: \"%*s\\r...\"", |
1298 r->header_end - r->header_name_start, | |
1299 r->header_name_start); | |
1427 | 1300 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
505 | 1301 return; |
19
d7908993fdeb
nginx-0.0.1-2002-12-02-19:09:40 import; resume after 2 months stall
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
1302 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
1303 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
1304 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
1305 |
501 | 1306 static ssize_t |
1307 ngx_http_read_request_header(ngx_http_request_t *r) | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1308 { |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
1309 ssize_t n; |
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
1310 ngx_event_t *rev; |
681 | 1311 ngx_connection_t *c; |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
1312 ngx_http_core_srv_conf_t *cscf; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1313 |
681 | 1314 c = r->connection; |
1315 rev = c->read; | |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
1316 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1317 n = r->header_in->last - r->header_in->pos; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1318 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1319 if (n > 0) { |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1320 return n; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1321 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1322 |
523 | 1323 if (rev->ready) { |
681 | 1324 n = c->recv(c, r->header_in->last, |
1325 r->header_in->end - r->header_in->last); | |
523 | 1326 } else { |
1327 n = NGX_AGAIN; | |
189
c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
1328 } |
c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
1329 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1330 if (n == NGX_AGAIN) { |
1856
11d12ef106a9
axe old flag remained after ancient "post_accept_timeout" directive
Igor Sysoev <igor@sysoev.ru>
parents:
1855
diff
changeset
|
1331 if (!rev->timer_set) { |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1332 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
1333 ngx_add_timer(rev, cscf->client_header_timeout); |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1334 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1335 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
1336 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
1337 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
1338 return NGX_ERROR; |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
1339 } |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
1340 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1341 return NGX_AGAIN; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1342 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1343 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1344 if (n == 0) { |
681 | 1345 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4552
diff
changeset
|
1346 "client prematurely closed connection"); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1347 } |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1348 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1349 if (n == 0 || n == NGX_ERROR) { |
991 | 1350 c->error = 1; |
992 | 1351 c->log->action = "reading client request headers"; |
681 | 1352 |
991 | 1353 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1354 return NGX_ERROR; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1355 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1356 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1357 r->header_in->last += n; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1358 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1359 return n; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1360 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1361 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1362 |
501 | 1363 static ngx_int_t |
1364 ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, | |
1365 ngx_uint_t request_line) | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1366 { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1367 u_char *old, *new; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1368 ngx_buf_t *b; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1369 ngx_http_connection_t *hc; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1370 ngx_http_core_srv_conf_t *cscf; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1371 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1372 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1373 "http alloc large header buffer"); |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1374 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1375 if (request_line && r->state == 0) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1376 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1377 /* the client fills up the buffer with "\r\n" */ |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1378 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1379 r->header_in->pos = r->header_in->start; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1380 r->header_in->last = r->header_in->start; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1381 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1382 return NGX_OK; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1383 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1384 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1385 old = request_line ? r->request_start : r->header_name_start; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1386 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1387 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1388 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1389 if (r->state != 0 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1390 && (size_t) (r->header_in->pos - old) |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1391 >= cscf->large_client_header_buffers.size) |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1392 { |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1393 return NGX_DECLINED; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1394 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1395 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1396 hc = r->http_connection; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1397 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1398 if (hc->nfree) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1399 b = hc->free[--hc->nfree]; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1400 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1401 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 1402 "http large header free: %p %uz", |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1403 b->pos, b->end - b->last); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1404 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1405 } else if (hc->nbusy < cscf->large_client_header_buffers.num) { |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1406 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1407 if (hc->busy == NULL) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1408 hc->busy = ngx_palloc(r->connection->pool, |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1409 cscf->large_client_header_buffers.num * sizeof(ngx_buf_t *)); |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1410 if (hc->busy == NULL) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1411 return NGX_ERROR; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1412 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1413 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1414 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1415 b = ngx_create_temp_buf(r->connection->pool, |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1416 cscf->large_client_header_buffers.size); |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1417 if (b == NULL) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1418 return NGX_ERROR; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1419 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1420 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1421 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 1422 "http large header alloc: %p %uz", |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1423 b->pos, b->end - b->last); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1424 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1425 } else { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1426 return NGX_DECLINED; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1427 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1428 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1429 hc->busy[hc->nbusy++] = b; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1430 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1431 if (r->state == 0) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1432 /* |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1433 * r->state == 0 means that a header line was parsed successfully |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1434 * and we do not need to copy incomplete header line and |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1435 * to relocate the parser header pointers |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1436 */ |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1437 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1438 r->header_in = b; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1439 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1440 return NGX_OK; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1441 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1442 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1443 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1444 "http large header copy: %d", r->header_in->pos - old); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1445 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1446 new = b->start; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1447 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1448 ngx_memcpy(new, old, r->header_in->pos - old); |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1449 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1450 b->pos = new + (r->header_in->pos - old); |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1451 b->last = new + (r->header_in->pos - old); |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1452 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1453 if (request_line) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1454 r->request_start = new; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1455 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1456 if (r->request_end) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1457 r->request_end = new + (r->request_end - old); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1458 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1459 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1460 r->method_end = new + (r->method_end - old); |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1461 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1462 r->uri_start = new + (r->uri_start - old); |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1463 r->uri_end = new + (r->uri_end - old); |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1464 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1465 if (r->schema_start) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1466 r->schema_start = new + (r->schema_start - old); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1467 r->schema_end = new + (r->schema_end - old); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1468 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1469 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1470 if (r->host_start) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1471 r->host_start = new + (r->host_start - old); |
928
a6fe6bedb9e3
fix segfault when $host is used and
Igor Sysoev <igor@sysoev.ru>
parents:
895
diff
changeset
|
1472 if (r->host_end) { |
a6fe6bedb9e3
fix segfault when $host is used and
Igor Sysoev <igor@sysoev.ru>
parents:
895
diff
changeset
|
1473 r->host_end = new + (r->host_end - old); |
a6fe6bedb9e3
fix segfault when $host is used and
Igor Sysoev <igor@sysoev.ru>
parents:
895
diff
changeset
|
1474 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1475 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1476 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1477 if (r->port_start) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1478 r->port_start = new + (r->port_start - old); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1479 r->port_end = new + (r->port_end - old); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1480 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1481 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1482 if (r->uri_ext) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1483 r->uri_ext = new + (r->uri_ext - old); |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1484 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1485 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1486 if (r->args_start) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1487 r->args_start = new + (r->args_start - old); |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1488 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1489 |
1677
c997912a8f0b
copy protocol value when large request line is copied,
Igor Sysoev <igor@sysoev.ru>
parents:
1676
diff
changeset
|
1490 if (r->http_protocol.data) { |
c997912a8f0b
copy protocol value when large request line is copied,
Igor Sysoev <igor@sysoev.ru>
parents:
1676
diff
changeset
|
1491 r->http_protocol.data = new + (r->http_protocol.data - old); |
c997912a8f0b
copy protocol value when large request line is copied,
Igor Sysoev <igor@sysoev.ru>
parents:
1676
diff
changeset
|
1492 } |
c997912a8f0b
copy protocol value when large request line is copied,
Igor Sysoev <igor@sysoev.ru>
parents:
1676
diff
changeset
|
1493 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1494 } else { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1495 r->header_name_start = new; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1496 r->header_name_end = new + (r->header_name_end - old); |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1497 r->header_start = new + (r->header_start - old); |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1498 r->header_end = new + (r->header_end - old); |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1499 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1500 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1501 r->header_in = b; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1502 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1503 return NGX_OK; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1504 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1505 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1506 |
501 | 1507 static ngx_int_t |
509 | 1508 ngx_http_process_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, |
1509 ngx_uint_t offset) | |
1510 { | |
1511 ngx_table_elt_t **ph; | |
1512 | |
1513 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
1514 | |
1515 if (*ph == NULL) { | |
1516 *ph = h; | |
1517 } | |
1518 | |
1519 return NGX_OK; | |
1520 } | |
1521 | |
1522 | |
1523 static ngx_int_t | |
523 | 1524 ngx_http_process_unique_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, |
1525 ngx_uint_t offset) | |
1526 { | |
1527 ngx_table_elt_t **ph; | |
1528 | |
1529 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
1530 | |
1531 if (*ph == NULL) { | |
1532 *ph = h; | |
1533 return NGX_OK; | |
1534 } | |
1535 | |
1536 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
681 | 1537 "client sent duplicate header line: \"%V: %V\", " |
1538 "previous value: \"%V: %V\"", | |
1539 &h->key, &h->value, &(*ph)->key, &(*ph)->value); | |
523 | 1540 |
1541 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
1542 | |
1543 return NGX_ERROR; | |
1544 } | |
1545 | |
1546 | |
1547 static ngx_int_t | |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1548 ngx_http_process_host(ngx_http_request_t *r, ngx_table_elt_t *h, |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1549 ngx_uint_t offset) |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1550 { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1551 ngx_int_t rc; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1552 ngx_str_t host; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1553 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1554 if (r->headers_in.host == NULL) { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1555 r->headers_in.host = h; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1556 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1557 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1558 host = h->value; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1559 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1560 rc = ngx_http_validate_host(&host, r->pool, 0); |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1561 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1562 if (rc == NGX_DECLINED) { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1563 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1564 "client sent invalid host header"); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1565 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1566 return NGX_ERROR; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1567 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1568 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1569 if (rc == NGX_ERROR) { |
3152 | 1570 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1571 return NGX_ERROR; | |
1572 } | |
1573 | |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1574 if (r->headers_in.server.len) { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1575 return NGX_OK; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1576 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1577 |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1578 if (ngx_http_set_virtual_server(r, &host) == NGX_ERROR) { |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1579 return NGX_ERROR; |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1580 } |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1581 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1582 r->headers_in.server = host; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1583 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1584 return NGX_OK; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1585 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1586 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1587 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1588 static ngx_int_t |
1467
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1589 ngx_http_process_connection(ngx_http_request_t *r, ngx_table_elt_t *h, |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1590 ngx_uint_t offset) |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1591 { |
1549 | 1592 if (ngx_strcasestrn(h->value.data, "close", 5 - 1)) { |
1467
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1593 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE; |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1594 |
1549 | 1595 } else if (ngx_strcasestrn(h->value.data, "keep-alive", 10 - 1)) { |
1467
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1596 r->headers_in.connection_type = NGX_HTTP_CONNECTION_KEEP_ALIVE; |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1597 } |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1598 |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1599 return NGX_OK; |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1600 } |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1601 |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1602 |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1603 static ngx_int_t |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1604 ngx_http_process_user_agent(ngx_http_request_t *r, ngx_table_elt_t *h, |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1605 ngx_uint_t offset) |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1606 { |
2205 | 1607 u_char *user_agent, *msie; |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1608 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1609 if (r->headers_in.user_agent) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1610 return NGX_OK; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1611 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1612 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1613 r->headers_in.user_agent = h; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1614 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1615 /* check some widespread browsers while the header is in CPU cache */ |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1616 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1617 user_agent = h->value.data; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1618 |
2205 | 1619 msie = ngx_strstrn(user_agent, "MSIE ", 5 - 1); |
1620 | |
1621 if (msie && msie + 7 < user_agent + h->value.len) { | |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1622 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1623 r->headers_in.msie = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1624 |
2205 | 1625 if (msie[6] == '.') { |
1626 | |
1627 switch (msie[5]) { | |
1628 case '4': | |
1629 case '5': | |
3054
a137de814516
do not disable gzip for MSIE 6.0 SV1 in "gzip_disable msie6"
Igor Sysoev <igor@sysoev.ru>
parents:
3052
diff
changeset
|
1630 r->headers_in.msie6 = 1; |
a137de814516
do not disable gzip for MSIE 6.0 SV1 in "gzip_disable msie6"
Igor Sysoev <igor@sysoev.ru>
parents:
3052
diff
changeset
|
1631 break; |
2205 | 1632 case '6': |
3054
a137de814516
do not disable gzip for MSIE 6.0 SV1 in "gzip_disable msie6"
Igor Sysoev <igor@sysoev.ru>
parents:
3052
diff
changeset
|
1633 if (ngx_strstrn(msie + 8, "SV1", 3 - 1) == NULL) { |
a137de814516
do not disable gzip for MSIE 6.0 SV1 in "gzip_disable msie6"
Igor Sysoev <igor@sysoev.ru>
parents:
3052
diff
changeset
|
1634 r->headers_in.msie6 = 1; |
a137de814516
do not disable gzip for MSIE 6.0 SV1 in "gzip_disable msie6"
Igor Sysoev <igor@sysoev.ru>
parents:
3052
diff
changeset
|
1635 } |
a137de814516
do not disable gzip for MSIE 6.0 SV1 in "gzip_disable msie6"
Igor Sysoev <igor@sysoev.ru>
parents:
3052
diff
changeset
|
1636 break; |
2205 | 1637 } |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1638 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1639 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1640 #if 0 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1641 /* MSIE ignores the SSL "close notify" alert */ |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1642 if (c->ssl) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1643 c->ssl->no_send_shutdown = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1644 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1645 #endif |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1646 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1647 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1648 if (ngx_strstrn(user_agent, "Opera", 5 - 1)) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1649 r->headers_in.opera = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1650 r->headers_in.msie = 0; |
2205 | 1651 r->headers_in.msie6 = 0; |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1652 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1653 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1654 if (!r->headers_in.msie && !r->headers_in.opera) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1655 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1656 if (ngx_strstrn(user_agent, "Gecko/", 6 - 1)) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1657 r->headers_in.gecko = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1658 |
3315 | 1659 } else if (ngx_strstrn(user_agent, "Chrome/", 7 - 1)) { |
1660 r->headers_in.chrome = 1; | |
1661 | |
4552
b00098cbc44d
Restricted keepalive_disable safari to OS X only.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4472
diff
changeset
|
1662 } else if (ngx_strstrn(user_agent, "Safari/", 7 - 1) |
b00098cbc44d
Restricted keepalive_disable safari to OS X only.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4472
diff
changeset
|
1663 && ngx_strstrn(user_agent, "Mac OS X", 8 - 1)) |
b00098cbc44d
Restricted keepalive_disable safari to OS X only.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4472
diff
changeset
|
1664 { |
3419
fcd72b8d69f3
disable keepalive for Safari:
Igor Sysoev <igor@sysoev.ru>
parents:
3416
diff
changeset
|
1665 r->headers_in.safari = 1; |
fcd72b8d69f3
disable keepalive for Safari:
Igor Sysoev <igor@sysoev.ru>
parents:
3416
diff
changeset
|
1666 |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1667 } else if (ngx_strstrn(user_agent, "Konqueror", 9 - 1)) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1668 r->headers_in.konqueror = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1669 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1670 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1671 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1672 return NGX_OK; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1673 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1674 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1675 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1676 static ngx_int_t |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1677 ngx_http_process_multi_header_lines(ngx_http_request_t *r, ngx_table_elt_t *h, |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1678 ngx_uint_t offset) |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1679 { |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1680 ngx_array_t *headers; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1681 ngx_table_elt_t **ph; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1682 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1683 headers = (ngx_array_t *) ((char *) &r->headers_in + offset); |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1684 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1685 if (headers->elts == NULL) { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1686 if (ngx_array_init(headers, r->pool, 1, sizeof(ngx_table_elt_t *)) |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1687 != NGX_OK) |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1688 { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1689 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1690 return NGX_ERROR; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1691 } |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1692 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1693 |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1694 ph = ngx_array_push(headers); |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1695 if (ph == NULL) { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1696 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1697 return NGX_ERROR; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1698 } |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1699 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1700 *ph = h; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
1701 return NGX_OK; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1702 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1703 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1704 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1705 ngx_int_t |
501 | 1706 ngx_http_process_request_header(ngx_http_request_t *r) |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1707 { |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1708 if (r->headers_in.server.len == 0 |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1709 && ngx_http_set_virtual_server(r, &r->headers_in.server) |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1710 == NGX_ERROR) |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1711 { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1712 return NGX_ERROR; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1713 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1714 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1715 if (r->headers_in.host == NULL && r->http_version > NGX_HTTP_VERSION_10) { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1716 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1717 "client sent HTTP/1.1 request without \"Host\" header"); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1718 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1719 return NGX_ERROR; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1720 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1721 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1722 if (r->headers_in.content_length) { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1723 r->headers_in.content_length_n = |
663 | 1724 ngx_atoof(r->headers_in.content_length->value.data, |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1725 r->headers_in.content_length->value.len); |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1726 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1727 if (r->headers_in.content_length_n == NGX_ERROR) { |
505 | 1728 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1729 "client sent invalid \"Content-Length\" header"); | |
4930
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1730 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
505 | 1731 return NGX_ERROR; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1732 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1733 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1734 |
1464 | 1735 if (r->method & NGX_HTTP_TRACE) { |
1151 | 1736 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1737 "client sent TRACE method"); | |
1738 ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED); | |
1739 return NGX_ERROR; | |
1740 } | |
1741 | |
4930
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1742 if (r->headers_in.transfer_encoding) { |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1743 if (r->headers_in.transfer_encoding->value.len == 7 |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1744 && ngx_strncasecmp(r->headers_in.transfer_encoding->value.data, |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1745 (u_char *) "chunked", 7) == 0) |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1746 { |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1747 r->headers_in.content_length = NULL; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1748 r->headers_in.content_length_n = -1; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1749 r->headers_in.chunked = 1; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1750 |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1751 } else if (r->headers_in.transfer_encoding->value.len != 8 |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1752 || ngx_strncasecmp(r->headers_in.transfer_encoding->value.data, |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1753 (u_char *) "identity", 8) != 0) |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1754 { |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1755 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1756 "client sent unknown \"Transfer-Encoding\": \"%V\"", |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1757 &r->headers_in.transfer_encoding->value); |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1758 ngx_http_finalize_request(r, NGX_HTTP_NOT_IMPLEMENTED); |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1759 return NGX_ERROR; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
1760 } |
298
4a3f18406832
nginx-0.0.3-2004-03-30-10:27:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
1761 } |
4a3f18406832
nginx-0.0.3-2004-03-30-10:27:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
1762 |
1467
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1763 if (r->headers_in.connection_type == NGX_HTTP_CONNECTION_KEEP_ALIVE) { |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1764 if (r->headers_in.keep_alive) { |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1765 r->headers_in.keep_alive_n = |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1766 ngx_atotm(r->headers_in.keep_alive->value.data, |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1767 r->headers_in.keep_alive->value.len); |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1768 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1769 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1770 |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1771 return NGX_OK; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1772 } |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1773 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1774 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1775 void |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1776 ngx_http_process_request(ngx_http_request_t *r) |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1777 { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1677
diff
changeset
|
1778 ngx_connection_t *c; |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1779 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1780 c = r->connection; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1781 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1782 #if (NGX_HTTP_SSL) |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1783 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1784 if (r->http_connection->ssl) { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1677
diff
changeset
|
1785 long rc; |
1974
f32cc6df6bd6
fix memory leak when ssl_verify_client is on
Igor Sysoev <igor@sysoev.ru>
parents:
1924
diff
changeset
|
1786 X509 *cert; |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1677
diff
changeset
|
1787 ngx_http_ssl_srv_conf_t *sscf; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1677
diff
changeset
|
1788 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1789 if (c->ssl == NULL) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1790 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1791 "client sent plain HTTP request to HTTPS port"); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1792 ngx_http_finalize_request(r, NGX_HTTP_TO_HTTPS); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1793 return; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1794 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1795 |
669 | 1796 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); |
1797 | |
2994 | 1798 if (sscf->verify) { |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1799 rc = SSL_get_verify_result(c->ssl->connection); |
669 | 1800 |
4884
e406c997470a
SSL: the "ssl_verify_client" directive parameter "optional_no_ca".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4770
diff
changeset
|
1801 if (rc != X509_V_OK |
e406c997470a
SSL: the "ssl_verify_client" directive parameter "optional_no_ca".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4770
diff
changeset
|
1802 && (sscf->verify != 3 || !ngx_ssl_verify_error_optional(rc))) |
e406c997470a
SSL: the "ssl_verify_client" directive parameter "optional_no_ca".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4770
diff
changeset
|
1803 { |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1804 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
671 | 1805 "client SSL certificate verify error: (%l:%s)", |
669 | 1806 rc, X509_verify_cert_error_string(rc)); |
1924
291689a7e5dc
invalidate SSL session if there is no valid client certificate
Igor Sysoev <igor@sysoev.ru>
parents:
1894
diff
changeset
|
1807 |
291689a7e5dc
invalidate SSL session if there is no valid client certificate
Igor Sysoev <igor@sysoev.ru>
parents:
1894
diff
changeset
|
1808 ngx_ssl_remove_cached_session(sscf->ssl.ctx, |
291689a7e5dc
invalidate SSL session if there is no valid client certificate
Igor Sysoev <igor@sysoev.ru>
parents:
1894
diff
changeset
|
1809 (SSL_get0_session(c->ssl->connection))); |
291689a7e5dc
invalidate SSL session if there is no valid client certificate
Igor Sysoev <igor@sysoev.ru>
parents:
1894
diff
changeset
|
1810 |
669 | 1811 ngx_http_finalize_request(r, NGX_HTTPS_CERT_ERROR); |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1812 return; |
669 | 1813 } |
1814 | |
2994 | 1815 if (sscf->verify == 1) { |
1816 cert = SSL_get_peer_certificate(c->ssl->connection); | |
1817 | |
1818 if (cert == NULL) { | |
1819 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
1820 "client sent no required SSL certificate"); | |
1821 | |
1822 ngx_ssl_remove_cached_session(sscf->ssl.ctx, | |
1924
291689a7e5dc
invalidate SSL session if there is no valid client certificate
Igor Sysoev <igor@sysoev.ru>
parents:
1894
diff
changeset
|
1823 (SSL_get0_session(c->ssl->connection))); |
291689a7e5dc
invalidate SSL session if there is no valid client certificate
Igor Sysoev <igor@sysoev.ru>
parents:
1894
diff
changeset
|
1824 |
2994 | 1825 ngx_http_finalize_request(r, NGX_HTTPS_NO_CERT); |
1826 return; | |
1827 } | |
1828 | |
1829 X509_free(cert); | |
669 | 1830 } |
1831 } | |
1832 } | |
1833 | |
1834 #endif | |
1835 | |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1836 if (c->read->timer_set) { |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1837 ngx_del_timer(c->read); |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1838 } |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1839 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1840 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
1841 (void) ngx_atomic_fetch_add(ngx_stat_reading, -1); |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1842 r->stat_reading = 0; |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
1843 (void) ngx_atomic_fetch_add(ngx_stat_writing, 1); |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1844 r->stat_writing = 1; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1845 #endif |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1846 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1847 c->read->handler = ngx_http_request_handler; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1848 c->write->handler = ngx_http_request_handler; |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
1849 r->read_event_handler = ngx_http_block_reading; |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1850 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1851 ngx_http_handler(r); |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1852 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
1853 ngx_http_run_posted_requests(c); |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1854 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1855 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1856 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1857 static ngx_int_t |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1858 ngx_http_validate_host(ngx_str_t *host, ngx_pool_t *pool, ngx_uint_t alloc) |
477 | 1859 { |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1860 u_char *h, ch; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1861 size_t i, dot_pos, host_len; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1862 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1863 enum { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1864 sw_usual = 0, |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1865 sw_literal, |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1866 sw_rest |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1867 } state; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1868 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1869 dot_pos = host->len; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1870 host_len = host->len; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1871 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1872 h = host->data; |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1873 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1874 state = sw_usual; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1875 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1876 for (i = 0; i < host->len; i++) { |
3152 | 1877 ch = h[i]; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1878 |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1879 switch (ch) { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1880 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1881 case '.': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1882 if (dot_pos == i - 1) { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1883 return NGX_DECLINED; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1884 } |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1885 dot_pos = i; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1886 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1887 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1888 case ':': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1889 if (state == sw_usual) { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1890 host_len = i; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1891 state = sw_rest; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1892 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1893 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1894 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1895 case '[': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1896 if (i == 0) { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1897 state = sw_literal; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1898 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1899 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1900 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1901 case ']': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1902 if (state == sw_literal) { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1903 host_len = i + 1; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1904 state = sw_rest; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1905 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1906 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1907 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1908 case '\0': |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1909 return NGX_DECLINED; |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1910 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1911 default: |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1912 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1913 if (ngx_path_separator(ch)) { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1914 return NGX_DECLINED; |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1915 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1916 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1917 if (ch >= 'A' && ch <= 'Z') { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1918 alloc = 1; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1919 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1920 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1921 break; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1922 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1923 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1924 |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1925 if (dot_pos == host_len - 1) { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
1926 host_len--; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1927 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1928 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1929 if (host_len == 0) { |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1930 return NGX_DECLINED; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1931 } |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1932 |
3152 | 1933 if (alloc) { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1934 host->data = ngx_pnalloc(pool, host_len); |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1935 if (host->data == NULL) { |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1936 return NGX_ERROR; |
3152 | 1937 } |
1938 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1939 ngx_strlow(host->data, h, host_len); |
3152 | 1940 } |
1941 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1942 host->len = host_len; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1943 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1944 return NGX_OK; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1945 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1946 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1947 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1948 static ngx_int_t |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1949 ngx_http_set_virtual_server(ngx_http_request_t *r, ngx_str_t *host) |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1950 { |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1951 ngx_int_t rc; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1952 ngx_http_connection_t *hc; |
593 | 1953 ngx_http_core_loc_conf_t *clcf; |
1954 ngx_http_core_srv_conf_t *cscf; | |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1955 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1956 hc = r->http_connection; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1957 |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
1958 #if (NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME) |
5093
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1959 |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1960 if (hc->ssl_servername) { |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1961 if (hc->ssl_servername->len == host->len |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1962 && ngx_strncmp(hc->ssl_servername->data, |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1963 host->data, host->len) == 0) |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1964 { |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1965 #if (NGX_PCRE) |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1966 if (hc->ssl_servername_regex |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1967 && ngx_http_regex_exec(r, hc->ssl_servername_regex, |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1968 hc->ssl_servername) != NGX_OK) |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1969 { |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1970 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1971 return NGX_ERROR; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1972 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1973 #endif |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1974 return NGX_OK; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1975 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1976 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1977 |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1978 #endif |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1979 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1980 rc = ngx_http_find_virtual_server(r->connection, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1981 hc->addr_conf->virtual_names, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1982 host, r, &cscf); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1983 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1984 if (rc == NGX_ERROR) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1985 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1986 return NGX_ERROR; |
477 | 1987 } |
1988 | |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
1989 #if (NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME) |
5094
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
1990 |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
1991 if (hc->ssl_servername) { |
5095
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
1992 ngx_http_ssl_srv_conf_t *sscf; |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
1993 |
5094
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
1994 if (rc == NGX_DECLINED) { |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
1995 cscf = hc->addr_conf->default_server; |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
1996 rc = NGX_OK; |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
1997 } |
5095
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
1998 |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
1999 sscf = ngx_http_get_module_srv_conf(cscf->ctx, ngx_http_ssl_module); |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2000 |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2001 if (sscf->verify) { |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2002 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2003 "client attempted to request the server name " |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2004 "different from that one was negotiated"); |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2005 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2006 return NGX_ERROR; |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2007 } |
5094
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2008 } |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2009 |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2010 #endif |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2011 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2012 if (rc == NGX_DECLINED) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2013 return NGX_OK; |
1387 | 2014 } |
2015 | |
593 | 2016 r->srv_conf = cscf->ctx->srv_conf; |
2017 r->loc_conf = cscf->ctx->loc_conf; | |
509 | 2018 |
2019 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
5086
1b204b8ea9a3
Introduced the ngx_http_set_connection_log() macro.
Valentin Bartenev <vbart@nginx.com>
parents:
5085
diff
changeset
|
2020 |
1b204b8ea9a3
Introduced the ngx_http_set_connection_log() macro.
Valentin Bartenev <vbart@nginx.com>
parents:
5085
diff
changeset
|
2021 ngx_http_set_connection_log(r->connection, clcf->error_log); |
477 | 2022 |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2023 return NGX_OK; |
477 | 2024 } |
2025 | |
2026 | |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2027 static ngx_int_t |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2028 ngx_http_find_virtual_server(ngx_connection_t *c, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2029 ngx_http_virtual_names_t *virtual_names, ngx_str_t *host, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2030 ngx_http_request_t *r, ngx_http_core_srv_conf_t **cscfp) |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2031 { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2032 ngx_http_core_srv_conf_t *cscf; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2033 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2034 if (virtual_names == NULL) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2035 return NGX_DECLINED; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2036 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2037 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2038 cscf = ngx_hash_find_combined(&virtual_names->names, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2039 ngx_hash_key(host->data, host->len), |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2040 host->data, host->len); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2041 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2042 if (cscf) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2043 *cscfp = cscf; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2044 return NGX_OK; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2045 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2046 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2047 #if (NGX_PCRE) |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2048 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2049 if (host->len && virtual_names->nregex) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2050 ngx_int_t n; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2051 ngx_uint_t i; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2052 ngx_http_server_name_t *sn; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2053 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2054 sn = virtual_names->regex; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2055 |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2056 #if (NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME) |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2057 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2058 if (r == NULL) { |
5093
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2059 ngx_http_connection_t *hc; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2060 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2061 for (i = 0; i < virtual_names->nregex; i++) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2062 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2063 n = ngx_regex_exec(sn[i].regex->regex, host, NULL, 0); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2064 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2065 if (n == NGX_REGEX_NO_MATCHED) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2066 continue; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2067 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2068 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2069 if (n >= 0) { |
5093
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2070 hc = c->data; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2071 hc->ssl_servername_regex = sn[i].regex; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2072 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2073 *cscfp = sn[i].server; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2074 return NGX_OK; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2075 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2076 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2077 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2078 ngx_regex_exec_n " failed: %i " |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2079 "on \"%V\" using \"%V\"", |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2080 n, host, &sn[i].regex->name); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2081 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2082 return NGX_ERROR; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2083 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2084 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2085 return NGX_DECLINED; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2086 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2087 |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2088 #endif /* NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME */ |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2089 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2090 for (i = 0; i < virtual_names->nregex; i++) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2091 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2092 n = ngx_http_regex_exec(r, sn[i].regex, host); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2093 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2094 if (n == NGX_DECLINED) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2095 continue; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2096 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2097 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2098 if (n == NGX_OK) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2099 *cscfp = sn[i].server; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2100 return NGX_OK; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2101 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2102 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2103 return NGX_ERROR; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2104 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2105 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2106 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2107 #endif /* NGX_PCRE */ |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2108 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2109 return NGX_DECLINED; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2110 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2111 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2112 |
509 | 2113 static void |
2114 ngx_http_request_handler(ngx_event_t *ev) | |
2115 { | |
2116 ngx_connection_t *c; | |
2117 ngx_http_request_t *r; | |
665 | 2118 ngx_http_log_ctx_t *ctx; |
509 | 2119 |
2120 c = ev->data; | |
2121 r = c->data; | |
2122 | |
665 | 2123 ctx = c->log->data; |
2124 ctx->current_request = r; | |
2125 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2126 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2127 "http run request: \"%V?%V\"", &r->uri, &r->args); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2128 |
509 | 2129 if (ev->write) { |
2130 r->write_event_handler(r); | |
2131 | |
2132 } else { | |
2133 r->read_event_handler(r); | |
2134 } | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2135 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2136 ngx_http_run_posted_requests(c); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2137 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2138 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2139 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2140 void |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2141 ngx_http_run_posted_requests(ngx_connection_t *c) |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2142 { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2143 ngx_http_request_t *r; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2144 ngx_http_log_ctx_t *ctx; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2145 ngx_http_posted_request_t *pr; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2146 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2147 for ( ;; ) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2148 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2149 if (c->destroyed) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2150 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2151 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2152 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2153 r = c->data; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2154 pr = r->main->posted_requests; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2155 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2156 if (pr == NULL) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2157 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2158 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2159 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2160 r->main->posted_requests = pr->next; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2161 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2162 r = pr->request; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2163 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2164 ctx = c->log->data; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2165 ctx->current_request = r; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2166 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2167 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2168 "http posted request: \"%V?%V\"", &r->uri, &r->args); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2169 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2170 r->write_event_handler(r); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2171 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2172 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2173 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2174 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2175 ngx_int_t |
3064 | 2176 ngx_http_post_request(ngx_http_request_t *r, ngx_http_posted_request_t *pr) |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2177 { |
3064 | 2178 ngx_http_posted_request_t **p; |
2179 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2180 if (pr == NULL) { |
3064 | 2181 pr = ngx_palloc(r->pool, sizeof(ngx_http_posted_request_t)); |
2182 if (pr == NULL) { | |
2183 return NGX_ERROR; | |
2184 } | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2185 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2186 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2187 pr->request = r; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2188 pr->next = NULL; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2189 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2190 for (p = &r->main->posted_requests; *p; p = &(*p)->next) { /* void */ } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2191 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2192 *p = pr; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2193 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2194 return NGX_OK; |
509 | 2195 } |
2196 | |
2197 | |
501 | 2198 void |
509 | 2199 ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc) |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2200 { |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2201 ngx_connection_t *c; |
509 | 2202 ngx_http_request_t *pr; |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
2203 ngx_http_core_loc_conf_t *clcf; |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
2204 |
3049 | 2205 c = r->connection; |
2206 | |
2207 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
2208 "http finalize request: %d, \"%V?%V\" a:%d, c:%d", | |
2209 rc, &r->uri, &r->args, r == c->data, r->main->count); | |
2210 | |
509 | 2211 if (rc == NGX_DONE) { |
3049 | 2212 ngx_http_finalize_connection(r); |
509 | 2213 return; |
2214 } | |
2215 | |
2819
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
2216 if (rc == NGX_OK && r->filter_finalize) { |
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
2217 c->error = 1; |
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
2218 } |
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
2219 |
681 | 2220 if (rc == NGX_DECLINED) { |
2221 r->content_handler = NULL; | |
2222 r->write_event_handler = ngx_http_core_run_phases; | |
2223 ngx_http_core_run_phases(r); | |
2224 return; | |
2225 } | |
2226 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
716
diff
changeset
|
2227 if (r != r->main && r->post_subrequest) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
716
diff
changeset
|
2228 rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc); |
667 | 2229 } |
2230 | |
1783 | 2231 if (rc == NGX_ERROR |
2232 || rc == NGX_HTTP_REQUEST_TIME_OUT | |
2233 || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST | |
2234 || c->error) | |
2235 { | |
613 | 2236 if (ngx_http_post_action(r) == NGX_OK) { |
2237 return; | |
2238 } | |
2239 | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2240 if (r->main->blocked) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2241 r->write_event_handler = ngx_http_request_finalizer; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2242 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2243 |
3049 | 2244 ngx_http_terminate_request(r, rc); |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2245 return; |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2246 } |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2247 |
637 | 2248 if (rc >= NGX_HTTP_SPECIAL_RESPONSE |
2249 || rc == NGX_HTTP_CREATED | |
2250 || rc == NGX_HTTP_NO_CONTENT) | |
2251 { | |
587 | 2252 if (rc == NGX_HTTP_CLOSE) { |
3049 | 2253 ngx_http_terminate_request(r, rc); |
587 | 2254 return; |
2255 } | |
2256 | |
597 | 2257 if (r == r->main) { |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2258 if (c->read->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2259 ngx_del_timer(c->read); |
569 | 2260 } |
2261 | |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2262 if (c->write->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2263 ngx_del_timer(c->write); |
569 | 2264 } |
2265 } | |
2266 | |
2250
7fc20e1105cd
set request handlers, this fixes complex proxied 400 handler with SSI includes
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
2267 c->read->handler = ngx_http_request_handler; |
7fc20e1105cd
set request handlers, this fixes complex proxied 400 handler with SSI includes
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
2268 c->write->handler = ngx_http_request_handler; |
7fc20e1105cd
set request handlers, this fixes complex proxied 400 handler with SSI includes
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
2269 |
569 | 2270 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); |
2271 return; | |
2272 } | |
2273 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2274 if (r != r->main) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2275 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2276 if (r->buffered || r->postponed) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2277 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2278 if (ngx_http_set_write_handler(r) != NGX_OK) { |
3049 | 2279 ngx_http_terminate_request(r, 0); |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2280 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2281 |
525 | 2282 return; |
2283 } | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2284 |
509 | 2285 pr = r->parent; |
2286 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2287 if (r == c->data) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2288 |
3049 | 2289 r->main->count--; |
4471
b19a651471d9
Core: protection from subrequest loops.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
2290 r->main->subrequests++; |
3049 | 2291 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2292 if (!r->logged) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2293 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2294 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2295 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2296 if (clcf->log_subrequest) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2297 ngx_http_log_request(r); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2298 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2299 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2300 r->logged = 1; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2301 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2302 } else { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2303 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2304 "subrequest: \"%V?%V\" logged again", |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2305 &r->uri, &r->args); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2306 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2307 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2308 r->done = 1; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2309 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2310 if (pr->postponed && pr->postponed->request == r) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2311 pr->postponed = pr->postponed->next; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2312 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2313 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2314 c->data = pr; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2315 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2316 } else { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2317 |
4612
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
2318 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
2319 "http finalize non-active request: \"%V?%V\"", |
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
2320 &r->uri, &r->args); |
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
2321 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2322 r->write_event_handler = ngx_http_request_finalizer; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2323 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2324 if (r->waited) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2325 r->done = 1; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2326 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2327 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2328 |
3064 | 2329 if (ngx_http_post_request(pr, NULL) != NGX_OK) { |
3049 | 2330 r->main->count++; |
2331 ngx_http_terminate_request(r, 0); | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2332 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2333 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2334 |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2335 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2336 "http wake parent request: \"%V?%V\"", |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2337 &pr->uri, &pr->args); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2338 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2339 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2340 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2341 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2342 if (r->buffered || c->buffered || r->postponed || r->blocked) { |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2343 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2344 if (ngx_http_set_write_handler(r) != NGX_OK) { |
3049 | 2345 ngx_http_terminate_request(r, 0); |
2261 | 2346 } |
2347 | |
509 | 2348 return; |
2349 } | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
2350 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2351 if (r != c->data) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2352 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2353 "http finalize non-active request: \"%V?%V\"", |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2354 &r->uri, &r->args); |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2355 return; |
527 | 2356 } |
2357 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2358 r->done = 1; |
3415
1b8c3599e3ce
Fix segfault when while discarding body a write event handler is called,
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
2359 r->write_event_handler = ngx_http_request_empty_handler; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2360 |
629 | 2361 if (!r->post_action) { |
2362 r->request_complete = 1; | |
2363 } | |
2364 | |
613 | 2365 if (ngx_http_post_action(r) == NGX_OK) { |
577 | 2366 return; |
2367 } | |
2368 | |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2369 if (c->read->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2370 ngx_del_timer(c->read); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2371 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2372 |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2373 if (c->write->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2374 c->write->delayed = 0; |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2375 ngx_del_timer(c->write); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2376 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2377 |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2378 if (c->read->eof) { |
1423
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
2379 ngx_http_close_request(r, 0); |
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
2380 return; |
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
2381 } |
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
2382 |
3049 | 2383 ngx_http_finalize_connection(r); |
2384 } | |
2385 | |
2386 | |
2387 static void | |
2388 ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc) | |
2389 { | |
3064 | 2390 ngx_http_cleanup_t *cln; |
2391 ngx_http_request_t *mr; | |
2392 ngx_http_ephemeral_t *e; | |
3049 | 2393 |
2394 mr = r->main; | |
2395 | |
2396 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2397 "http terminate request count:%d", mr->count); |
3049 | 2398 |
3176
60bc5cc68d3b
log 499 instead 0, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3153
diff
changeset
|
2399 if (rc > 0 && (mr->headers_out.status == 0 || mr->connection->sent == 0)) { |
60bc5cc68d3b
log 499 instead 0, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3153
diff
changeset
|
2400 mr->headers_out.status = rc; |
60bc5cc68d3b
log 499 instead 0, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3153
diff
changeset
|
2401 } |
60bc5cc68d3b
log 499 instead 0, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3153
diff
changeset
|
2402 |
3049 | 2403 cln = mr->cleanup; |
2404 mr->cleanup = NULL; | |
2405 | |
2406 while (cln) { | |
2407 if (cln->handler) { | |
2408 cln->handler(cln->data); | |
2409 } | |
2410 | |
2411 cln = cln->next; | |
2412 } | |
2413 | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2414 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2415 "http terminate cleanup count:%d blk:%d", |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2416 mr->count, mr->blocked); |
3049 | 2417 |
2418 if (mr->write_event_handler) { | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2419 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2420 if (mr->blocked) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2421 return; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2422 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2423 |
3064 | 2424 e = ngx_http_ephemeral(mr); |
3051 | 2425 mr->posted_requests = NULL; |
2426 mr->write_event_handler = ngx_http_terminate_handler; | |
3064 | 2427 (void) ngx_http_post_request(mr, &e->terminal_posted_request); |
3049 | 2428 return; |
2429 } | |
2430 | |
2431 ngx_http_close_request(mr, rc); | |
2432 } | |
2433 | |
2434 | |
2435 static void | |
2436 ngx_http_terminate_handler(ngx_http_request_t *r) | |
2437 { | |
2438 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2439 "http terminate handler count:%d", r->count); |
3049 | 2440 |
2441 r->count = 1; | |
2442 | |
2443 ngx_http_close_request(r, 0); | |
2444 } | |
2445 | |
2446 | |
2447 static void | |
2448 ngx_http_finalize_connection(ngx_http_request_t *r) | |
2449 { | |
2450 ngx_http_core_loc_conf_t *clcf; | |
2451 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2452 #if (NGX_HTTP_SPDY) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2453 if (r->spdy_stream) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2454 ngx_http_close_request(r, 0); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2455 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2456 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2457 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2458 |
3211
3ea03c1fe050
add lingering timeout if a response is short and a request body is being
Igor Sysoev <igor@sysoev.ru>
parents:
3180
diff
changeset
|
2459 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
3ea03c1fe050
add lingering timeout if a response is short and a request body is being
Igor Sysoev <igor@sysoev.ru>
parents:
3180
diff
changeset
|
2460 |
3049 | 2461 if (r->main->count != 1) { |
3211
3ea03c1fe050
add lingering timeout if a response is short and a request body is being
Igor Sysoev <igor@sysoev.ru>
parents:
3180
diff
changeset
|
2462 |
3214
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
2463 if (r->discard_body) { |
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
2464 r->read_event_handler = ngx_http_discarded_request_body_handler; |
3985
07d1aa82899b
always set timer in discard body handler, this fixes the cases
Igor Sysoev <igor@sysoev.ru>
parents:
3984
diff
changeset
|
2465 ngx_add_timer(r->connection->read, clcf->lingering_timeout); |
3214
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
2466 |
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
2467 if (r->lingering_time == 0) { |
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
2468 r->lingering_time = ngx_time() |
3211
3ea03c1fe050
add lingering timeout if a response is short and a request body is being
Igor Sysoev <igor@sysoev.ru>
parents:
3180
diff
changeset
|
2469 + (time_t) (clcf->lingering_time / 1000); |
3214
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
2470 } |
3211
3ea03c1fe050
add lingering timeout if a response is short and a request body is being
Igor Sysoev <igor@sysoev.ru>
parents:
3180
diff
changeset
|
2471 } |
3ea03c1fe050
add lingering timeout if a response is short and a request body is being
Igor Sysoev <igor@sysoev.ru>
parents:
3180
diff
changeset
|
2472 |
3049 | 2473 ngx_http_close_request(r, 0); |
2474 return; | |
2475 } | |
2476 | |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
2477 if (!ngx_terminate |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
2478 && !ngx_exiting |
2019 | 2479 && r->keepalive |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
2480 && clcf->keepalive_timeout > 0) |
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
2481 { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2482 ngx_http_set_keepalive(r); |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
2483 return; |
3984
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2484 } |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2485 |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2486 if (clcf->lingering_close == NGX_HTTP_LINGERING_ALWAYS |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2487 || (clcf->lingering_close == NGX_HTTP_LINGERING_ON |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2488 && (r->lingering_close |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2489 || r->header_in->pos < r->header_in->last |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2490 || r->connection->read->ready))) |
3981
77604e9a1ed8
enable lingering close for pipelined requests
Igor Sysoev <igor@sysoev.ru>
parents:
3978
diff
changeset
|
2491 { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2492 ngx_http_set_lingering_close(r); |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
2493 return; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2494 } |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2495 |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
2496 ngx_http_close_request(r, 0); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2497 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2498 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2499 |
525 | 2500 static ngx_int_t |
501 | 2501 ngx_http_set_write_handler(ngx_http_request_t *r) |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2502 { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2503 ngx_event_t *wev; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
2504 ngx_http_core_loc_conf_t *clcf; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2505 |
509 | 2506 r->http_state = NGX_HTTP_WRITING_REQUEST_STATE; |
2507 | |
3215
4edf28522d24
allow discarding body while a long response transfer
Igor Sysoev <igor@sysoev.ru>
parents:
3214
diff
changeset
|
2508 r->read_event_handler = r->discard_body ? |
4edf28522d24
allow discarding body while a long response transfer
Igor Sysoev <igor@sysoev.ru>
parents:
3214
diff
changeset
|
2509 ngx_http_discarded_request_body_handler: |
4edf28522d24
allow discarding body while a long response transfer
Igor Sysoev <igor@sysoev.ru>
parents:
3214
diff
changeset
|
2510 ngx_http_test_reading; |
525 | 2511 r->write_event_handler = ngx_http_writer; |
2512 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2513 #if (NGX_HTTP_SPDY) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2514 if (r->spdy_stream) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2515 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2516 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2517 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2518 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2519 wev = r->connection->write; |
369
9c2515d70489
nginx-0.0.7-2004-06-25-18:42:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
2520 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
2521 if (wev->ready && wev->delayed) { |
525 | 2522 return NGX_OK; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2523 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2524 |
509 | 2525 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
2526 if (!wev->delayed) { |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2527 ngx_add_timer(wev, clcf->send_timeout); |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2528 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2529 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2530 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
2531 ngx_http_close_request(r, 0); |
525 | 2532 return NGX_ERROR; |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
2533 } |
525 | 2534 |
2535 return NGX_OK; | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2536 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2537 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2538 |
509 | 2539 static void |
2540 ngx_http_writer(ngx_http_request_t *r) | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2541 { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2542 int rc; |
509 | 2543 ngx_event_t *wev; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2544 ngx_connection_t *c; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
2545 ngx_http_core_loc_conf_t *clcf; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2546 |
509 | 2547 c = r->connection; |
2548 wev = c->write; | |
2549 | |
583 | 2550 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
2551 "http writer handler: \"%V?%V\"", &r->uri, &r->args); | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2552 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2553 clcf = ngx_http_get_module_loc_conf(r->main, ngx_http_core_module); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2554 |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2555 if (wev->timedout) { |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
2556 if (!wev->delayed) { |
505 | 2557 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, |
2558 "client timed out"); | |
2559 c->timedout = 1; | |
567 | 2560 |
613 | 2561 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT); |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2562 return; |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2563 } |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2564 |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2565 wev->timedout = 0; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
2566 wev->delayed = 0; |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2567 |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2568 if (!wev->ready) { |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2569 ngx_add_timer(wev, clcf->send_timeout); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
2570 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2571 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { |
569 | 2572 ngx_http_close_request(r, 0); |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2573 } |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2574 |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2575 return; |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2576 } |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2577 |
4195
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2578 } |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2579 |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2580 if (wev->delayed || r->aio) { |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2581 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2582 "http writer delayed"); |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2583 |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2584 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2585 ngx_http_close_request(r, 0); |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2586 } |
4195
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2587 |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2588 return; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
2589 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
2590 |
583 | 2591 rc = ngx_http_output_filter(r, NULL); |
2592 | |
2593 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
2594 "http writer output filter: %d, \"%V?%V\"", | |
2595 rc, &r->uri, &r->args); | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2596 |
2883
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2597 if (rc == NGX_ERROR) { |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2598 ngx_http_finalize_request(r, rc); |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2599 return; |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2600 } |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2601 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2602 if (r->buffered || r->postponed || (r == r->main && c->buffered)) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2603 |
4194
7ce8f2cde0af
Fix for connection drops with AIO.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4033
diff
changeset
|
2604 if (!wev->delayed) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2605 ngx_add_timer(wev, clcf->send_timeout); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2606 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2607 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2608 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { |
569 | 2609 ngx_http_close_request(r, 0); |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2610 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2611 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2612 return; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2613 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2614 |
583 | 2615 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
2616 "http writer done: \"%V?%V\"", &r->uri, &r->args); | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2617 |
3216
79ae445ec57b
fix two previous commits: an early parallel body discarding completion
Igor Sysoev <igor@sysoev.ru>
parents:
3215
diff
changeset
|
2618 r->write_event_handler = ngx_http_request_empty_handler; |
79ae445ec57b
fix two previous commits: an early parallel body discarding completion
Igor Sysoev <igor@sysoev.ru>
parents:
3215
diff
changeset
|
2619 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2620 ngx_http_finalize_request(r, rc); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2621 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2622 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2623 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2624 static void |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2625 ngx_http_request_finalizer(ngx_http_request_t *r) |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2626 { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2627 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2628 "http finalizer done: \"%V?%V\"", &r->uri, &r->args); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2629 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2630 ngx_http_finalize_request(r, 0); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2631 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2632 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2633 |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
2634 void |
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
2635 ngx_http_block_reading(ngx_http_request_t *r) |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
2636 { |
1283
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2637 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
2638 "http reading blocked"); |
1283
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2639 |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2640 /* aio does not call this handler */ |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2641 |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2642 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2643 && r->connection->read->active) |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2644 { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2645 if (ngx_del_event(r->connection->read, NGX_READ_EVENT, 0) != NGX_OK) { |
1283
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2646 ngx_http_close_request(r, 0); |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2647 } |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2648 } |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2649 } |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2650 |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2651 |
2294 | 2652 void |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
2653 ngx_http_test_reading(ngx_http_request_t *r) |
1283
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
2654 { |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2655 int n; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2656 char buf[1]; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2657 ngx_err_t err; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2658 ngx_event_t *rev; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2659 ngx_connection_t *c; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2660 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2661 c = r->connection; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2662 rev = c->read; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2663 |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
2664 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http test reading"); |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2665 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2666 #if (NGX_HTTP_SPDY) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2667 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2668 if (r->spdy_stream) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2669 if (c->error) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2670 err = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2671 goto closed; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2672 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2673 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2674 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2675 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2676 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2677 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2678 |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2679 #if (NGX_HAVE_KQUEUE) |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2680 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2681 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2682 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2683 if (!rev->pending_eof) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2684 return; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2685 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2686 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2687 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2688 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2689 err = rev->kq_errno; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2690 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2691 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2692 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2693 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2694 #endif |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2695 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2696 n = recv(c->fd, buf, 1, MSG_PEEK); |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2697 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2698 if (n == 0) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2699 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2700 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2701 err = 0; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2702 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2703 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2704 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2705 } else if (n == -1) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2706 err = ngx_socket_errno; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2707 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2708 if (err != NGX_EAGAIN) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2709 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2710 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2711 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2712 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2713 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2714 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2715 |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
2716 /* aio does not call this handler */ |
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
2717 |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2718 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && rev->active) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2719 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2720 if (ngx_del_event(rev, NGX_READ_EVENT, 0) != NGX_OK) { |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
2721 ngx_http_close_request(r, 0); |
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
2722 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
2723 } |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2724 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2725 return; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2726 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2727 closed: |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2728 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2729 if (err) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2730 rev->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2731 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2732 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2733 ngx_log_error(NGX_LOG_INFO, c->log, err, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4552
diff
changeset
|
2734 "client prematurely closed connection"); |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
2735 |
1115
f07a5f4017d9
finalize request to allow post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1110
diff
changeset
|
2736 ngx_http_finalize_request(r, 0); |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2737 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2738 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2739 |
501 | 2740 static void |
2741 ngx_http_set_keepalive(ngx_http_request_t *r) | |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2742 { |
452 | 2743 int tcp_nodelay; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2744 ngx_int_t i; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2745 ngx_buf_t *b, *f; |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
2746 ngx_event_t *rev, *wev; |
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
2747 ngx_connection_t *c; |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
2748 ngx_http_connection_t *hc; |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
2749 ngx_http_core_srv_conf_t *cscf; |
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
2750 ngx_http_core_loc_conf_t *clcf; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2751 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
2752 c = r->connection; |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
2753 rev = c->read; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2754 |
1373
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
2755 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
2756 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
2757 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "set http keepalive handler"); |
94
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
2758 |
1373
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
2759 if (r->discard_body) { |
2489
d1a7203a8a44
avoid a double redirect response if
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
2760 r->write_event_handler = ngx_http_request_empty_handler; |
1373
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
2761 r->lingering_time = ngx_time() + (time_t) (clcf->lingering_time / 1000); |
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
2762 ngx_add_timer(rev, clcf->lingering_timeout); |
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
2763 return; |
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
2764 } |
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
2765 |
483 | 2766 c->log->action = "closing request"; |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
2767 |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
2768 hc = r->http_connection; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2769 b = r->header_in; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2770 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2771 if (b->pos < b->last) { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2772 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2773 /* the pipelined request */ |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2774 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2775 if (b != c->buffer) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2776 |
455 | 2777 /* |
2778 * If the large header buffers were allocated while the previous | |
2779 * request processing then we do not use c->buffer for | |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2780 * the pipelined request (see ngx_http_create_request()). |
577 | 2781 * |
455 | 2782 * Now we would move the large header buffers to the free list. |
2783 */ | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2784 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2785 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2786 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2787 if (hc->free == NULL) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2788 hc->free = ngx_palloc(c->pool, |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2789 cscf->large_client_header_buffers.num * sizeof(ngx_buf_t *)); |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2790 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2791 if (hc->free == NULL) { |
477 | 2792 ngx_http_close_request(r, 0); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2793 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2794 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2795 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2796 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2797 for (i = 0; i < hc->nbusy - 1; i++) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2798 f = hc->busy[i]; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2799 hc->free[hc->nfree++] = f; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2800 f->pos = f->start; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2801 f->last = f->start; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2802 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2803 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2804 hc->busy[0] = b; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2805 hc->nbusy = 1; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2806 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2807 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2808 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
2809 /* guard against recursive call from ngx_http_finalize_connection() */ |
3180
0e420f3f8e18
clear r->keepalive to disable preventively calling
Igor Sysoev <igor@sysoev.ru>
parents:
3176
diff
changeset
|
2810 r->keepalive = 0; |
0e420f3f8e18
clear r->keepalive to disable preventively calling
Igor Sysoev <igor@sysoev.ru>
parents:
3176
diff
changeset
|
2811 |
3049 | 2812 ngx_http_free_request(r, 0); |
569 | 2813 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
2814 c->data = hc; |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
2815 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2816 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2817 ngx_http_close_connection(c); |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2818 return; |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
2819 } |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
2820 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
2821 wev = c->write; |
509 | 2822 wev->handler = ngx_http_empty_handler; |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
2823 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
335
diff
changeset
|
2824 if (b->pos < b->last) { |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
2825 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
2826 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "pipelined request"); |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
2827 |
483 | 2828 c->log->action = "reading client pipelined request line"; |
567 | 2829 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2830 r = ngx_http_create_request(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2831 if (r == NULL) { |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2832 ngx_http_close_connection(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2833 return; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2834 } |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2835 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2836 r->pipeline = 1; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2837 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2838 c->data = r; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2839 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2840 c->sent = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2841 c->destroyed = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2842 |
5102
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
2843 if (rev->timer_set) { |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
2844 ngx_del_timer(rev); |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
2845 } |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
2846 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
2847 rev->handler = ngx_http_process_request_line; |
2014 | 2848 ngx_post_event(rev, &ngx_posted_events); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2849 return; |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
2850 } |
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
2851 |
455 | 2852 /* |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
2853 * To keep a memory footprint as small as possible for an idle keepalive |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
2854 * connection we try to free c->buffer's memory if it was allocated outside |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
2855 * the c->pool. The large header buffers are always allocated outside the |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
2856 * c->pool and are freed too. |
455 | 2857 */ |
2858 | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2859 b = c->buffer; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2860 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2861 if (ngx_pfree(c->pool, b->start) == NGX_OK) { |
455 | 2862 |
2863 /* | |
2864 * the special note for ngx_http_keepalive_handler() that | |
2865 * c->buffer's memory was freed | |
2866 */ | |
2867 | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2868 b->pos = NULL; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2869 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2870 } else { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2871 b->pos = b->start; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2872 b->last = b->start; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2873 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2874 |
461 | 2875 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc free: %p %d", |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2876 hc->free, hc->nfree); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2877 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2878 if (hc->free) { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2879 for (i = 0; i < hc->nfree; i++) { |
1708
3748e50f9b23
large_client_header_buffers did not free()ed before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
2880 ngx_pfree(c->pool, hc->free[i]->start); |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2881 hc->free[i] = NULL; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2882 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2883 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2884 hc->nfree = 0; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2885 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2886 |
461 | 2887 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc busy: %p %d", |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2888 hc->busy, hc->nbusy); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2889 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2890 if (hc->busy) { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2891 for (i = 0; i < hc->nbusy; i++) { |
1708
3748e50f9b23
large_client_header_buffers did not free()ed before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
2892 ngx_pfree(c->pool, hc->busy[i]->start); |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2893 hc->busy[i] = NULL; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2894 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2895 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2896 hc->nbusy = 0; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2897 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2898 |
1779
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
2899 #if (NGX_HTTP_SSL) |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
2900 if (c->ssl) { |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
2901 ngx_ssl_free_buffer(c); |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
2902 } |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
2903 #endif |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
2904 |
509 | 2905 rev->handler = ngx_http_keepalive_handler; |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
2906 |
583 | 2907 if (wev->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2908 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) != NGX_OK) { |
583 | 2909 ngx_http_close_connection(c); |
2910 return; | |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2911 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2912 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2913 |
483 | 2914 c->log->action = "keepalive"; |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
2915 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
2916 if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) { |
501 | 2917 if (ngx_tcp_push(c->fd) == -1) { |
328
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
2918 ngx_connection_error(c, ngx_socket_errno, ngx_tcp_push_n " failed"); |
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
2919 ngx_http_close_connection(c); |
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
2920 return; |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
2921 } |
452 | 2922 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
2923 c->tcp_nopush = NGX_TCP_NOPUSH_UNSET; |
473 | 2924 tcp_nodelay = ngx_tcp_nodelay_and_tcp_nopush ? 1 : 0; |
452 | 2925 |
2926 } else { | |
473 | 2927 tcp_nodelay = 1; |
2928 } | |
2929 | |
483 | 2930 if (tcp_nodelay |
2931 && clcf->tcp_nodelay | |
2932 && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) | |
2933 { | |
473 | 2934 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay"); |
2935 | |
2936 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, | |
635 | 2937 (const void *) &tcp_nodelay, sizeof(int)) |
2938 == -1) | |
473 | 2939 { |
2560
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2556
diff
changeset
|
2940 #if (NGX_SOLARIS) |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2556
diff
changeset
|
2941 /* Solaris returns EINVAL if a socket has been shut down */ |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2556
diff
changeset
|
2942 c->log_error = NGX_ERROR_IGNORE_EINVAL; |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2556
diff
changeset
|
2943 #endif |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2556
diff
changeset
|
2944 |
473 | 2945 ngx_connection_error(c, ngx_socket_errno, |
2946 "setsockopt(TCP_NODELAY) failed"); | |
2560
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2556
diff
changeset
|
2947 |
a7443674e429
ignore EINVAL from setsockopt() on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
2556
diff
changeset
|
2948 c->log_error = NGX_ERROR_INFO; |
473 | 2949 ngx_http_close_connection(c); |
2950 return; | |
452 | 2951 } |
473 | 2952 |
483 | 2953 c->tcp_nodelay = NGX_TCP_NODELAY_SET; |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
2954 } |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
2955 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2956 #if 0 |
455 | 2957 /* if ngx_http_request_t was freed then we need some other place */ |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
2958 r->http_state = NGX_HTTP_KEEPALIVE_STATE; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2959 #endif |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
2960 |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
2961 c->idle = 1; |
3880
e3cb8e27e413
reuse keepalive connections if there are no free worker connections
Igor Sysoev <igor@sysoev.ru>
parents:
3848
diff
changeset
|
2962 ngx_reusable_connection(c, 1); |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
2963 |
5102
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
2964 ngx_add_timer(rev, clcf->keepalive_timeout); |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
2965 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
2966 if (rev->ready) { |
2014 | 2967 ngx_post_event(rev, &ngx_posted_events); |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
2968 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2969 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2970 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2971 |
501 | 2972 static void |
2973 ngx_http_keepalive_handler(ngx_event_t *rev) | |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
2974 { |
501 | 2975 size_t size; |
2976 ssize_t n; | |
2977 ngx_buf_t *b; | |
2978 ngx_connection_t *c; | |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
2979 |
394
e7a68e14ccd3
nginx-0.0.7-2004-07-16-10:33:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
2980 c = rev->data; |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
2981 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
2982 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http keepalive handler"); |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
2983 |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
2984 if (rev->timedout || c->close) { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2985 ngx_http_close_connection(c); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2986 return; |
68
d549fdc17d7e
nginx-0.0.1-2003-03-12-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
2987 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
2988 |
469 | 2989 #if (NGX_HAVE_KQUEUE) |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2990 |
455 | 2991 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
587 | 2992 if (rev->pending_eof) { |
483 | 2993 c->log->handler = NULL; |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2994 ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno, |
461 | 2995 "kevent() reported that client %V closed " |
483 | 2996 "keepalive connection", &c->addr_text); |
473 | 2997 #if (NGX_HTTP_SSL) |
2998 if (c->ssl) { | |
547 | 2999 c->ssl->no_send_shutdown = 1; |
473 | 3000 } |
3001 #endif | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3002 ngx_http_close_connection(c); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3003 return; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3004 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3005 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3006 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3007 #endif |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3008 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3009 b = c->buffer; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3010 size = b->end - b->start; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3011 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3012 if (b->pos == NULL) { |
455 | 3013 |
3014 /* | |
3015 * The c->buffer's memory was freed by ngx_http_set_keepalive(). | |
3016 * However, the c->buffer->start and c->buffer->end were not changed | |
3017 * to keep the buffer size. | |
3018 */ | |
3019 | |
501 | 3020 b->pos = ngx_palloc(c->pool, size); |
3021 if (b->pos == NULL) { | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3022 ngx_http_close_connection(c); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3023 return; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3024 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3025 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3026 b->start = b->pos; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3027 b->last = b->pos; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3028 b->end = b->pos + size; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3029 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3030 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3031 /* |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3032 * MSIE closes a keepalive connection with RST flag |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3033 * so we ignore ECONNRESET here. |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3034 */ |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3035 |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
3036 c->log_error = NGX_ERROR_IGNORE_ECONNRESET; |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3037 ngx_set_socket_errno(0); |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
3038 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3039 n = c->recv(c, b->last, size); |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
3040 c->log_error = NGX_ERROR_INFO; |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3041 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3042 if (n == NGX_AGAIN) { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3043 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
475 | 3044 ngx_http_close_connection(c); |
5082
42a888fdad0b
Fixed potential segfault in ngx_http_keepalive_handler().
Valentin Bartenev <vbart@nginx.com>
parents:
5072
diff
changeset
|
3045 return; |
475 | 3046 } |
3047 | |
4891
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3048 /* |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3049 * Like ngx_http_set_keepalive() we are trying to not hold |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3050 * c->buffer's memory for a keepalive connection. |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3051 */ |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3052 |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3053 if (ngx_pfree(c->pool, b->start) == NGX_OK) { |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3054 |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3055 /* |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3056 * the special note that c->buffer's memory was freed |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3057 */ |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3058 |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3059 b->pos = NULL; |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3060 } |
1e666c78a42c
ngx_http_keepalive_handler() is now trying to not keep c->buffer's memory for
Valentin Bartenev <vbart@nginx.com>
parents:
4884
diff
changeset
|
3061 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3062 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3063 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3064 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3065 if (n == NGX_ERROR) { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3066 ngx_http_close_connection(c); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3067 return; |
68
d549fdc17d7e
nginx-0.0.1-2003-03-12-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
3068 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3069 |
483 | 3070 c->log->handler = NULL; |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3071 |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3072 if (n == 0) { |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3073 ngx_log_error(NGX_LOG_INFO, c->log, ngx_socket_errno, |
483 | 3074 "client %V closed keepalive connection", &c->addr_text); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3075 ngx_http_close_connection(c); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3076 return; |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3077 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3078 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3079 b->last += n; |
483 | 3080 |
3081 c->log->handler = ngx_http_log_error; | |
3082 c->log->action = "reading client request line"; | |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3083 |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
3084 c->idle = 0; |
3880
e3cb8e27e413
reuse keepalive connections if there are no free worker connections
Igor Sysoev <igor@sysoev.ru>
parents:
3848
diff
changeset
|
3085 ngx_reusable_connection(c, 0); |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
3086 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3087 c->data = ngx_http_create_request(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3088 if (c->data == NULL) { |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3089 ngx_http_close_connection(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3090 return; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3091 } |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3092 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3093 c->sent = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3094 c->destroyed = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3095 |
5102
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3096 ngx_del_timer(rev); |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3097 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3098 rev->handler = ngx_http_process_request_line; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3099 ngx_http_process_request_line(rev); |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3100 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3101 |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3102 |
501 | 3103 static void |
3104 ngx_http_set_lingering_close(ngx_http_request_t *r) | |
577 | 3105 { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3106 ngx_event_t *rev, *wev; |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3107 ngx_connection_t *c; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3108 ngx_http_core_loc_conf_t *clcf; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
3109 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3110 c = r->connection; |
53
d1e42f1b8fd4
nginx-0.0.1-2003-01-27-00:08:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
52
diff
changeset
|
3111 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3112 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
3113 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3114 rev = c->read; |
509 | 3115 rev->handler = ngx_http_lingering_close_handler; |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3116 |
557 | 3117 r->lingering_time = ngx_time() + (time_t) (clcf->lingering_time / 1000); |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3118 ngx_add_timer(rev, clcf->lingering_timeout); |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3119 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3120 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3121 ngx_http_close_request(r, 0); |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3122 return; |
53
d1e42f1b8fd4
nginx-0.0.1-2003-01-27-00:08:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
52
diff
changeset
|
3123 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3124 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3125 wev = c->write; |
509 | 3126 wev->handler = ngx_http_empty_handler; |
53
d1e42f1b8fd4
nginx-0.0.1-2003-01-27-00:08:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
52
diff
changeset
|
3127 |
583 | 3128 if (wev->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3129 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) != NGX_OK) { |
583 | 3130 ngx_http_close_request(r, 0); |
3131 return; | |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3132 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3133 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3134 |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3135 if (ngx_shutdown_socket(c->fd, NGX_WRITE_SHUTDOWN) == -1) { |
328
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
3136 ngx_connection_error(c, ngx_socket_errno, |
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
3137 ngx_shutdown_socket_n " failed"); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3138 ngx_http_close_request(r, 0); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3139 return; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3140 } |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3141 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
3142 if (rev->ready) { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3143 ngx_http_lingering_close_handler(rev); |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3144 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3145 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3146 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3147 |
501 | 3148 static void |
3149 ngx_http_lingering_close_handler(ngx_event_t *rev) | |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3150 { |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3151 ssize_t n; |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3152 ngx_msec_t timer; |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3153 ngx_connection_t *c; |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3154 ngx_http_request_t *r; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3155 ngx_http_core_loc_conf_t *clcf; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3156 u_char buffer[NGX_HTTP_LINGERING_BUFFER_SIZE]; |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3157 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3158 c = rev->data; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3159 r = c->data; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
55
diff
changeset
|
3160 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3161 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3162 "http lingering close handler"); |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3163 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3164 if (rev->timedout) { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3165 ngx_http_close_request(r, 0); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3166 return; |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
3167 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3168 |
5210
ea2ba6dbe361
Fixed lingering_time check.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5200
diff
changeset
|
3169 timer = (ngx_msec_t) r->lingering_time - (ngx_msec_t) ngx_time(); |
ea2ba6dbe361
Fixed lingering_time check.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5200
diff
changeset
|
3170 if ((ngx_msec_int_t) timer <= 0) { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3171 ngx_http_close_request(r, 0); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3172 return; |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
3173 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3174 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3175 do { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3176 n = c->recv(c, buffer, NGX_HTTP_LINGERING_BUFFER_SIZE); |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3177 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3178 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "lingering read: %d", n); |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3179 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3180 if (n == NGX_ERROR || n == 0) { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3181 ngx_http_close_request(r, 0); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3182 return; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3183 } |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3184 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3185 } while (rev->ready); |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3186 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3187 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
477 | 3188 ngx_http_close_request(r, 0); |
475 | 3189 return; |
3190 } | |
3191 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3192 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3193 |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3194 timer *= 1000; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3195 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3196 if (timer > clcf->lingering_timeout) { |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3197 timer = clcf->lingering_timeout; |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
3198 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3199 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3200 ngx_add_timer(rev, timer); |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3201 } |
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3202 |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
3203 |
501 | 3204 void |
3205 ngx_http_empty_handler(ngx_event_t *wev) | |
94
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3206 { |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3207 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http empty handler"); |
94
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3208 |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3209 return; |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3210 } |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3211 |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3212 |
509 | 3213 void |
3214 ngx_http_request_empty_handler(ngx_http_request_t *r) | |
3215 { | |
3216 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
583 | 3217 "http request empty handler"); |
509 | 3218 |
3219 return; | |
3220 } | |
3221 | |
3222 | |
501 | 3223 ngx_int_t |
581 | 3224 ngx_http_send_special(ngx_http_request_t *r, ngx_uint_t flags) |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3225 { |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
335
diff
changeset
|
3226 ngx_buf_t *b; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
3227 ngx_chain_t out; |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3228 |
501 | 3229 b = ngx_calloc_buf(r->pool); |
3230 if (b == NULL) { | |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
335
diff
changeset
|
3231 return NGX_ERROR; |
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
335
diff
changeset
|
3232 } |
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
335
diff
changeset
|
3233 |
581 | 3234 if (flags & NGX_HTTP_LAST) { |
2971
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3235 |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3236 if (r == r->main && !r->post_action) { |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3237 b->last_buf = 1; |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3238 |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3239 } else { |
2993
f592d466bbda
fix r2972, it caused "zero size buf" alert.
Igor Sysoev <igor@sysoev.ru>
parents:
2992
diff
changeset
|
3240 b->sync = 1; |
2971
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3241 b->last_in_chain = 1; |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3242 } |
581 | 3243 } |
3244 | |
3245 if (flags & NGX_HTTP_FLUSH) { | |
3246 b->flush = 1; | |
3247 } | |
3248 | |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
335
diff
changeset
|
3249 out.buf = b; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
3250 out.next = NULL; |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3251 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
3252 return ngx_http_output_filter(r, &out); |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3253 } |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3254 |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3255 |
613 | 3256 static ngx_int_t |
3257 ngx_http_post_action(ngx_http_request_t *r) | |
3258 { | |
3259 ngx_http_core_loc_conf_t *clcf; | |
3260 | |
3261 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
3262 | |
3263 if (clcf->post_action.data == NULL) { | |
3264 return NGX_DECLINED; | |
3265 } | |
3266 | |
4472
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
3267 if (r->post_action && r->uri_changes == 0) { |
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
3268 return NGX_DECLINED; |
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
3269 } |
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
3270 |
623 | 3271 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3272 "post action: \"%V\"", &clcf->post_action); | |
3273 | |
3145
9160a117a46a
fix request counter for post_action, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3076
diff
changeset
|
3274 r->main->count--; |
9160a117a46a
fix request counter for post_action, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3076
diff
changeset
|
3275 |
613 | 3276 r->http_version = NGX_HTTP_VERSION_9; |
3277 r->header_only = 1; | |
629 | 3278 r->post_action = 1; |
613 | 3279 |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3280 r->read_event_handler = ngx_http_block_reading; |
895
49d03c183ad2
fix post_action for disconnected client
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
3281 |
1894
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3282 if (clcf->post_action.data[0] == '/') { |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3283 ngx_http_internal_redirect(r, &clcf->post_action, NULL); |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3284 |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3285 } else { |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3286 ngx_http_named_location(r, &clcf->post_action); |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3287 } |
613 | 3288 |
3289 return NGX_OK; | |
3290 } | |
3291 | |
3292 | |
3293 static void | |
3049 | 3294 ngx_http_close_request(ngx_http_request_t *r, ngx_int_t rc) |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3295 { |
639 | 3296 ngx_connection_t *c; |
569 | 3297 |
3049 | 3298 r = r->main; |
569 | 3299 c = r->connection; |
639 | 3300 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3301 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3302 "http request count:%d blk:%d", r->count, r->blocked); |
3049 | 3303 |
3304 if (r->count == 0) { | |
3305 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "http request count is zero"); | |
3306 } | |
3307 | |
3308 r->count--; | |
3309 | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3310 if (r->count || r->blocked) { |
3049 | 3311 return; |
3312 } | |
3313 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3314 #if (NGX_HTTP_SPDY) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3315 if (r->spdy_stream) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3316 ngx_http_spdy_close_stream(r->spdy_stream, rc); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3317 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3318 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3319 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3320 |
3049 | 3321 ngx_http_free_request(r, rc); |
569 | 3322 ngx_http_close_connection(c); |
3323 } | |
3324 | |
3325 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3326 void |
3049 | 3327 ngx_http_free_request(ngx_http_request_t *r, ngx_int_t rc) |
569 | 3328 { |
2261 | 3329 ngx_log_t *log; |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3330 ngx_pool_t *pool; |
2261 | 3331 struct linger linger; |
3332 ngx_http_cleanup_t *cln; | |
3333 ngx_http_log_ctx_t *ctx; | |
3334 ngx_http_core_loc_conf_t *clcf; | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3335 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
3336 log = r->connection->log; |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
3337 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
3338 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http close request"); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3339 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3340 if (r->pool == NULL) { |
531 | 3341 ngx_log_error(NGX_LOG_ALERT, log, 0, "http request already closed"); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3342 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3343 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3344 |
639 | 3345 for (cln = r->cleanup; cln; cln = cln->next) { |
3346 if (cln->handler) { | |
3347 cln->handler(cln->data); | |
3348 } | |
3349 } | |
3350 | |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3351 #if (NGX_STAT_STUB) |
567 | 3352 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3353 if (r->stat_reading) { |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
3354 (void) ngx_atomic_fetch_add(ngx_stat_reading, -1); |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3355 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3356 |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3357 if (r->stat_writing) { |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
3358 (void) ngx_atomic_fetch_add(ngx_stat_writing, -1); |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3359 } |
567 | 3360 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3361 #endif |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3362 |
3049 | 3363 if (rc > 0 && (r->headers_out.status == 0 || r->connection->sent == 0)) { |
3364 r->headers_out.status = rc; | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3365 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3366 |
2077 | 3367 log->action = "logging request"; |
3368 | |
2261 | 3369 ngx_http_log_request(r); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3370 |
2077 | 3371 log->action = "closing request"; |
3372 | |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3373 if (r->connection->timedout) { |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3374 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3375 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3376 if (clcf->reset_timedout_connection) { |
509 | 3377 linger.l_onoff = 1; |
3378 linger.l_linger = 0; | |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3379 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3380 if (setsockopt(r->connection->fd, SOL_SOCKET, SO_LINGER, |
509 | 3381 (const void *) &linger, sizeof(struct linger)) == -1) |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3382 { |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3383 ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno, |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3384 "setsockopt(SO_LINGER) failed"); |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3385 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3386 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3387 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3388 |
509 | 3389 /* the various request strings were allocated from r->pool */ |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
3390 ctx = log->data; |
461 | 3391 ctx->request = NULL; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3392 |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
3393 r->request_line.len = 0; |
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
3394 |
583 | 3395 r->connection->destroyed = 1; |
3396 | |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3397 /* |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3398 * Setting r->pool to NULL will increase probability to catch double close |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3399 * of request since the request object is allocated from its own pool. |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3400 */ |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3401 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3402 pool = r->pool; |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3403 r->pool = NULL; |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3404 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3405 ngx_destroy_pool(pool); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3406 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3407 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3408 |
531 | 3409 static void |
2261 | 3410 ngx_http_log_request(ngx_http_request_t *r) |
3411 { | |
3412 ngx_uint_t i, n; | |
3413 ngx_http_handler_pt *log_handler; | |
3414 ngx_http_core_main_conf_t *cmcf; | |
3415 | |
3416 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
3417 | |
3418 log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts; | |
3419 n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts; | |
3420 | |
3421 for (i = 0; i < n; i++) { | |
3422 log_handler[i](r); | |
3423 } | |
3424 } | |
3425 | |
3426 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3427 void |
501 | 3428 ngx_http_close_connection(ngx_connection_t *c) |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
3429 { |
479 | 3430 ngx_pool_t *pool; |
3431 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3432 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
256
diff
changeset
|
3433 "close http connection: %d", c->fd); |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
3434 |
539 | 3435 #if (NGX_HTTP_SSL) |
452 | 3436 |
3437 if (c->ssl) { | |
3438 if (ngx_ssl_shutdown(c) == NGX_AGAIN) { | |
577 | 3439 c->ssl->handler = ngx_http_close_connection; |
452 | 3440 return; |
3441 } | |
3442 } | |
3443 | |
3444 #endif | |
3445 | |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
3446 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
3447 (void) ngx_atomic_fetch_add(ngx_stat_active, -1); |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
3448 #endif |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
3449 |
583 | 3450 c->destroyed = 1; |
3451 | |
479 | 3452 pool = c->pool; |
3453 | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
416
diff
changeset
|
3454 ngx_close_connection(c); |
479 | 3455 |
501 | 3456 ngx_destroy_pool(pool); |
18
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
3457 } |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
3458 |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
3459 |
501 | 3460 static u_char * |
3461 ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len) | |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3462 { |
483 | 3463 u_char *p; |
505 | 3464 ngx_http_request_t *r; |
483 | 3465 ngx_http_log_ctx_t *ctx; |
461 | 3466 |
483 | 3467 if (log->action) { |
509 | 3468 p = ngx_snprintf(buf, len, " while %s", log->action); |
461 | 3469 len -= p - buf; |
505 | 3470 buf = p; |
461 | 3471 } |
3472 | |
509 | 3473 ctx = log->data; |
3474 | |
1810 | 3475 p = ngx_snprintf(buf, len, ", client: %V", &ctx->connection->addr_text); |
509 | 3476 len -= p - buf; |
505 | 3477 |
3478 r = ctx->request; | |
3479 | |
509 | 3480 if (r) { |
665 | 3481 return r->log_handler(r, ctx->current_request, p, len); |
1810 | 3482 |
3483 } else { | |
3484 p = ngx_snprintf(p, len, ", server: %V", | |
3485 &ctx->connection->listening->addr_text); | |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3486 } |
461 | 3487 |
509 | 3488 return p; |
3489 } | |
3490 | |
3491 | |
3492 static u_char * | |
665 | 3493 ngx_http_log_error_handler(ngx_http_request_t *r, ngx_http_request_t *sr, |
3494 u_char *buf, size_t len) | |
509 | 3495 { |
1811 | 3496 char *uri_separator; |
3497 u_char *p; | |
3498 ngx_http_upstream_t *u; | |
3499 ngx_http_core_srv_conf_t *cscf; | |
3500 | |
3501 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | |
3502 | |
3503 p = ngx_snprintf(buf, len, ", server: %V", &cscf->server_name); | |
3504 len -= p - buf; | |
3505 buf = p; | |
503 | 3506 |
1656
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3507 if (r->request_line.data == NULL && r->request_start) { |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3508 for (p = r->request_start; p < r->header_in->last; p++) { |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3509 if (*p == CR || *p == LF) { |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3510 break; |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3511 } |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3512 } |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3513 |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3514 r->request_line.len = p - r->request_start; |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3515 r->request_line.data = r->request_start; |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3516 } |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3517 |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3518 if (r->request_line.len) { |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3519 p = ngx_snprintf(buf, len, ", request: \"%V\"", &r->request_line); |
505 | 3520 len -= p - buf; |
3521 buf = p; | |
461 | 3522 } |
3523 | |
665 | 3524 if (r != sr) { |
3525 p = ngx_snprintf(buf, len, ", subrequest: \"%V\"", &sr->uri); | |
3526 len -= p - buf; | |
3527 buf = p; | |
3528 } | |
3529 | |
3530 u = sr->upstream; | |
3531 | |
884 | 3532 if (u && u->peer.name) { |
3533 | |
3534 uri_separator = ""; | |
3535 | |
3536 #if (NGX_HAVE_UNIX_DOMAIN) | |
3537 if (u->peer.sockaddr && u->peer.sockaddr->sa_family == AF_UNIX) { | |
3538 uri_separator = ":"; | |
3539 } | |
3540 #endif | |
665 | 3541 |
3542 p = ngx_snprintf(buf, len, ", upstream: \"%V%V%s%V\"", | |
1658 | 3543 &u->schema, u->peer.name, |
884 | 3544 uri_separator, &u->uri); |
665 | 3545 len -= p - buf; |
3546 buf = p; | |
3547 } | |
3548 | |
505 | 3549 if (r->headers_in.host) { |
3550 p = ngx_snprintf(buf, len, ", host: \"%V\"", | |
3551 &r->headers_in.host->value); | |
3552 len -= p - buf; | |
3553 buf = p; | |
3554 } | |
3555 | |
3556 if (r->headers_in.referer) { | |
3557 p = ngx_snprintf(buf, len, ", referrer: \"%V\"", | |
3558 &r->headers_in.referer->value); | |
3559 buf = p; | |
3560 } | |
3561 | |
3562 return buf; | |
3563 } |