Mercurial > hg > nginx
annotate src/http/ngx_http_request.c @ 8168:b507592c15a7 quic
Server Initial Keys.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 28 Feb 2020 13:09:51 +0300 |
parents | 5d91389e0fd3 |
children | bd006bd520a9 |
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); |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
14 static ngx_http_request_t *ngx_http_alloc_request(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
|
15 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
|
16 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
|
17 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
|
18 static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, |
501 | 19 ngx_uint_t request_line); |
509 | 20 |
21 static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r, | |
22 ngx_table_elt_t *h, ngx_uint_t offset); | |
523 | 23 static ngx_int_t ngx_http_process_unique_header_line(ngx_http_request_t *r, |
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 ngx_table_elt_t *h, ngx_uint_t offset); |
509 | 33 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 |
509 | 42 static void ngx_http_request_handler(ngx_event_t *ev); |
3049 | 43 static void ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc); |
44 static void ngx_http_terminate_handler(ngx_http_request_t *r); | |
45 static void ngx_http_finalize_connection(ngx_http_request_t *r); | |
525 | 46 static ngx_int_t ngx_http_set_write_handler(ngx_http_request_t *r); |
509 | 47 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
|
48 static void ngx_http_request_finalizer(ngx_http_request_t *r); |
509 | 49 |
87
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_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
|
51 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
|
52 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
|
53 static void ngx_http_lingering_close_handler(ngx_event_t *ev); |
613 | 54 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r); |
531 | 55 static void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error); |
2261 | 56 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
|
57 |
483 | 58 static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len); |
665 | 59 static u_char *ngx_http_log_error_handler(ngx_http_request_t *r, |
60 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
|
61 |
539 | 62 #if (NGX_HTTP_SSL) |
63 static void ngx_http_ssl_handshake(ngx_event_t *rev); | |
547 | 64 static void ngx_http_ssl_handshake_handler(ngx_connection_t *c); |
8167
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
65 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
66 static void ngx_http_quic_handshake(ngx_event_t *rev); |
539 | 67 #endif |
68 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 |
505 | 70 static char *ngx_http_client_errors[] = { |
71 | |
72 /* NGX_HTTP_PARSE_INVALID_METHOD */ | |
73 "client sent invalid method", | |
74 | |
75 /* NGX_HTTP_PARSE_INVALID_REQUEST */ | |
76 "client sent invalid request", | |
77 | |
6993
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
78 /* NGX_HTTP_PARSE_INVALID_VERSION */ |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
79 "client sent invalid version", |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
80 |
505 | 81 /* NGX_HTTP_PARSE_INVALID_09_METHOD */ |
82 "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
|
83 }; |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
84 |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
85 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
86 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
|
87 { 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
|
88 ngx_http_process_host }, |
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
89 |
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
90 { 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
|
91 ngx_http_process_connection }, |
509 | 92 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
93 { ngx_string("If-Modified-Since"), |
509 | 94 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
|
95 ngx_http_process_unique_header_line }, |
509 | 96 |
3814
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
97 { ngx_string("If-Unmodified-Since"), |
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
98 offsetof(ngx_http_headers_in_t, if_unmodified_since), |
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
99 ngx_http_process_unique_header_line }, |
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
100 |
4744
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
101 { ngx_string("If-Match"), |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
102 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
|
103 ngx_http_process_unique_header_line }, |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
104 |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
105 { ngx_string("If-None-Match"), |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
106 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
|
107 ngx_http_process_unique_header_line }, |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
108 |
2193
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
109 { 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
|
110 ngx_http_process_user_agent }, |
509 | 111 |
112 { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer), | |
113 ngx_http_process_header_line }, | |
114 | |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
115 { ngx_string("Content-Length"), |
509 | 116 offsetof(ngx_http_headers_in_t, content_length), |
523 | 117 ngx_http_process_unique_header_line }, |
509 | 118 |
6538
055cbb52ac1d
Dav: return 501 on PUT with ranges (ticket #948).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
119 { ngx_string("Content-Range"), |
055cbb52ac1d
Dav: return 501 on PUT with ranges (ticket #948).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
120 offsetof(ngx_http_headers_in_t, content_range), |
055cbb52ac1d
Dav: return 501 on PUT with ranges (ticket #948).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
121 ngx_http_process_unique_header_line }, |
055cbb52ac1d
Dav: return 501 on PUT with ranges (ticket #948).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
122 |
479 | 123 { ngx_string("Content-Type"), |
509 | 124 offsetof(ngx_http_headers_in_t, content_type), |
125 ngx_http_process_header_line }, | |
126 | |
127 { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range), | |
128 ngx_http_process_header_line }, | |
129 | |
1630 | 130 { ngx_string("If-Range"), |
131 offsetof(ngx_http_headers_in_t, if_range), | |
132 ngx_http_process_unique_header_line }, | |
133 | |
581 | 134 { ngx_string("Transfer-Encoding"), |
135 offsetof(ngx_http_headers_in_t, transfer_encoding), | |
7625
aca005d232ff
Disabled multiple Transfer-Encoding headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7475
diff
changeset
|
136 ngx_http_process_unique_header_line }, |
581 | 137 |
7234
c693daca57f7
gRPC: special handling of the TE request header.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7206
diff
changeset
|
138 { ngx_string("TE"), |
c693daca57f7
gRPC: special handling of the TE request header.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7206
diff
changeset
|
139 offsetof(ngx_http_headers_in_t, te), |
c693daca57f7
gRPC: special handling of the TE request header.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7206
diff
changeset
|
140 ngx_http_process_header_line }, |
c693daca57f7
gRPC: special handling of the TE request header.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7206
diff
changeset
|
141 |
2067 | 142 { ngx_string("Expect"), |
143 offsetof(ngx_http_headers_in_t, expect), | |
144 ngx_http_process_unique_header_line }, | |
145 | |
5072
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
146 { ngx_string("Upgrade"), |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
147 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
|
148 ngx_http_process_header_line }, |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
149 |
7206
33edea74bd58
Expose more headers with NGX_HTTP_HEADERS.
Ruslan Ermilov <ru@nginx.com>
parents:
7193
diff
changeset
|
150 #if (NGX_HTTP_GZIP || NGX_HTTP_HEADERS) |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
151 { ngx_string("Accept-Encoding"), |
509 | 152 offsetof(ngx_http_headers_in_t, accept_encoding), |
153 ngx_http_process_header_line }, | |
154 | |
155 { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via), | |
156 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
|
157 #endif |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
158 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
159 { ngx_string("Authorization"), |
509 | 160 offsetof(ngx_http_headers_in_t, authorization), |
523 | 161 ngx_http_process_unique_header_line }, |
509 | 162 |
163 { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive), | |
164 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
|
165 |
4697
09187f9b0950
Fixed compile-time conditionals used to detect if X-Forwarded-For support
Ruslan Ermilov <ru@nginx.com>
parents:
4675
diff
changeset
|
166 #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
|
167 { ngx_string("X-Forwarded-For"), |
509 | 168 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
|
169 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
|
170 #endif |
479 | 171 |
573 | 172 #if (NGX_HTTP_REALIP) |
173 { ngx_string("X-Real-IP"), | |
174 offsetof(ngx_http_headers_in_t, x_real_ip), | |
175 ngx_http_process_header_line }, | |
176 #endif | |
177 | |
489 | 178 #if (NGX_HTTP_HEADERS) |
509 | 179 { ngx_string("Accept"), offsetof(ngx_http_headers_in_t, accept), |
180 ngx_http_process_header_line }, | |
181 | |
489 | 182 { ngx_string("Accept-Language"), |
509 | 183 offsetof(ngx_http_headers_in_t, accept_language), |
184 ngx_http_process_header_line }, | |
489 | 185 #endif |
186 | |
637 | 187 #if (NGX_HTTP_DAV) |
188 { ngx_string("Depth"), offsetof(ngx_http_headers_in_t, depth), | |
189 ngx_http_process_header_line }, | |
190 | |
191 { ngx_string("Destination"), offsetof(ngx_http_headers_in_t, destination), | |
192 ngx_http_process_header_line }, | |
681 | 193 |
1059 | 194 { ngx_string("Overwrite"), offsetof(ngx_http_headers_in_t, overwrite), |
195 ngx_http_process_header_line }, | |
196 | |
681 | 197 { ngx_string("Date"), offsetof(ngx_http_headers_in_t, date), |
198 ngx_http_process_header_line }, | |
637 | 199 #endif |
200 | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
201 { 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
|
202 ngx_http_process_multi_header_lines }, |
509 | 203 |
204 { 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
|
205 }; |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
206 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
207 |
501 | 208 void |
209 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
|
210 { |
5085
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
211 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 #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
|
219 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
|
220 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
|
221 #endif |
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 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
|
224 if (hc == NULL) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
225 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
|
226 return; |
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 c->data = hc; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
230 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
231 /* 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
|
232 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
233 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
|
234 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
235 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
|
236 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
237 /* |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
238 * 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
|
239 * 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
|
240 * 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
|
241 */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
242 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
243 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
|
244 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
|
245 return; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
246 } |
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 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
|
249 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
250 #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
|
251 case AF_INET6: |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
252 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
|
253 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
254 addr6 = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
255 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
256 /* 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
|
257 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
258 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
|
259 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
|
260 break; |
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 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
263 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
264 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
|
265 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
266 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
267 #endif |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
268 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
269 default: /* AF_INET */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
270 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
|
271 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
272 addr = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
273 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
274 /* 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
|
275 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
276 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
|
277 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
|
278 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
279 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
280 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
281 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
282 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
|
283 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
284 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
285 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
286 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
287 } else { |
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 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
|
290 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
291 #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
|
292 case AF_INET6: |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
293 addr6 = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
294 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
|
295 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
296 #endif |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
297 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
298 default: /* AF_INET */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
299 addr = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
300 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
|
301 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
302 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
303 } |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
304 |
5089
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
305 /* 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
|
306 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
|
307 |
501 | 308 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); |
309 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
|
310 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
|
311 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
312 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
313 |
1810 | 314 ctx->connection = c; |
461 | 315 ctx->request = NULL; |
665 | 316 ctx->current_request = NULL; |
483 | 317 |
318 c->log->connection = c->number; | |
319 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
|
320 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
|
321 c->log->action = "waiting for request"; |
483 | 322 |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
323 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
|
324 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
325 rev = c->read; |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
326 rev->handler = ngx_http_wait_request_handler; |
569 | 327 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
|
328 |
8166
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
329 if (c->shared) { |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
330 rev->ready = 1; |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
331 } |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
332 |
8167
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
333 #if (NGX_HTTP_SSL) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
334 if (hc->addr_conf->http3) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
335 hc->quic = 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
336 c->log->action = "QUIC handshaking"; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
337 rev->handler = ngx_http_quic_handshake; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
338 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
339 #endif |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
340 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
341 #if (NGX_HTTP_V2) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
342 if (hc->addr_conf->http2) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
343 rev->handler = ngx_http_v2_init; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
344 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
345 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
346 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
347 #if (NGX_HTTP_SSL) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
348 { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
349 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
|
350 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
351 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
|
352 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
353 if (sscf->enable || hc->addr_conf->ssl) { |
7269
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7234
diff
changeset
|
354 hc->ssl = 1; |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
355 c->log->action = "SSL handshaking"; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
356 rev->handler = ngx_http_ssl_handshake; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
357 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
358 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
359 #endif |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
360 |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
361 if (hc->addr_conf->proxy_protocol) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
362 hc->proxy_protocol = 1; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
363 c->log->action = "reading PROXY protocol"; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
364 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
365 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
366 if (rev->ready) { |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
367 /* the deferred accept(), iocp */ |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
368 |
611 | 369 if (ngx_use_accept_mutex) { |
563 | 370 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
|
371 return; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
372 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
373 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
374 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
|
375 return; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
55
diff
changeset
|
376 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
377 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
378 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
|
379 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
|
380 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
381 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
|
382 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
|
383 return; |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
384 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
385 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
386 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
387 |
641 | 388 static void |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
389 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
|
390 { |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
391 u_char *p; |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
392 size_t size; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
393 ssize_t n; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
394 ngx_buf_t *b; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
395 ngx_connection_t *c; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
396 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
|
397 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
|
398 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
399 c = rev->data; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
400 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
401 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
|
402 |
8166
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
403 if (c->shared) { |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
404 goto request; |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
405 } |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
406 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
407 if (rev->timedout) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
408 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
|
409 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
|
410 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
411 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
412 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
413 if (c->close) { |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
414 ngx_http_close_connection(c); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
415 return; |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
416 } |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
417 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
418 hc = c->data; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
419 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
|
420 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
421 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
|
422 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
423 b = c->buffer; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
424 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
425 if (b == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
426 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
|
427 if (b == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
428 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
|
429 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
430 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
431 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
432 c->buffer = b; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
433 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
434 } 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
|
435 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
436 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
|
437 if (b->start == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
438 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
|
439 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
440 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
441 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
442 b->pos = b->start; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
443 b->last = b->start; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
444 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
|
445 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
446 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
447 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
|
448 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
449 if (n == NGX_AGAIN) { |
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 if (!rev->timer_set) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
452 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
|
453 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
|
454 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
455 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
456 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
|
457 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
|
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 /* |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
462 * 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
|
463 */ |
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 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
|
466 b->start = NULL; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
467 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
468 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
469 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
470 } |
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 if (n == NGX_ERROR) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
473 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
|
474 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
475 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
476 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
477 if (n == 0) { |
5109
44bd04fbbb4f
Fixed logging in ngx_http_wait_request_handler().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5105
diff
changeset
|
478 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
|
479 "client closed connection"); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
480 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
|
481 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
482 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
483 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
484 b->last += n; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
485 |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
486 if (hc->proxy_protocol) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
487 hc->proxy_protocol = 0; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
488 |
6185
a420cb1c170b
Core: renamed ngx_proxy_protocol_parse to ngx_proxy_protocol_read.
Roman Arutyunyan <arut@nginx.com>
parents:
6129
diff
changeset
|
489 p = ngx_proxy_protocol_read(c, b->pos, b->last); |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
490 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
491 if (p == NULL) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
492 ngx_http_close_connection(c); |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
493 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
494 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
495 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
496 b->pos = p; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
497 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
498 if (b->pos == b->last) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
499 c->log->action = "waiting for request"; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
500 b->pos = b->start; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
501 b->last = b->start; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
502 ngx_post_event(rev, &ngx_posted_events); |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
503 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
504 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
505 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
506 |
8166
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
507 request: |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
508 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
509 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
|
510 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
511 ngx_reusable_connection(c, 0); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
512 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
513 c->data = ngx_http_create_request(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
514 if (c->data == NULL) { |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
515 ngx_http_close_connection(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
516 return; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
517 } |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
518 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
519 rev->handler = ngx_http_process_request_line; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
520 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
|
521 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
522 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
523 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
524 ngx_http_request_t * |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
525 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
|
526 { |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
527 ngx_http_request_t *r; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
528 ngx_http_log_ctx_t *ctx; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
529 ngx_http_core_loc_conf_t *clcf; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
530 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
531 r = ngx_http_alloc_request(c); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
532 if (r == NULL) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
533 return NULL; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
534 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
535 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
536 c->requests++; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
537 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
538 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
539 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
540 ngx_set_connection_log(c, clcf->error_log); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
541 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
542 ctx = c->log->data; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
543 ctx->request = r; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
544 ctx->current_request = r; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
545 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
546 #if (NGX_STAT_STUB) |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
547 (void) ngx_atomic_fetch_add(ngx_stat_reading, 1); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
548 r->stat_reading = 1; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
549 (void) ngx_atomic_fetch_add(ngx_stat_requests, 1); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
550 #endif |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
551 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
552 return r; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
553 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
554 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
555 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
556 static ngx_http_request_t * |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
557 ngx_http_alloc_request(ngx_connection_t *c) |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
558 { |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
559 ngx_pool_t *pool; |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
560 ngx_time_t *tp; |
573 | 561 ngx_http_request_t *r; |
562 ngx_http_connection_t *hc; | |
563 ngx_http_core_srv_conf_t *cscf; | |
564 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
|
565 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
566 hc = c->data; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
567 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
568 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
|
569 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
570 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
|
571 if (pool == NULL) { |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
572 return NULL; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
573 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
574 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
575 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
|
576 if (r == NULL) { |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
577 ngx_destroy_pool(pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
578 return NULL; |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
579 } |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
580 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
581 r->pool = pool; |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
582 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
583 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
|
584 r->signature = NGX_HTTP_MODULE; |
1805 | 585 r->connection = c; |
586 | |
5089
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
587 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
|
588 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
|
589 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
|
590 |
3000
66ef86affbb8
fix segfault if 400 or 414 errors are handled intricately
Igor Sysoev <igor@sysoev.ru>
parents:
2994
diff
changeset
|
591 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
|
592 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
593 r->header_in = hc->busy ? hc->busy->buf : c->buffer; |
294
5cfd65b8b0a7
nginx-0.0.3-2004-03-23-09:01:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
293
diff
changeset
|
594 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
595 if (ngx_list_init(&r->headers_out.headers, r->pool, 20, |
581 | 596 sizeof(ngx_table_elt_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2534
diff
changeset
|
597 != NGX_OK) |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
598 { |
2902
a1a1c7e3fb8d
fix "out of memory" case handling
Igor Sysoev <igor@sysoev.ru>
parents:
2888
diff
changeset
|
599 ngx_destroy_pool(r->pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
600 return NULL; |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
601 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
602 |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
603 if (ngx_list_init(&r->headers_out.trailers, r->pool, 4, |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
604 sizeof(ngx_table_elt_t)) |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
605 != NGX_OK) |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
606 { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
607 ngx_destroy_pool(r->pool); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
608 return NULL; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
609 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
610 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
611 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
|
612 if (r->ctx == NULL) { |
2902
a1a1c7e3fb8d
fix "out of memory" case handling
Igor Sysoev <igor@sysoev.ru>
parents:
2888
diff
changeset
|
613 ngx_destroy_pool(r->pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
614 return NULL; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
615 } |
10
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
616 |
573 | 617 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
618 | |
619 r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts | |
620 * sizeof(ngx_http_variable_value_t)); | |
621 if (r->variables == NULL) { | |
2902
a1a1c7e3fb8d
fix "out of memory" case handling
Igor Sysoev <igor@sysoev.ru>
parents:
2888
diff
changeset
|
622 ngx_destroy_pool(r->pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
623 return NULL; |
573 | 624 } |
625 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
626 #if (NGX_HTTP_SSL) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
627 if (c->ssl) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
628 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
|
629 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
630 #endif |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
631 |
553 | 632 r->main = r; |
3049 | 633 r->count = 1; |
553 | 634 |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
635 tp = ngx_timeofday(); |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
636 r->start_sec = tp->sec; |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
637 r->start_msec = tp->msec; |
497 | 638 |
631 | 639 r->method = NGX_HTTP_UNKNOWN; |
5354
62be77b0608f
Assume the HTTP/1.0 version by default.
Valentin Bartenev <vbart@nginx.com>
parents:
5289
diff
changeset
|
640 r->http_version = NGX_HTTP_VERSION_10; |
631 | 641 |
82
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
642 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
|
643 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
|
644 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
|
645 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
|
646 |
675 | 647 r->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1; |
648 r->subrequests = NGX_HTTP_MAX_SUBREQUESTS + 1; | |
649 | |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
650 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
|
651 |
509 | 652 r->log_handler = ngx_http_log_error_handler; |
505 | 653 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
654 return r; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
655 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
656 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
657 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
658 #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
|
659 |
8167
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
660 static uint64_t |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
661 ngx_quic_parse_int(u_char **pos) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
662 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
663 u_char *p; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
664 uint64_t value; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
665 ngx_uint_t len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
666 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
667 p = *pos; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
668 len = 1 << ((*p & 0xc0) >> 6); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
669 value = *p++ & 0x3f; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
670 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
671 while (--len) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
672 value = (value << 8) + *p++; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
673 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
674 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
675 *pos = p; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
676 return value; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
677 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
678 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
679 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
680 static uint64_t |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
681 ngx_quic_parse_pn(u_char **pos, ngx_int_t len, u_char *mask) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
682 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
683 u_char *p; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
684 uint64_t value; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
685 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
686 p = *pos; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
687 value = *p++ ^ *mask++; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
688 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
689 while (--len) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
690 value = (value << 8) + (*p++ ^ *mask++); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
691 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
692 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
693 *pos = p; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
694 return value; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
695 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
696 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
697 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
698 static void |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
699 ngx_http_quic_handshake(ngx_event_t *rev) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
700 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
701 int n, sslerr; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
702 #if (NGX_DEBUG) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
703 u_char buf[512]; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
704 size_t m; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
705 #endif |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
706 ngx_buf_t *b; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
707 ngx_connection_t *c; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
708 ngx_http_connection_t *hc; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
709 ngx_quic_connection_t *qc; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
710 ngx_http_ssl_srv_conf_t *sscf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
711 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
712 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "quic handshake"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
713 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
714 c = rev->data; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
715 hc = c->data; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
716 b = c->buffer; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
717 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
718 qc = ngx_pcalloc(c->pool, sizeof(ngx_quic_connection_t)); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
719 if (qc == NULL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
720 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
721 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
722 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
723 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
724 c->quic = qc; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
725 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
726 printf("buffer %p %p:%p:%p:%p \n", b, b->start, b->pos, b->last, b->end); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
727 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
728 if ((b->pos[0] & 0xf0) != 0xc0) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
729 ngx_log_error(NGX_LOG_INFO, rev->log, 0, "invalid initial packet"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
730 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
731 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
732 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
733 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
734 if (ngx_buf_size(b) < 1200) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
735 ngx_log_error(NGX_LOG_INFO, rev->log, 0, "too small UDP datagram"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
736 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
737 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
738 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
739 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
740 ngx_int_t flags = *b->pos++; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
741 uint32_t version = ngx_http_v2_parse_uint32(b->pos); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
742 b->pos += 4; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
743 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
744 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
745 "quic flags:%xi version:%xD", flags, version); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
746 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
747 if (version != 0xff000017) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
748 ngx_log_error(NGX_LOG_INFO, rev->log, 0, "unsupported quic version"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
749 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
750 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
751 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
752 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
753 qc->dcid.len = *b->pos++; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
754 qc->dcid.data = ngx_pnalloc(c->pool, qc->dcid.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
755 if (qc->dcid.data == NULL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
756 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
757 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
758 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
759 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
760 ngx_memcpy(qc->dcid.data, b->pos, qc->dcid.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
761 b->pos += qc->dcid.len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
762 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
763 qc->scid.len = *b->pos++; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
764 qc->scid.data = ngx_pnalloc(c->pool, qc->scid.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
765 if (qc->scid.data == NULL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
766 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
767 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
768 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
769 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
770 ngx_memcpy(qc->scid.data, b->pos, qc->scid.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
771 b->pos += qc->scid.len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
772 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
773 qc->token.len = ngx_quic_parse_int(&b->pos); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
774 qc->token.data = ngx_pnalloc(c->pool, qc->token.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
775 if (qc->token.data == NULL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
776 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
777 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
778 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
779 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
780 ngx_memcpy(qc->token.data, b->pos, qc->token.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
781 b->pos += qc->token.len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
782 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
783 uint64_t plen = ngx_quic_parse_int(&b->pos); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
784 /* draft-ietf-quic-tls-23#section-5.4.2: |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
785 * the Packet Number field is assumed to be 4 bytes long |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
786 * draft-ietf-quic-tls-23#section-5.4.3: |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
787 * AES-Based header protection samples 16 bytes |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
788 */ |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
789 u_char *sample = b->pos + 4; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
790 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
791 #if (NGX_DEBUG) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
792 if (c->log->log_level & NGX_LOG_DEBUG_EVENT) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
793 m = ngx_hex_dump(buf, qc->dcid.data, qc->dcid.len) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
794 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
795 "quic DCID: %*s, len: %uz", m, buf, qc->dcid.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
796 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
797 m = ngx_hex_dump(buf, qc->scid.data, qc->scid.len) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
798 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
799 "quic SCID: %*s, len: %uz", m, buf, qc->scid.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
800 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
801 m = ngx_hex_dump(buf, qc->token.data, qc->token.len) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
802 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
803 "quic token: %*s, len: %uz", m, buf, qc->token.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
804 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
805 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
806 "quic packet length: %d", plen); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
807 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
808 m = ngx_hex_dump(buf, sample, 16) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
809 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
810 "quic sample: %*s", m, buf); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
811 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
812 #endif |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
813 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
814 // initial secret |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
815 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
816 size_t is_len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
817 uint8_t is[SHA256_DIGEST_LENGTH]; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
818 const EVP_MD *digest; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
819 static const uint8_t salt[20] = |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
820 "\xc3\xee\xf7\x12\xc7\x2e\xbb\x5a\x11\xa7" |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
821 "\xd2\x43\x2b\xb4\x63\x65\xbe\xf9\xf5\x02"; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
822 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
823 digest = EVP_sha256(); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
824 HKDF_extract(is, &is_len, digest, qc->dcid.data, qc->dcid.len, salt, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
825 sizeof(salt)); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
826 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
827 #if (NGX_DEBUG) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
828 if (c->log->log_level & NGX_LOG_DEBUG_EVENT) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
829 m = ngx_hex_dump(buf, (uint8_t *) salt, sizeof(salt)) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
830 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
831 "quic salt: %*s, len: %uz", m, buf, sizeof(salt)); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
832 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
833 m = ngx_hex_dump(buf, is, is_len) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
834 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
835 "quic initial secret: %*s, len: %uz", m, buf, is_len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
836 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
837 #endif |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
838 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
839 size_t hkdfl_len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
840 uint8_t hkdfl[20]; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
841 uint8_t *p; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
842 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
843 /* draft-ietf-quic-tls-23#section-5.2 */ |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
844 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
845 qc->client_in.len = SHA256_DIGEST_LENGTH; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
846 qc->client_in.data = ngx_pnalloc(c->pool, qc->client_in.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
847 if (qc->client_in.data == NULL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
848 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
849 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
850 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
851 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
852 hkdfl_len = 2 + 1 + sizeof("tls13 client in") - 1 + 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
853 hkdfl[0] = 0; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
854 hkdfl[1] = qc->client_in.len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
855 hkdfl[2] = sizeof("tls13 client in") - 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
856 p = ngx_cpymem(&hkdfl[3], "tls13 client in", |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
857 sizeof("tls13 client in") - 1); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
858 *p = '\0'; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
859 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
860 if (HKDF_expand(qc->client_in.data, qc->client_in.len, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
861 digest, is, is_len, hkdfl, hkdfl_len) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
862 == 0) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
863 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
864 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
865 "HKDF_expand(client_in) failed"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
866 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
867 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
868 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
869 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
870 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
871 "quic EVP key:%d tag:%d nonce:%d", |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
872 EVP_AEAD_key_length(EVP_aead_aes_128_gcm()), |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
873 EVP_AEAD_max_tag_len(EVP_aead_aes_128_gcm()), |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
874 EVP_AEAD_nonce_length(EVP_aead_aes_128_gcm())); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
875 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
876 /* AEAD_AES_128_GCM prior to handshake, quic-tls-23#section-5.3 */ |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
877 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
878 qc->client_in_key.len = EVP_AEAD_key_length(EVP_aead_aes_128_gcm()); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
879 qc->client_in_key.data = ngx_pnalloc(c->pool, qc->client_in_key.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
880 if (qc->client_in_key.data == NULL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
881 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
882 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
883 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
884 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
885 hkdfl_len = 2 + 1 + sizeof("tls13 quic key") - 1 + 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
886 hkdfl[1] = qc->client_in_key.len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
887 hkdfl[2] = sizeof("tls13 quic key") - 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
888 p = ngx_cpymem(&hkdfl[3], "tls13 quic key", |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
889 sizeof("tls13 quic key") - 1); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
890 *p = '\0'; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
891 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
892 if (HKDF_expand(qc->client_in_key.data, qc->client_in_key.len, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
893 digest, qc->client_in.data, qc->client_in.len, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
894 hkdfl, hkdfl_len) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
895 == 0) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
896 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
897 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
898 "HKDF_expand(client_in_key) failed"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
899 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
900 return; |
8168 | 901 } |
8167
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
902 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
903 qc->client_in_iv.len = EVP_AEAD_nonce_length(EVP_aead_aes_128_gcm()); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
904 qc->client_in_iv.data = ngx_pnalloc(c->pool, qc->client_in_iv.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
905 if (qc->client_in_iv.data == NULL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
906 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
907 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
908 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
909 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
910 hkdfl_len = 2 + 1 + sizeof("tls13 quic iv") - 1 + 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
911 hkdfl[1] = qc->client_in_iv.len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
912 hkdfl[2] = sizeof("tls13 quic iv") - 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
913 p = ngx_cpymem(&hkdfl[3], "tls13 quic iv", sizeof("tls13 quic iv") - 1); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
914 *p = '\0'; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
915 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
916 if (HKDF_expand(qc->client_in_iv.data, qc->client_in_iv.len, digest, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
917 qc->client_in.data, qc->client_in.len, hkdfl, hkdfl_len) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
918 == 0) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
919 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
920 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
921 "HKDF_expand(client_in_iv) failed"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
922 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
923 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
924 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
925 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
926 /* AEAD_AES_128_GCM prior to handshake, quic-tls-23#section-5.4.1 */ |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
927 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
928 qc->client_in_hp.len = EVP_AEAD_key_length(EVP_aead_aes_128_gcm()); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
929 qc->client_in_hp.data = ngx_pnalloc(c->pool, qc->client_in_hp.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
930 if (qc->client_in_hp.data == NULL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
931 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
932 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
933 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
934 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
935 hkdfl_len = 2 + 1 + sizeof("tls13 quic hp") - 1 + 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
936 hkdfl[1] = qc->client_in_hp.len; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
937 hkdfl[2] = sizeof("tls13 quic hp") - 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
938 p = ngx_cpymem(&hkdfl[3], "tls13 quic hp", sizeof("tls13 quic hp") - 1); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
939 *p = '\0'; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
940 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
941 if (HKDF_expand(qc->client_in_hp.data, qc->client_in_hp.len, digest, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
942 qc->client_in.data, qc->client_in.len, hkdfl, hkdfl_len) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
943 == 0) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
944 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
945 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
946 "HKDF_expand(client_in_hp) failed"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
947 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
948 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
949 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
950 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
951 #if (NGX_DEBUG) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
952 if (c->log->log_level & NGX_LOG_DEBUG_EVENT) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
953 m = ngx_hex_dump(buf, qc->client_in.data, qc->client_in.len) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
954 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
955 "quic client initial secret: %*s, len: %uz", |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
956 m, buf, qc->client_in.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
957 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
958 m = ngx_hex_dump(buf, qc->client_in_key.data, qc->client_in_key.len) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
959 - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
960 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
8168 | 961 "quic client key: %*s, len: %uz", |
8167
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
962 m, buf, qc->client_in_key.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
963 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
964 m = ngx_hex_dump(buf, qc->client_in_iv.data, qc->client_in_iv.len) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
965 - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
966 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
8168 | 967 "quic client iv: %*s, len: %uz", |
968 m, buf, qc->client_in_iv.len); | |
8167
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
969 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
970 m = ngx_hex_dump(buf, qc->client_in_hp.data, qc->client_in_hp.len) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
971 - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
972 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
8168 | 973 "quic client hp: %*s, len: %uz", |
974 m, buf, qc->client_in_hp.len); | |
975 } | |
976 #endif | |
977 | |
978 // server initial | |
979 | |
980 /* draft-ietf-quic-tls-23#section-5.2 */ | |
981 | |
982 qc->server_in.len = SHA256_DIGEST_LENGTH; | |
983 qc->server_in.data = ngx_pnalloc(c->pool, qc->server_in.len); | |
984 if (qc->server_in.data == NULL) { | |
985 ngx_http_close_connection(c); | |
986 return; | |
987 } | |
988 | |
989 hkdfl_len = 2 + 1 + sizeof("tls13 server in") - 1 + 1; | |
990 hkdfl[0] = 0; | |
991 hkdfl[1] = qc->server_in.len; | |
992 hkdfl[2] = sizeof("tls13 server in") - 1; | |
993 p = ngx_cpymem(&hkdfl[3], "tls13 server in", | |
994 sizeof("tls13 server in") - 1); | |
995 *p = '\0'; | |
996 | |
997 if (HKDF_expand(qc->server_in.data, qc->server_in.len, | |
998 digest, is, is_len, hkdfl, hkdfl_len) | |
999 == 0) | |
1000 { | |
1001 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, | |
1002 "HKDF_expand(server_in) failed"); | |
1003 ngx_http_close_connection(c); | |
1004 return; | |
1005 } | |
1006 | |
1007 /* AEAD_AES_128_GCM prior to handshake, quic-tls-23#section-5.3 */ | |
1008 | |
1009 qc->server_in_key.len = EVP_AEAD_key_length(EVP_aead_aes_128_gcm()); | |
1010 qc->server_in_key.data = ngx_pnalloc(c->pool, qc->server_in_key.len); | |
1011 if (qc->server_in_key.data == NULL) { | |
1012 ngx_http_close_connection(c); | |
1013 return; | |
1014 } | |
1015 | |
1016 hkdfl_len = 2 + 1 + sizeof("tls13 quic key") - 1 + 1; | |
1017 hkdfl[1] = qc->server_in_key.len; | |
1018 hkdfl[2] = sizeof("tls13 quic key") - 1; | |
1019 p = ngx_cpymem(&hkdfl[3], "tls13 quic key", | |
1020 sizeof("tls13 quic key") - 1); | |
1021 *p = '\0'; | |
1022 | |
1023 if (HKDF_expand(qc->server_in_key.data, qc->server_in_key.len, | |
1024 digest, qc->server_in.data, qc->server_in.len, | |
1025 hkdfl, hkdfl_len) | |
1026 == 0) | |
1027 { | |
1028 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, | |
1029 "HKDF_expand(server_in_key) failed"); | |
1030 ngx_http_close_connection(c); | |
1031 return; | |
1032 } | |
1033 | |
1034 qc->server_in_iv.len = EVP_AEAD_nonce_length(EVP_aead_aes_128_gcm()); | |
1035 qc->server_in_iv.data = ngx_pnalloc(c->pool, qc->server_in_iv.len); | |
1036 if (qc->server_in_iv.data == NULL) { | |
1037 ngx_http_close_connection(c); | |
1038 return; | |
1039 } | |
1040 | |
1041 hkdfl_len = 2 + 1 + sizeof("tls13 quic iv") - 1 + 1; | |
1042 hkdfl[1] = qc->server_in_iv.len; | |
1043 hkdfl[2] = sizeof("tls13 quic iv") - 1; | |
1044 p = ngx_cpymem(&hkdfl[3], "tls13 quic iv", sizeof("tls13 quic iv") - 1); | |
1045 *p = '\0'; | |
1046 | |
1047 if (HKDF_expand(qc->server_in_iv.data, qc->server_in_iv.len, digest, | |
1048 qc->server_in.data, qc->server_in.len, hkdfl, hkdfl_len) | |
1049 == 0) | |
1050 { | |
1051 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, | |
1052 "HKDF_expand(server_in_iv) failed"); | |
1053 ngx_http_close_connection(c); | |
1054 return; | |
1055 } | |
1056 | |
1057 /* AEAD_AES_128_GCM prior to handshake, quic-tls-23#section-5.4.1 */ | |
1058 | |
1059 qc->server_in_hp.len = EVP_AEAD_key_length(EVP_aead_aes_128_gcm()); | |
1060 qc->server_in_hp.data = ngx_pnalloc(c->pool, qc->server_in_hp.len); | |
1061 if (qc->server_in_hp.data == NULL) { | |
1062 ngx_http_close_connection(c); | |
1063 return; | |
1064 } | |
1065 | |
1066 hkdfl_len = 2 + 1 + sizeof("tls13 quic hp") - 1 + 1; | |
1067 hkdfl[1] = qc->server_in_hp.len; | |
1068 hkdfl[2] = sizeof("tls13 quic hp") - 1; | |
1069 p = ngx_cpymem(&hkdfl[3], "tls13 quic hp", sizeof("tls13 quic hp") - 1); | |
1070 *p = '\0'; | |
1071 | |
1072 if (HKDF_expand(qc->server_in_hp.data, qc->server_in_hp.len, digest, | |
1073 qc->server_in.data, qc->server_in.len, hkdfl, hkdfl_len) | |
1074 == 0) | |
1075 { | |
1076 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, | |
1077 "HKDF_expand(server_in_hp) failed"); | |
1078 ngx_http_close_connection(c); | |
1079 return; | |
1080 } | |
1081 | |
1082 #if (NGX_DEBUG) | |
1083 if (c->log->log_level & NGX_LOG_DEBUG_EVENT) { | |
1084 m = ngx_hex_dump(buf, qc->server_in.data, qc->server_in.len) - buf; | |
1085 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, | |
1086 "quic server initial secret: %*s, len: %uz", | |
1087 m, buf, qc->server_in.len); | |
1088 | |
1089 m = ngx_hex_dump(buf, qc->server_in_key.data, qc->server_in_key.len) | |
1090 - buf; | |
1091 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, | |
1092 "quic server key: %*s, len: %uz", | |
1093 m, buf, qc->server_in_key.len); | |
1094 | |
1095 m = ngx_hex_dump(buf, qc->server_in_iv.data, qc->server_in_iv.len) | |
1096 - buf; | |
1097 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, | |
1098 "quic server iv: %*s, len: %uz", | |
1099 m, buf, qc->server_in_iv.len); | |
1100 | |
1101 m = ngx_hex_dump(buf, qc->server_in_hp.data, qc->server_in_hp.len) | |
1102 - buf; | |
1103 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, | |
1104 "quic server hp: %*s, len: %uz", | |
1105 m, buf, qc->server_in_hp.len); | |
8167
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1106 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1107 #endif |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1108 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1109 // header protection |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1110 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1111 EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1112 uint8_t mask[16]; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1113 int outlen; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1114 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1115 if (EVP_EncryptInit_ex(ctx, EVP_aes_128_ecb(), NULL, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1116 qc->client_in_hp.data, NULL) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1117 != 1) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1118 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1119 EVP_CIPHER_CTX_free(ctx); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1120 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1121 "EVP_EncryptInit_ex() failed"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1122 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1123 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1124 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1125 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1126 if (!EVP_EncryptUpdate(ctx, mask, &outlen, sample, 16)) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1127 EVP_CIPHER_CTX_free(ctx); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1128 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1129 "EVP_EncryptUpdate() failed"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1130 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1131 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1132 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1133 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1134 EVP_CIPHER_CTX_free(ctx); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1135 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1136 u_char clearflags = flags ^ (mask[0] & 0x0f); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1137 ngx_int_t pnl = (clearflags & 0x03) + 1; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1138 uint64_t pn = ngx_quic_parse_pn(&b->pos, pnl, &mask[1]); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1139 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1140 #if (NGX_DEBUG) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1141 if (c->log->log_level & NGX_LOG_DEBUG_EVENT) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1142 m = ngx_hex_dump(buf, sample, 16) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1143 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1144 "quic sample: %*s", m, buf); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1145 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1146 m = ngx_hex_dump(buf, mask, 5) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1147 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1148 "quic mask: %*s", m, buf); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1149 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1150 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1151 "quic packet number: %uL, len: %xi", pn, pnl); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1152 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1153 #endif |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1154 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1155 // packet protection |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1156 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1157 ngx_str_t ciphertext; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1158 ciphertext.data = b->pos; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1159 ciphertext.len = plen - pnl; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1160 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1161 ngx_str_t ad; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1162 ad.len = b->pos - b->start; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1163 ad.data = ngx_pnalloc(c->pool, ad.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1164 if (ad.data == NULL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1165 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1166 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1167 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1168 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1169 ngx_memcpy(ad.data, b->start, ad.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1170 ad.data[0] = clearflags; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1171 ad.data[ad.len - pnl] = (u_char)pn; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1172 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1173 uint8_t *nonce = ngx_pstrdup(c->pool, &qc->client_in_iv); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1174 nonce[11] ^= pn; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1175 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1176 #if (NGX_DEBUG) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1177 if (c->log->log_level & NGX_LOG_DEBUG_EVENT) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1178 m = ngx_hex_dump(buf, nonce, 12) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1179 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1180 "quic nonce: %*s, len: %uz", m, buf, 12); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1181 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1182 m = ngx_hex_dump(buf, ad.data, ad.len) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1183 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1184 "quic ad: %*s, len: %uz", m, buf, ad.len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1185 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1186 #endif |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1187 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1188 EVP_AEAD_CTX *aead = EVP_AEAD_CTX_new(EVP_aead_aes_128_gcm(), |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1189 qc->client_in_key.data, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1190 qc->client_in_key.len, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1191 EVP_AEAD_DEFAULT_TAG_LENGTH); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1192 uint8_t cleartext[1600]; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1193 size_t cleartext_len = sizeof(cleartext); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1194 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1195 if (EVP_AEAD_CTX_open(aead, cleartext, &cleartext_len, sizeof(cleartext), |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1196 nonce, qc->client_in_iv.len, ciphertext.data, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1197 ciphertext.len, ad.data, ad.len) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1198 != 1) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1199 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1200 EVP_AEAD_CTX_free(aead); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1201 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1202 "EVP_AEAD_CTX_open() failed"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1203 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1204 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1205 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1206 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1207 EVP_AEAD_CTX_free(aead); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1208 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1209 #if (NGX_DEBUG) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1210 if (c->log->log_level & NGX_LOG_DEBUG_EVENT) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1211 m = ngx_hex_dump(buf, cleartext, ngx_min(cleartext_len, 256)) - buf; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1212 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1213 "quic packet: %*s%s, len: %uz", |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1214 m, buf, m < 512 ? "" : "...", cleartext_len); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1215 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1216 #endif |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1217 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1218 sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1219 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1220 if (ngx_ssl_create_connection(&sscf->ssl, c, NGX_SSL_BUFFER) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1221 != NGX_OK) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1222 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1223 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1224 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1225 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1226 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1227 n = SSL_do_handshake(c->ssl->connection); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1228 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1229 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_do_handshake: %d", n); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1230 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1231 if (n == -1) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1232 sslerr = SSL_get_error(c->ssl->connection, n); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1233 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1234 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1235 sslerr); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1236 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1237 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1238 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1239 "SSL_quic_read_level: %d, SSL_quic_write_level: %d", |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1240 (int) SSL_quic_read_level(c->ssl->connection), |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1241 (int) SSL_quic_write_level(c->ssl->connection)); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1242 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1243 if (!SSL_provide_quic_data(c->ssl->connection, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1244 SSL_quic_read_level(c->ssl->connection), |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1245 &cleartext[4], cleartext_len - 4)) |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1246 { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1247 ngx_ssl_error(NGX_LOG_INFO, rev->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1248 "SSL_provide_quic_data() failed"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1249 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1250 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1251 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1252 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1253 n = SSL_do_handshake(c->ssl->connection); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1254 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1255 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_do_handshake: %d", n); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1256 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1257 if (n == -1) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1258 sslerr = SSL_get_error(c->ssl->connection, n); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1259 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1260 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1261 sslerr); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1262 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1263 if (sslerr == SSL_ERROR_SSL) { |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1264 ngx_ssl_error(NGX_LOG_ERR, c->log, 0, "SSL_do_handshake() failed"); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1265 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1266 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1267 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1268 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1269 "SSL_quic_read_level: %d, SSL_quic_write_level: %d", |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1270 (int) SSL_quic_read_level(c->ssl->connection), |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1271 (int) SSL_quic_write_level(c->ssl->connection)); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1272 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1273 ngx_http_close_connection(c); |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1274 return; |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1275 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1276 |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8166
diff
changeset
|
1277 |
501 | 1278 static void |
1279 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
|
1280 { |
7008
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1281 u_char *p, buf[NGX_PROXY_PROTOCOL_MAX_HEADER + 1]; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1282 size_t size; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1283 ssize_t n; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1284 ngx_err_t err; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1285 ngx_int_t rc; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1286 ngx_connection_t *c; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1287 ngx_http_connection_t *hc; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1288 ngx_http_ssl_srv_conf_t *sscf; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1289 ngx_http_core_loc_conf_t *clcf; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1290 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1291 c = rev->data; |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1292 hc = c->data; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1293 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1294 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
|
1295 "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
|
1296 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1297 if (rev->timedout) { |
505 | 1298 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
|
1299 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
|
1300 return; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1301 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1302 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
1303 if (c->close) { |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
1304 ngx_http_close_connection(c); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
1305 return; |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
1306 } |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
1307 |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1308 size = hc->proxy_protocol ? sizeof(buf) : 1; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1309 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1310 n = recv(c->fd, (char *) buf, size, MSG_PEEK); |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1311 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1312 err = ngx_socket_errno; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1313 |
6480 | 1314 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http recv(): %z", n); |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1315 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1316 if (n == -1) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1317 if (err == NGX_EAGAIN) { |
5993
5b549cc7f698
SSL: reset ready flag if recv(MSG_PEEK) found no bytes in socket.
Roman Arutyunyan <arut@nginx.com>
parents:
5928
diff
changeset
|
1318 rev->ready = 0; |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1319 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1320 if (!rev->timer_set) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1321 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
|
1322 ngx_reusable_connection(c, 1); |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1323 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1324 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1325 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
|
1326 ngx_http_close_connection(c); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1327 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1328 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1329 return; |
1855 | 1330 } |
1331 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1332 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
|
1333 ngx_http_close_connection(c); |
1858 | 1334 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1335 return; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1336 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1337 |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1338 if (hc->proxy_protocol) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1339 hc->proxy_protocol = 0; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1340 |
6185
a420cb1c170b
Core: renamed ngx_proxy_protocol_parse to ngx_proxy_protocol_read.
Roman Arutyunyan <arut@nginx.com>
parents:
6129
diff
changeset
|
1341 p = ngx_proxy_protocol_read(c, buf, buf + n); |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1342 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1343 if (p == NULL) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1344 ngx_http_close_connection(c); |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1345 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1346 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1347 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1348 size = p - buf; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1349 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1350 if (c->recv(c, buf, size) != (ssize_t) size) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1351 ngx_http_close_connection(c); |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1352 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1353 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1354 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1355 c->log->action = "SSL handshaking"; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1356 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1357 if (n == (ssize_t) size) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1358 ngx_post_event(rev, &ngx_posted_events); |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1359 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1360 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1361 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1362 n = 1; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1363 buf[0] = *p; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1364 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
1365 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1366 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
|
1367 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
|
1368 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
461 | 1369 "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
|
1370 |
7008
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1371 clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1372 ngx_http_core_module); |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1373 |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1374 if (clcf->tcp_nodelay && ngx_tcp_nodelay(c) != NGX_OK) { |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1375 ngx_http_close_connection(c); |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1376 return; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1377 } |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
1378 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1379 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
|
1380 ngx_http_ssl_module); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1381 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1382 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
|
1383 != NGX_OK) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1384 { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1385 ngx_http_close_connection(c); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1386 return; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1387 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1388 |
7628
2e3bfd696ecb
Disabled connection reuse while in SSL handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7627
diff
changeset
|
1389 ngx_reusable_connection(c, 0); |
2e3bfd696ecb
Disabled connection reuse while in SSL handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7627
diff
changeset
|
1390 |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
1391 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
|
1392 |
547 | 1393 if (rc == NGX_AGAIN) { |
1829
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
1394 |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
1395 if (!rev->timer_set) { |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
1396 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
|
1397 } |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
1398 |
547 | 1399 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
|
1400 return; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
1401 } |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
1402 |
547 | 1403 ngx_http_ssl_handshake_handler(c); |
1404 | |
1405 return; | |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1406 } |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1407 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1408 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
|
1409 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
1410 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
|
1411 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
1412 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
|
1413 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
|
1414 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1415 return; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1416 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1417 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1418 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
|
1419 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
|
1420 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1421 |
547 | 1422 |
1423 static void | |
1424 ngx_http_ssl_handshake_handler(ngx_connection_t *c) | |
1425 { | |
1426 if (c->ssl->handshaked) { | |
1427 | |
1428 /* | |
1429 * The majority of browsers do not send the "close notify" alert. | |
1430 * Among them are MSIE, old Mozilla, Netscape 4, Konqueror, | |
1431 * and Links. And what is more, MSIE ignores the server's alert. | |
1432 * | |
1433 * Opera and recent Mozilla send the alert. | |
1434 */ | |
1435 | |
1436 c->ssl->no_wait_shutdown = 1; | |
1437 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
1438 #if (NGX_HTTP_V2 \ |
5545
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
1439 && (defined TLSEXT_TYPE_application_layer_protocol_negotiation \ |
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
1440 || defined TLSEXT_TYPE_next_proto_neg)) |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1441 { |
6289
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1442 unsigned int len; |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1443 const unsigned char *data; |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1444 ngx_http_connection_t *hc; |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1445 |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1446 hc = c->data; |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1447 |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1448 if (hc->addr_conf->http2) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1449 |
5545
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
1450 #ifdef TLSEXT_TYPE_application_layer_protocol_negotiation |
6289
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1451 SSL_get0_alpn_selected(c->ssl->connection, &data, &len); |
5545
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
1452 |
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
1453 #ifdef TLSEXT_TYPE_next_proto_neg |
6289
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1454 if (len == 0) { |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1455 SSL_get0_next_proto_negotiated(c->ssl->connection, &data, &len); |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1456 } |
5545
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
1457 #endif |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1458 |
5547
2e40188f83ef
Fixed a compile warning introduced by 01e2a5bcdd8f.
Ruslan Ermilov <ru@nginx.com>
parents:
5545
diff
changeset
|
1459 #else /* TLSEXT_TYPE_next_proto_neg */ |
6289
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1460 SSL_get0_next_proto_negotiated(c->ssl->connection, &data, &len); |
5547
2e40188f83ef
Fixed a compile warning introduced by 01e2a5bcdd8f.
Ruslan Ermilov <ru@nginx.com>
parents:
5545
diff
changeset
|
1461 #endif |
2e40188f83ef
Fixed a compile warning introduced by 01e2a5bcdd8f.
Ruslan Ermilov <ru@nginx.com>
parents:
5545
diff
changeset
|
1462 |
6289
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1463 if (len == 2 && data[0] == 'h' && data[1] == '2') { |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1464 ngx_http_v2_init(c->read); |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1465 return; |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
1466 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1467 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1468 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1469 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1470 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
1471 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
|
1472 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
1473 c->read->handler = ngx_http_wait_request_handler; |
547 | 1474 /* STUB: epoll edge */ c->write->handler = ngx_http_empty_handler; |
1475 | |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
1476 ngx_reusable_connection(c, 1); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
1477 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
1478 ngx_http_wait_request_handler(c->read); |
547 | 1479 |
1480 return; | |
1481 } | |
1482 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1483 if (c->read->timedout) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1484 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
|
1485 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1486 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1487 ngx_http_close_connection(c); |
547 | 1488 } |
1489 | |
7458 | 1490 |
1219 | 1491 #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME |
1492 | |
1493 int | |
1494 ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg) | |
1495 { | |
7472
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1496 ngx_int_t rc; |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1497 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
|
1498 const char *servername; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1499 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
|
1500 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
|
1501 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
|
1502 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
|
1503 ngx_http_core_srv_conf_t *cscf; |
1219 | 1504 |
1505 c = ngx_ssl_get_connection(ssl_conn); | |
1506 | |
7367
bf1ac3dc1e68
SSL: fixed segfault on renegotiation (ticket #1646).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7354
diff
changeset
|
1507 if (c->ssl->handshaked) { |
7472
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1508 *ad = SSL_AD_NO_RENEGOTIATION; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1509 return SSL_TLSEXT_ERR_ALERT_FATAL; |
6320
a6902a941279
SSL: fixed possible segfault on renegotiation (ticket #845).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6306
diff
changeset
|
1510 } |
a6902a941279
SSL: fixed possible segfault on renegotiation (ticket #845).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6306
diff
changeset
|
1511 |
7475
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
1512 servername = SSL_get_servername(ssl_conn, TLSEXT_NAMETYPE_host_name); |
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
1513 |
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
1514 if (servername == NULL) { |
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
1515 return SSL_TLSEXT_ERR_OK; |
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
1516 } |
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
1517 |
1219 | 1518 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1519 "SSL server name: \"%s\"", servername); | |
1520 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1521 host.len = ngx_strlen(servername); |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1522 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1523 if (host.len == 0) { |
7471
7e8bcba6d039
SSL: server name callback changed to return SSL_TLSEXT_ERR_OK.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7466
diff
changeset
|
1524 return SSL_TLSEXT_ERR_OK; |
2195 | 1525 } |
1526 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1527 host.data = (u_char *) servername; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1528 |
7472
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1529 rc = ngx_http_validate_host(&host, c->pool, 1); |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1530 |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1531 if (rc == NGX_ERROR) { |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1532 *ad = SSL_AD_INTERNAL_ERROR; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1533 return SSL_TLSEXT_ERR_ALERT_FATAL; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1534 } |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1535 |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1536 if (rc == NGX_DECLINED) { |
7471
7e8bcba6d039
SSL: server name callback changed to return SSL_TLSEXT_ERR_OK.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7466
diff
changeset
|
1537 return SSL_TLSEXT_ERR_OK; |
3152 | 1538 } |
1539 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1540 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
|
1541 |
7472
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1542 rc = ngx_http_find_virtual_server(c, hc->addr_conf->virtual_names, &host, |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1543 NULL, &cscf); |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1544 |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1545 if (rc == NGX_ERROR) { |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1546 *ad = SSL_AD_INTERNAL_ERROR; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1547 return SSL_TLSEXT_ERR_ALERT_FATAL; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1548 } |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1549 |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1550 if (rc == NGX_DECLINED) { |
7471
7e8bcba6d039
SSL: server name callback changed to return SSL_TLSEXT_ERR_OK.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7466
diff
changeset
|
1551 return SSL_TLSEXT_ERR_OK; |
1219 | 1552 } |
1553 | |
5093
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1554 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
|
1555 if (hc->ssl_servername == NULL) { |
7472
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1556 *ad = SSL_AD_INTERNAL_ERROR; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1557 return SSL_TLSEXT_ERR_ALERT_FATAL; |
5093
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1558 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1559 |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1560 *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
|
1561 |
5089
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
1562 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
|
1563 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1564 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
|
1565 |
6129
187aa751ad62
Core: the ngx_set_connection_log() macro.
Vladimir Homutov <vl@nginx.com>
parents:
6126
diff
changeset
|
1566 ngx_set_connection_log(c, clcf->error_log); |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
1567 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1568 sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module); |
1219 | 1569 |
6901
72bb626484a4
SSL: fixed ssl_buffer_size on SNI virtual hosts (ticket #1192).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6584
diff
changeset
|
1570 c->ssl->buffer_size = sscf->buffer_size; |
72bb626484a4
SSL: fixed ssl_buffer_size on SNI virtual hosts (ticket #1192).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6584
diff
changeset
|
1571 |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1572 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
|
1573 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
|
1574 |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1575 /* |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1576 * 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
|
1577 * 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
|
1578 */ |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1579 |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1580 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
|
1581 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
|
1582 |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1583 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
|
1584 |
7318
3443fe40bdc7
SSL: fixed SSL_clear_options() usage with OpenSSL 1.1.0+.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7313
diff
changeset
|
1585 #if OPENSSL_VERSION_NUMBER >= 0x009080dfL |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1586 /* 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
|
1587 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
|
1588 ~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
|
1589 #endif |
4e1a489c26cd
Better handling of various per-server ssl options with SNI.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3985
diff
changeset
|
1590 |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1591 SSL_set_options(ssl_conn, SSL_CTX_get_options(sscf->ssl.ctx)); |
7367
bf1ac3dc1e68
SSL: fixed segfault on renegotiation (ticket #1646).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7354
diff
changeset
|
1592 |
bf1ac3dc1e68
SSL: fixed segfault on renegotiation (ticket #1646).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7354
diff
changeset
|
1593 #ifdef SSL_OP_NO_RENEGOTIATION |
bf1ac3dc1e68
SSL: fixed segfault on renegotiation (ticket #1646).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7354
diff
changeset
|
1594 SSL_set_options(ssl_conn, SSL_OP_NO_RENEGOTIATION); |
bf1ac3dc1e68
SSL: fixed segfault on renegotiation (ticket #1646).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7354
diff
changeset
|
1595 #endif |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1596 } |
4033
4e1a489c26cd
Better handling of various per-server ssl options with SNI.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3985
diff
changeset
|
1597 |
1219 | 1598 return SSL_TLSEXT_ERR_OK; |
1599 } | |
1600 | |
1601 #endif | |
547 | 1602 |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1603 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1604 #ifdef SSL_R_CERT_CB_ERROR |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1605 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1606 int |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1607 ngx_http_ssl_certificate(ngx_ssl_conn_t *ssl_conn, void *arg) |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1608 { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1609 ngx_str_t cert, key; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1610 ngx_uint_t i, nelts; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1611 ngx_connection_t *c; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1612 ngx_http_request_t *r; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1613 ngx_http_ssl_srv_conf_t *sscf; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1614 ngx_http_complex_value_t *certs, *keys; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1615 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1616 c = ngx_ssl_get_connection(ssl_conn); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1617 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1618 if (c->ssl->handshaked) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1619 return 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1620 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1621 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1622 r = ngx_http_alloc_request(c); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1623 if (r == NULL) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1624 return 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1625 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1626 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1627 r->logged = 1; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1628 |
7466
48c87377aabd
SSL: fixed possible segfault with dynamic certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7463
diff
changeset
|
1629 sscf = arg; |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1630 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1631 nelts = sscf->certificate_values->nelts; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1632 certs = sscf->certificate_values->elts; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1633 keys = sscf->certificate_key_values->elts; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1634 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1635 for (i = 0; i < nelts; i++) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1636 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1637 if (ngx_http_complex_value(r, &certs[i], &cert) != NGX_OK) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1638 goto failed; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1639 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1640 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1641 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1642 "ssl cert: \"%s\"", cert.data); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1643 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1644 if (ngx_http_complex_value(r, &keys[i], &key) != NGX_OK) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1645 goto failed; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1646 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1647 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1648 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1649 "ssl key: \"%s\"", key.data); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1650 |
7463
180df83473a4
SSL: passwords support for dynamic certificate loading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7462
diff
changeset
|
1651 if (ngx_ssl_connection_certificate(c, r->pool, &cert, &key, |
180df83473a4
SSL: passwords support for dynamic certificate loading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7462
diff
changeset
|
1652 sscf->passwords) |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1653 != NGX_OK) |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1654 { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1655 goto failed; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1656 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1657 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1658 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1659 ngx_http_free_request(r, 0); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1660 c->destroyed = 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1661 return 1; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1662 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1663 failed: |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1664 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1665 ngx_http_free_request(r, 0); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1666 c->destroyed = 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1667 return 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1668 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1669 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1670 #endif |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1671 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1672 #endif |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1673 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
1674 |
501 | 1675 static void |
1676 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
|
1677 { |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1678 ssize_t n; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1679 ngx_int_t rc, rv; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1680 ngx_str_t host; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1681 ngx_connection_t *c; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1682 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
|
1683 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1684 c = rev->data; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1685 r = c->data; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1686 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1687 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
|
1688 "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
|
1689 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
1690 if (rev->timedout) { |
505 | 1691 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
1692 c->timedout = 1; | |
1693 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
|
1694 return; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
1695 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1696 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1697 rc = NGX_AGAIN; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1698 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1699 for ( ;; ) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1700 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1701 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
|
1702 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
|
1703 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1704 if (n == NGX_AGAIN || n == NGX_ERROR) { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1705 break; |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1706 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1707 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1708 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1709 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
|
1710 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1711 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
|
1712 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1713 /* 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
|
1714 |
461 | 1715 r->request_line.len = r->request_end - r->request_start; |
1716 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
|
1717 r->request_length = r->header_in->pos - r->request_start; |
461 | 1718 |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1719 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
|
1720 "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
|
1721 |
509 | 1722 r->method_name.len = r->method_end - r->request_start + 1; |
1723 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
|
1724 |
479 | 1725 if (r->http_protocol.data) { |
1726 r->http_protocol.len = r->request_end - r->http_protocol.data; | |
1727 } | |
1728 | |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1729 if (ngx_http_process_request_uri(r) != NGX_OK) { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1730 break; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1731 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1732 |
7295 | 1733 if (r->schema_end) { |
1734 r->schema.len = r->schema_end - r->schema_start; | |
1735 r->schema.data = r->schema_start; | |
1736 } | |
1737 | |
7294
21ad2af3262c
Removed extraneous check while processing request line.
Ruslan Ermilov <ru@nginx.com>
parents:
7269
diff
changeset
|
1738 if (r->host_end) { |
3152 | 1739 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1740 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
|
1741 host.data = r->host_start; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1742 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1743 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
|
1744 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1745 if (rc == NGX_DECLINED) { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1746 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
|
1747 "client sent invalid host in request line"); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1748 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1749 break; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1750 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1751 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1752 if (rc == NGX_ERROR) { |
3152 | 1753 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1754 break; |
3152 | 1755 } |
1756 | |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1757 if (ngx_http_set_virtual_server(r, &host) == NGX_ERROR) { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1758 break; |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1759 } |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1760 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1761 r->headers_in.server = host; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1762 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1763 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1764 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
|
1765 |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1766 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
|
1767 && 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
|
1768 == NGX_ERROR) |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1769 { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1770 break; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1771 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1772 |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1773 ngx_http_process_request(r); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1774 break; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1775 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1776 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1777 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1778 if (ngx_list_init(&r->headers_in.headers, r->pool, 20, |
581 | 1779 sizeof(ngx_table_elt_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2534
diff
changeset
|
1780 != NGX_OK) |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1781 { |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1782 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1783 break; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1784 } |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
1785 |
483 | 1786 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
|
1787 |
509 | 1788 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
|
1789 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
|
1790 |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1791 break; |
505 | 1792 } |
1793 | |
1794 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
|
1795 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1796 /* 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
|
1797 |
505 | 1798 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
1799 ngx_http_client_errors[rc - NGX_HTTP_CLIENT_ERROR]); | |
6993
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1800 |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1801 if (rc == NGX_HTTP_PARSE_INVALID_VERSION) { |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1802 ngx_http_finalize_request(r, NGX_HTTP_VERSION_NOT_SUPPORTED); |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1803 |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1804 } else { |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1805 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1806 } |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1807 |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1808 break; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
1809 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
1810 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1811 /* 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
|
1812 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1813 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
|
1814 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1815 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
|
1816 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1817 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
|
1818 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1819 break; |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
1820 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1821 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1822 if (rv == NGX_DECLINED) { |
505 | 1823 r->request_line.len = r->header_in->end - r->request_start; |
1824 r->request_line.data = r->request_start; | |
1825 | |
1826 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
1827 "client sent too long URI"); | |
1828 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_URI_TOO_LARGE); | |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1829 break; |
66
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
1830 } |
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
1831 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
1832 } |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1833 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1834 ngx_http_run_posted_requests(c); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1835 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1836 |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
1837 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1838 ngx_int_t |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1839 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
|
1840 { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1841 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
|
1842 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1843 if (r->args_start) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1844 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
|
1845 } else { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1846 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
|
1847 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1848 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1849 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
|
1850 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1851 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
|
1852 if (r->uri.data == NULL) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1853 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
|
1854 return NGX_ERROR; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1855 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1856 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1857 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
|
1858 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1859 if (ngx_http_parse_complex_uri(r, cscf->merge_slashes) != NGX_OK) { |
5769
e0aa54a4357e
Reset of r->uri.len on URI parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5605
diff
changeset
|
1860 r->uri.len = 0; |
e0aa54a4357e
Reset of r->uri.len on URI parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5605
diff
changeset
|
1861 |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1862 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
|
1863 "client sent invalid request"); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1864 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
|
1865 return NGX_ERROR; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1866 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1867 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1868 } else { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1869 r->uri.data = r->uri_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1870 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1871 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1872 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
|
1873 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
|
1874 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1875 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
|
1876 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1877 if (r->uri_ext) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1878 if (r->args_start) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1879 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
|
1880 } else { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1881 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
|
1882 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1883 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1884 r->exten.data = r->uri_ext; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1885 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1886 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1887 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
|
1888 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
|
1889 r->args.data = r->args_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1890 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1891 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1892 #if (NGX_WIN32) |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1893 { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1894 u_char *p, *last; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1895 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1896 p = r->uri.data; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1897 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
|
1898 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1899 while (p < last) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1900 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1901 if (*p++ == ':') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1902 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1903 /* |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1904 * 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
|
1905 * ":$i30:$index_allocation" |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1906 */ |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1907 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1908 if (p < last && *p == '$') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1909 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
|
1910 "client sent unsafe win32 URI"); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1911 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
|
1912 return NGX_ERROR; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1913 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1914 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1915 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1916 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1917 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
|
1918 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1919 while (p > r->uri.data) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1920 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1921 if (*p == ' ') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1922 p--; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1923 continue; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1924 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1925 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1926 if (*p == '.') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1927 p--; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1928 continue; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1929 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1930 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1931 break; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1932 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1933 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1934 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
|
1935 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
|
1936 ngx_http_set_exten(r); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1937 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1938 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1939 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1940 #endif |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1941 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1942 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
|
1943 "http uri: \"%V\"", &r->uri); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1944 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1945 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
|
1946 "http args: \"%V\"", &r->args); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1947 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1948 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
|
1949 "http exten: \"%V\"", &r->exten); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1950 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1951 return NGX_OK; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1952 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1953 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1954 |
501 | 1955 static void |
1956 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
|
1957 { |
3076 | 1958 u_char *p; |
1959 size_t len; | |
507 | 1960 ssize_t n; |
1961 ngx_int_t rc, rv; | |
509 | 1962 ngx_table_elt_t *h; |
507 | 1963 ngx_connection_t *c; |
1964 ngx_http_header_t *hh; | |
1965 ngx_http_request_t *r; | |
511 | 1966 ngx_http_core_srv_conf_t *cscf; |
507 | 1967 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
|
1968 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1969 c = rev->data; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1970 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
|
1971 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1972 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
|
1973 "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
|
1974 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1975 if (rev->timedout) { |
505 | 1976 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
1977 c->timedout = 1; | |
1978 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
|
1979 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1980 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1981 |
507 | 1982 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
1983 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1984 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
|
1985 |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
1986 for ( ;; ) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1987 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1988 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
|
1989 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1990 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
|
1991 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1992 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
|
1993 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1994 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
|
1995 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1996 break; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1997 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1998 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1999 if (rv == NGX_DECLINED) { |
3076 | 2000 p = r->header_name_start; |
2001 | |
3848
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
2002 r->lingering_close = 1; |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
2003 |
3287
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
2004 if (p == NULL) { |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
2005 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
|
2006 "client sent too large request"); |
3848
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
2007 ngx_http_finalize_request(r, |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
2008 NGX_HTTP_REQUEST_HEADER_TOO_LARGE); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2009 break; |
3287
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
2010 } |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
2011 |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
2012 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
|
2013 |
3076 | 2014 if (len > NGX_MAX_ERROR_STR - 300) { |
2015 len = NGX_MAX_ERROR_STR - 300; | |
531 | 2016 } |
2017 | |
505 | 2018 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
5871
21043ce2a005
Fixed possible buffer overrun in "too long header line" logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5813
diff
changeset
|
2019 "client sent too long header line: \"%*s...\"", |
21043ce2a005
Fixed possible buffer overrun in "too long header line" logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5813
diff
changeset
|
2020 len, r->header_name_start); |
3848
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
2021 |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
2022 ngx_http_finalize_request(r, |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
2023 NGX_HTTP_REQUEST_HEADER_TOO_LARGE); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2024 break; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2025 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2026 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2027 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2028 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
|
2029 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2030 if (n == NGX_AGAIN || n == NGX_ERROR) { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2031 break; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2032 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2033 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2034 |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
2035 /* 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
|
2036 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
|
2037 |
2256 | 2038 rc = ngx_http_parse_header_line(r, r->header_in, |
2039 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
|
2040 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2041 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
|
2042 |
4739
986cc869b09d
Corrected $request_length calculation for pipelined requests.
Andrey Belov <defan@nginx.com>
parents:
4697
diff
changeset
|
2043 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
|
2044 |
511 | 2045 if (r->invalid_header && cscf->ignore_invalid_headers) { |
503 | 2046 |
2047 /* there was error while a header line parsing */ | |
2048 | |
505 | 2049 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
3076 | 2050 "client sent invalid header line: \"%*s\"", |
2051 r->header_end - r->header_name_start, | |
2052 r->header_name_start); | |
503 | 2053 continue; |
2054 } | |
2055 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2056 /* 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
|
2057 |
501 | 2058 h = ngx_list_push(&r->headers_in.headers); |
2059 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
|
2060 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2061 break; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2062 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2063 |
507 | 2064 h->hash = r->header_hash; |
2065 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2066 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
|
2067 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
|
2068 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
|
2069 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2070 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
|
2071 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
|
2072 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
|
2073 |
2049 | 2074 h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); |
649 | 2075 if (h->lowcase_key == NULL) { |
2076 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2077 break; |
649 | 2078 } |
2079 | |
2080 if (h->key.len == r->lowcase_index) { | |
2081 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
2082 | |
2083 } else { | |
2135 | 2084 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
|
2085 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2086 |
649 | 2087 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, |
2088 h->lowcase_key, h->key.len); | |
2089 | |
2090 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2091 break; |
649 | 2092 } |
2093 | |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
2094 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 2095 "http header: \"%V: %V\"", |
2096 &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
|
2097 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
2098 continue; |
505 | 2099 } |
2100 | |
2101 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
|
2102 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2103 /* 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
|
2104 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
2105 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
|
2106 "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
|
2107 |
4739
986cc869b09d
Corrected $request_length calculation for pipelined requests.
Andrey Belov <defan@nginx.com>
parents:
4697
diff
changeset
|
2108 r->request_length += r->header_in->pos - r->header_name_start; |
475 | 2109 |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
2110 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
|
2111 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2112 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
|
2113 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2114 if (rc != NGX_OK) { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2115 break; |
82
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
2116 } |
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
2117 |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2118 ngx_http_process_request(r); |
537 | 2119 |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2120 break; |
505 | 2121 } |
2122 | |
2123 if (rc == NGX_AGAIN) { | |
2124 | |
2125 /* a header line parsing is still not complete */ | |
2126 | |
2127 continue; | |
66
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
2128 } |
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
2129 |
6409
71edd9192f24
Fixed buffer over-read while logging invalid request headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6320
diff
changeset
|
2130 /* rc == NGX_HTTP_PARSE_INVALID_HEADER */ |
505 | 2131 |
2132 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
6409
71edd9192f24
Fixed buffer over-read while logging invalid request headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6320
diff
changeset
|
2133 "client sent invalid header line"); |
71edd9192f24
Fixed buffer over-read while logging invalid request headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6320
diff
changeset
|
2134 |
1427 | 2135 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2136 break; |
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
|
2137 } |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2138 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
2139 ngx_http_run_posted_requests(c); |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
2140 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
2141 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
2142 |
501 | 2143 static ssize_t |
2144 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
|
2145 { |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
2146 ssize_t n; |
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
2147 ngx_event_t *rev; |
681 | 2148 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
|
2149 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
|
2150 |
681 | 2151 c = r->connection; |
2152 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
|
2153 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2154 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
|
2155 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2156 if (n > 0) { |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2157 return n; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2158 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2159 |
523 | 2160 if (rev->ready) { |
681 | 2161 n = c->recv(c, r->header_in->last, |
2162 r->header_in->end - r->header_in->last); | |
523 | 2163 } else { |
2164 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
|
2165 } |
c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
2166 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2167 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
|
2168 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
|
2169 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
|
2170 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
|
2171 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2172 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2173 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
|
2174 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
|
2175 return NGX_ERROR; |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
2176 } |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
2177 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2178 return NGX_AGAIN; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2179 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2180 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2181 if (n == 0) { |
681 | 2182 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
|
2183 "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
|
2184 } |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2185 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2186 if (n == 0 || n == NGX_ERROR) { |
991 | 2187 c->error = 1; |
992 | 2188 c->log->action = "reading client request headers"; |
681 | 2189 |
991 | 2190 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
|
2191 return NGX_ERROR; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2192 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2193 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2194 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
|
2195 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2196 return n; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2197 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2198 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
2199 |
501 | 2200 static ngx_int_t |
2201 ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, | |
2202 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
|
2203 { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2204 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
|
2205 ngx_buf_t *b; |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2206 ngx_chain_t *cl; |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2207 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
|
2208 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
|
2209 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2210 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
|
2211 "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
|
2212 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2213 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
|
2214 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2215 /* 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
|
2216 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2217 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
|
2218 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
|
2219 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2220 return NGX_OK; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2221 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2222 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2223 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
|
2224 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2225 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
|
2226 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2227 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
|
2228 && (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
|
2229 >= 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
|
2230 { |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2231 return NGX_DECLINED; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2232 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2233 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2234 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
|
2235 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2236 if (hc->free) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2237 cl = hc->free; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2238 hc->free = cl->next; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2239 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2240 b = cl->buf; |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2241 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2242 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 2243 "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
|
2244 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
|
2245 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2246 } 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
|
2247 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2248 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
|
2249 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
|
2250 if (b == NULL) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2251 return NGX_ERROR; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2252 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2253 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2254 cl = ngx_alloc_chain_link(r->connection->pool); |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2255 if (cl == NULL) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2256 return NGX_ERROR; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2257 } |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2258 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2259 cl->buf = b; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2260 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2261 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 2262 "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
|
2263 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
|
2264 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2265 } else { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2266 return NGX_DECLINED; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2267 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2268 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2269 cl->next = hc->busy; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2270 hc->busy = cl; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
2271 hc->nbusy++; |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2272 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2273 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
|
2274 /* |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2275 * 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
|
2276 * 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
|
2277 * 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
|
2278 */ |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2279 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2280 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
|
2281 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2282 return NGX_OK; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2283 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2284 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2285 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6480 | 2286 "http large header copy: %uz", 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
|
2287 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2288 new = b->start; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2289 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2290 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
|
2291 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2292 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
|
2293 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
|
2294 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2295 if (request_line) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2296 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
|
2297 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2298 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
|
2299 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
|
2300 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2301 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2302 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
|
2303 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2304 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
|
2305 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
|
2306 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2307 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
|
2308 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
|
2309 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
|
2310 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2311 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2312 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
|
2313 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
|
2314 if (r->host_end) { |
a6fe6bedb9e3
fix segfault when $host is used and
Igor Sysoev <igor@sysoev.ru>
parents:
895
diff
changeset
|
2315 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
|
2316 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2317 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2318 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2319 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
|
2320 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
|
2321 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
|
2322 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2323 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2324 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
|
2325 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
|
2326 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2327 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2328 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
|
2329 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
|
2330 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2331 |
1677
c997912a8f0b
copy protocol value when large request line is copied,
Igor Sysoev <igor@sysoev.ru>
parents:
1676
diff
changeset
|
2332 if (r->http_protocol.data) { |
c997912a8f0b
copy protocol value when large request line is copied,
Igor Sysoev <igor@sysoev.ru>
parents:
1676
diff
changeset
|
2333 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
|
2334 } |
c997912a8f0b
copy protocol value when large request line is copied,
Igor Sysoev <igor@sysoev.ru>
parents:
1676
diff
changeset
|
2335 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2336 } else { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2337 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
|
2338 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
|
2339 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
|
2340 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
|
2341 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2342 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2343 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
|
2344 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2345 return NGX_OK; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2346 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2347 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2348 |
501 | 2349 static ngx_int_t |
509 | 2350 ngx_http_process_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, |
2351 ngx_uint_t offset) | |
2352 { | |
2353 ngx_table_elt_t **ph; | |
2354 | |
2355 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
2356 | |
2357 if (*ph == NULL) { | |
2358 *ph = h; | |
2359 } | |
2360 | |
2361 return NGX_OK; | |
2362 } | |
2363 | |
2364 | |
2365 static ngx_int_t | |
523 | 2366 ngx_http_process_unique_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, |
2367 ngx_uint_t offset) | |
2368 { | |
2369 ngx_table_elt_t **ph; | |
2370 | |
2371 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
2372 | |
2373 if (*ph == NULL) { | |
2374 *ph = h; | |
2375 return NGX_OK; | |
2376 } | |
2377 | |
2378 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
681 | 2379 "client sent duplicate header line: \"%V: %V\", " |
2380 "previous value: \"%V: %V\"", | |
2381 &h->key, &h->value, &(*ph)->key, &(*ph)->value); | |
523 | 2382 |
2383 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
2384 | |
2385 return NGX_ERROR; | |
2386 } | |
2387 | |
2388 | |
2389 static ngx_int_t | |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2390 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
|
2391 ngx_uint_t offset) |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2392 { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2393 ngx_int_t rc; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2394 ngx_str_t host; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2395 |
7627
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2396 if (r->headers_in.host) { |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2397 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2398 "client sent duplicate host header: \"%V: %V\", " |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2399 "previous value: \"%V: %V\"", |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2400 &h->key, &h->value, &r->headers_in.host->key, |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2401 &r->headers_in.host->value); |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2402 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2403 return NGX_ERROR; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2404 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2405 |
7627
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2406 r->headers_in.host = h; |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
2407 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2408 host = h->value; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2409 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2410 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
|
2411 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2412 if (rc == NGX_DECLINED) { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2413 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
|
2414 "client sent invalid host header"); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2415 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
|
2416 return NGX_ERROR; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2417 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2418 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2419 if (rc == NGX_ERROR) { |
3152 | 2420 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
2421 return NGX_ERROR; | |
2422 } | |
2423 | |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2424 if (r->headers_in.server.len) { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2425 return NGX_OK; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2426 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2427 |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
2428 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
|
2429 return NGX_ERROR; |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
2430 } |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
2431 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2432 r->headers_in.server = host; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2433 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2434 return NGX_OK; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2435 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2436 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2437 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2438 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
|
2439 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
|
2440 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
|
2441 { |
1549 | 2442 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
|
2443 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
|
2444 |
1549 | 2445 } 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
|
2446 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
|
2447 } |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
2448 |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
2449 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
|
2450 } |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
2451 |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
2452 |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
2453 static ngx_int_t |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2454 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
|
2455 ngx_uint_t offset) |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2456 { |
2205 | 2457 u_char *user_agent, *msie; |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2458 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2459 if (r->headers_in.user_agent) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2460 return NGX_OK; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2461 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2462 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2463 r->headers_in.user_agent = h; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2464 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2465 /* 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
|
2466 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2467 user_agent = h->value.data; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2468 |
2205 | 2469 msie = ngx_strstrn(user_agent, "MSIE ", 5 - 1); |
2470 | |
2471 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
|
2472 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2473 r->headers_in.msie = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2474 |
2205 | 2475 if (msie[6] == '.') { |
2476 | |
2477 switch (msie[5]) { | |
2478 case '4': | |
2479 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
|
2480 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
|
2481 break; |
2205 | 2482 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
|
2483 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
|
2484 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
|
2485 } |
a137de814516
do not disable gzip for MSIE 6.0 SV1 in "gzip_disable msie6"
Igor Sysoev <igor@sysoev.ru>
parents:
3052
diff
changeset
|
2486 break; |
2205 | 2487 } |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2488 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2489 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2490 #if 0 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2491 /* MSIE ignores the SSL "close notify" alert */ |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2492 if (c->ssl) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2493 c->ssl->no_send_shutdown = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2494 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2495 #endif |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2496 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2497 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2498 if (ngx_strstrn(user_agent, "Opera", 5 - 1)) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2499 r->headers_in.opera = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2500 r->headers_in.msie = 0; |
2205 | 2501 r->headers_in.msie6 = 0; |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2502 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2503 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2504 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
|
2505 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2506 if (ngx_strstrn(user_agent, "Gecko/", 6 - 1)) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2507 r->headers_in.gecko = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2508 |
3315 | 2509 } else if (ngx_strstrn(user_agent, "Chrome/", 7 - 1)) { |
2510 r->headers_in.chrome = 1; | |
2511 | |
4552
b00098cbc44d
Restricted keepalive_disable safari to OS X only.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4472
diff
changeset
|
2512 } 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
|
2513 && 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
|
2514 { |
3419
fcd72b8d69f3
disable keepalive for Safari:
Igor Sysoev <igor@sysoev.ru>
parents:
3416
diff
changeset
|
2515 r->headers_in.safari = 1; |
fcd72b8d69f3
disable keepalive for Safari:
Igor Sysoev <igor@sysoev.ru>
parents:
3416
diff
changeset
|
2516 |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2517 } 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
|
2518 r->headers_in.konqueror = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2519 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2520 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2521 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2522 return NGX_OK; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2523 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2524 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2525 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2526 static ngx_int_t |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2527 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
|
2528 ngx_uint_t offset) |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2529 { |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2530 ngx_array_t *headers; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2531 ngx_table_elt_t **ph; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2532 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2533 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
|
2534 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2535 if (headers->elts == NULL) { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2536 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
|
2537 != NGX_OK) |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2538 { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2539 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
|
2540 return NGX_ERROR; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2541 } |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2542 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2543 |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2544 ph = ngx_array_push(headers); |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2545 if (ph == NULL) { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2546 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
|
2547 return NGX_ERROR; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2548 } |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2549 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2550 *ph = h; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2551 return NGX_OK; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2552 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2553 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2554 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2555 ngx_int_t |
501 | 2556 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
|
2557 { |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
2558 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
|
2559 && 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
|
2560 == NGX_ERROR) |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
2561 { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2562 return NGX_ERROR; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2563 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2564 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2565 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
|
2566 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
|
2567 "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
|
2568 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
|
2569 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
|
2570 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2571 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2572 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
|
2573 r->headers_in.content_length_n = |
663 | 2574 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
|
2575 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
|
2576 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2577 if (r->headers_in.content_length_n == NGX_ERROR) { |
505 | 2578 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
2579 "client sent invalid \"Content-Length\" header"); | |
4930
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2580 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
505 | 2581 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
|
2582 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2583 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2584 |
6306
b1858fc47e3b
Style: unified request method checks.
Ruslan Ermilov <ru@nginx.com>
parents:
6289
diff
changeset
|
2585 if (r->method == NGX_HTTP_TRACE) { |
1151 | 2586 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
2587 "client sent TRACE method"); | |
2588 ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED); | |
2589 return NGX_ERROR; | |
2590 } | |
2591 | |
4930
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2592 if (r->headers_in.transfer_encoding) { |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2593 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
|
2594 && 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
|
2595 (u_char *) "chunked", 7) == 0) |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2596 { |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2597 r->headers_in.content_length = NULL; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2598 r->headers_in.content_length_n = -1; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2599 r->headers_in.chunked = 1; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2600 |
7626
fe5976aae0e3
Removed "Transfer-Encoding: identity" support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7625
diff
changeset
|
2601 } else { |
4930
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2602 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
|
2603 "client sent unknown \"Transfer-Encoding\": \"%V\"", |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2604 &r->headers_in.transfer_encoding->value); |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2605 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
|
2606 return NGX_ERROR; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2607 } |
298
4a3f18406832
nginx-0.0.3-2004-03-30-10:27:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
2608 } |
4a3f18406832
nginx-0.0.3-2004-03-30-10:27:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
2609 |
1467
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
2610 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
|
2611 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
|
2612 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
|
2613 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
|
2614 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
|
2615 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2616 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2617 |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2618 return NGX_OK; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2619 } |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2620 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2621 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2622 void |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2623 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
|
2624 { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1677
diff
changeset
|
2625 ngx_connection_t *c; |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2626 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2627 c = r->connection; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2628 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2629 #if (NGX_HTTP_SSL) |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2630 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2631 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
|
2632 long rc; |
1974
f32cc6df6bd6
fix memory leak when ssl_verify_client is on
Igor Sysoev <igor@sysoev.ru>
parents:
1924
diff
changeset
|
2633 X509 *cert; |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1677
diff
changeset
|
2634 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
|
2635 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2636 if (c->ssl == NULL) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2637 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
|
2638 "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
|
2639 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
|
2640 return; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2641 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2642 |
669 | 2643 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); |
2644 | |
2994 | 2645 if (sscf->verify) { |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2646 rc = SSL_get_verify_result(c->ssl->connection); |
669 | 2647 |
4884
e406c997470a
SSL: the "ssl_verify_client" directive parameter "optional_no_ca".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4770
diff
changeset
|
2648 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
|
2649 && (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
|
2650 { |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2651 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
671 | 2652 "client SSL certificate verify error: (%l:%s)", |
669 | 2653 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
|
2654 |
7193
9d14931cec8c
SSL: using default server context in session remove (closes #1464).
Sergey Kandaurov <pluknet@nginx.com>
parents:
7156
diff
changeset
|
2655 ngx_ssl_remove_cached_session(c->ssl->session_ctx, |
1924
291689a7e5dc
invalidate SSL session if there is no valid client certificate
Igor Sysoev <igor@sysoev.ru>
parents:
1894
diff
changeset
|
2656 (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
|
2657 |
669 | 2658 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
|
2659 return; |
669 | 2660 } |
2661 | |
2994 | 2662 if (sscf->verify == 1) { |
2663 cert = SSL_get_peer_certificate(c->ssl->connection); | |
2664 | |
2665 if (cert == NULL) { | |
2666 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
2667 "client sent no required SSL certificate"); | |
2668 | |
7193
9d14931cec8c
SSL: using default server context in session remove (closes #1464).
Sergey Kandaurov <pluknet@nginx.com>
parents:
7156
diff
changeset
|
2669 ngx_ssl_remove_cached_session(c->ssl->session_ctx, |
1924
291689a7e5dc
invalidate SSL session if there is no valid client certificate
Igor Sysoev <igor@sysoev.ru>
parents:
1894
diff
changeset
|
2670 (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
|
2671 |
2994 | 2672 ngx_http_finalize_request(r, NGX_HTTPS_NO_CERT); |
2673 return; | |
2674 } | |
2675 | |
2676 X509_free(cert); | |
669 | 2677 } |
2678 } | |
2679 } | |
2680 | |
2681 #endif | |
2682 | |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2683 if (c->read->timer_set) { |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2684 ngx_del_timer(c->read); |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2685 } |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2686 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2687 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
2688 (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
|
2689 r->stat_reading = 0; |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
2690 (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
|
2691 r->stat_writing = 1; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2692 #endif |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2693 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2694 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
|
2695 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
|
2696 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
|
2697 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2698 ngx_http_handler(r); |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2699 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2700 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2701 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2702 static ngx_int_t |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2703 ngx_http_validate_host(ngx_str_t *host, ngx_pool_t *pool, ngx_uint_t alloc) |
477 | 2704 { |
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
|
2705 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
|
2706 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
|
2707 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2708 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
|
2709 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
|
2710 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
|
2711 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
|
2712 } 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
|
2713 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2714 dot_pos = host->len; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2715 host_len = host->len; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2716 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2717 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
|
2718 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2719 state = sw_usual; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2720 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2721 for (i = 0; i < host->len; i++) { |
3152 | 2722 ch = h[i]; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2723 |
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
|
2724 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
|
2725 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2726 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
|
2727 if (dot_pos == i - 1) { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2728 return NGX_DECLINED; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2729 } |
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
|
2730 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
|
2731 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
|
2732 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2733 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
|
2734 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
|
2735 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
|
2736 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
|
2737 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2738 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
|
2739 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2740 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
|
2741 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
|
2742 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
|
2743 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2744 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
|
2745 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2746 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
|
2747 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
|
2748 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
|
2749 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
|
2750 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2751 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
|
2752 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2753 case '\0': |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2754 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
|
2755 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2756 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
|
2757 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2758 if (ngx_path_separator(ch)) { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2759 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
|
2760 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2761 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2762 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
|
2763 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
|
2764 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2765 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2766 break; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2767 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2768 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2769 |
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
|
2770 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
|
2771 host_len--; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2772 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2773 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2774 if (host_len == 0) { |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2775 return NGX_DECLINED; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2776 } |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2777 |
3152 | 2778 if (alloc) { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2779 host->data = ngx_pnalloc(pool, host_len); |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2780 if (host->data == NULL) { |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2781 return NGX_ERROR; |
3152 | 2782 } |
2783 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2784 ngx_strlow(host->data, h, host_len); |
3152 | 2785 } |
2786 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2787 host->len = host_len; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2788 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2789 return NGX_OK; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2790 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2791 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2792 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2793 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
|
2794 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
|
2795 { |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2796 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
|
2797 ngx_http_connection_t *hc; |
593 | 2798 ngx_http_core_loc_conf_t *clcf; |
2799 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
|
2800 |
5548
4d47722d76b2
Fixed false compiler warning.
Vladimir Homutov <vl@nginx.com>
parents:
5547
diff
changeset
|
2801 #if (NGX_SUPPRESS_WARN) |
4d47722d76b2
Fixed false compiler warning.
Vladimir Homutov <vl@nginx.com>
parents:
5547
diff
changeset
|
2802 cscf = NULL; |
4d47722d76b2
Fixed false compiler warning.
Vladimir Homutov <vl@nginx.com>
parents:
5547
diff
changeset
|
2803 #endif |
4d47722d76b2
Fixed false compiler warning.
Vladimir Homutov <vl@nginx.com>
parents:
5547
diff
changeset
|
2804 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2805 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
|
2806 |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2807 #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
|
2808 |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2809 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
|
2810 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
|
2811 && 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
|
2812 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
|
2813 { |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2814 #if (NGX_PCRE) |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2815 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
|
2816 && 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
|
2817 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
|
2818 { |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2819 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
|
2820 return NGX_ERROR; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2821 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2822 #endif |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2823 return NGX_OK; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2824 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2825 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2826 |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2827 #endif |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2828 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2829 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
|
2830 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
|
2831 host, r, &cscf); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2832 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2833 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
|
2834 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
|
2835 return NGX_ERROR; |
477 | 2836 } |
2837 | |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2838 #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
|
2839 |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2840 if (hc->ssl_servername) { |
5095
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2841 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
|
2842 |
5094
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2843 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
|
2844 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
|
2845 rc = NGX_OK; |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2846 } |
5095
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2847 |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2848 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
|
2849 |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2850 if (sscf->verify) { |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2851 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
|
2852 "client attempted to request the server name " |
6584
690b15cc8915
Fixed an error log message.
Valentin Bartenev <vbart@nginx.com>
parents:
6556
diff
changeset
|
2853 "different from the one that was negotiated"); |
6556
654d2dae97d3
HTTP/2: the "421 Misdirected Request" response (closes #848).
Valentin Bartenev <vbart@nginx.com>
parents:
6538
diff
changeset
|
2854 ngx_http_finalize_request(r, NGX_HTTP_MISDIRECTED_REQUEST); |
5095
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2855 return NGX_ERROR; |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2856 } |
5094
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2857 } |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2858 |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2859 #endif |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2860 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2861 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
|
2862 return NGX_OK; |
1387 | 2863 } |
2864 | |
593 | 2865 r->srv_conf = cscf->ctx->srv_conf; |
2866 r->loc_conf = cscf->ctx->loc_conf; | |
509 | 2867 |
2868 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
|
2869 |
6129
187aa751ad62
Core: the ngx_set_connection_log() macro.
Vladimir Homutov <vl@nginx.com>
parents:
6126
diff
changeset
|
2870 ngx_set_connection_log(r->connection, clcf->error_log); |
477 | 2871 |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2872 return NGX_OK; |
477 | 2873 } |
2874 | |
2875 | |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2876 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
|
2877 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
|
2878 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
|
2879 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
|
2880 { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2881 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
|
2882 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2883 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
|
2884 return NGX_DECLINED; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2885 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2886 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2887 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
|
2888 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
|
2889 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
|
2890 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2891 if (cscf) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2892 *cscfp = cscf; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2893 return NGX_OK; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2894 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2895 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2896 #if (NGX_PCRE) |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2897 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2898 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
|
2899 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
|
2900 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
|
2901 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
|
2902 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2903 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
|
2904 |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2905 #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
|
2906 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2907 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
|
2908 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
|
2909 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2910 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
|
2911 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2912 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
|
2913 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2914 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
|
2915 continue; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2916 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2917 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2918 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
|
2919 hc = c->data; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2920 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
|
2921 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2922 *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
|
2923 return NGX_OK; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2924 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2925 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2926 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
|
2927 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
|
2928 "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
|
2929 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
|
2930 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2931 return NGX_ERROR; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2932 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2933 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2934 return NGX_DECLINED; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2935 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2936 |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2937 #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
|
2938 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2939 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
|
2940 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2941 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
|
2942 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2943 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
|
2944 continue; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2945 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2946 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2947 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
|
2948 *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
|
2949 return NGX_OK; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2950 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2951 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2952 return NGX_ERROR; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2953 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2954 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2955 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2956 #endif /* NGX_PCRE */ |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2957 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2958 return NGX_DECLINED; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2959 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2960 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2961 |
509 | 2962 static void |
2963 ngx_http_request_handler(ngx_event_t *ev) | |
2964 { | |
2965 ngx_connection_t *c; | |
2966 ngx_http_request_t *r; | |
2967 | |
2968 c = ev->data; | |
2969 r = c->data; | |
2970 | |
5928
8dfee01ff0bd
Upstream: improved subrequest logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5871
diff
changeset
|
2971 ngx_http_set_log_request(c->log, r); |
665 | 2972 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2973 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
|
2974 "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
|
2975 |
7156
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2976 if (c->close) { |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2977 r->main->count++; |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2978 ngx_http_terminate_request(r, 0); |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2979 ngx_http_run_posted_requests(c); |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2980 return; |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2981 } |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2982 |
6961
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2983 if (ev->delayed && ev->timedout) { |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2984 ev->delayed = 0; |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2985 ev->timedout = 0; |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2986 } |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2987 |
509 | 2988 if (ev->write) { |
2989 r->write_event_handler(r); | |
2990 | |
2991 } else { | |
2992 r->read_event_handler(r); | |
2993 } | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2994 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2995 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
|
2996 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2997 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2998 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2999 void |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3000 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
|
3001 { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3002 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
|
3003 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
|
3004 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3005 for ( ;; ) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3006 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3007 if (c->destroyed) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3008 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3009 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3010 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3011 r = c->data; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3012 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
|
3013 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3014 if (pr == NULL) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3015 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3016 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3017 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3018 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
|
3019 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3020 r = pr->request; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3021 |
5928
8dfee01ff0bd
Upstream: improved subrequest logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5871
diff
changeset
|
3022 ngx_http_set_log_request(c->log, r); |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3023 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3024 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
|
3025 "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
|
3026 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3027 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
|
3028 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3029 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3030 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3031 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3032 ngx_int_t |
3064 | 3033 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
|
3034 { |
3064 | 3035 ngx_http_posted_request_t **p; |
3036 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3037 if (pr == NULL) { |
3064 | 3038 pr = ngx_palloc(r->pool, sizeof(ngx_http_posted_request_t)); |
3039 if (pr == NULL) { | |
3040 return NGX_ERROR; | |
3041 } | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3042 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3043 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3044 pr->request = r; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3045 pr->next = NULL; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3046 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3047 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
|
3048 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3049 *p = pr; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3050 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3051 return NGX_OK; |
509 | 3052 } |
3053 | |
3054 | |
501 | 3055 void |
509 | 3056 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
|
3057 { |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3058 ngx_connection_t *c; |
509 | 3059 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
|
3060 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
|
3061 |
3049 | 3062 c = r->connection; |
3063 | |
3064 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
6480 | 3065 "http finalize request: %i, \"%V?%V\" a:%d, c:%d", |
3049 | 3066 rc, &r->uri, &r->args, r == c->data, r->main->count); |
3067 | |
509 | 3068 if (rc == NGX_DONE) { |
3049 | 3069 ngx_http_finalize_connection(r); |
509 | 3070 return; |
3071 } | |
3072 | |
2819
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
3073 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
|
3074 c->error = 1; |
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
3075 } |
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
3076 |
681 | 3077 if (rc == NGX_DECLINED) { |
3078 r->content_handler = NULL; | |
3079 r->write_event_handler = ngx_http_core_run_phases; | |
3080 ngx_http_core_run_phases(r); | |
3081 return; | |
3082 } | |
3083 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
716
diff
changeset
|
3084 if (r != r->main && r->post_subrequest) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
716
diff
changeset
|
3085 rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc); |
667 | 3086 } |
3087 | |
1783 | 3088 if (rc == NGX_ERROR |
3089 || rc == NGX_HTTP_REQUEST_TIME_OUT | |
3090 || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST | |
3091 || c->error) | |
3092 { | |
613 | 3093 if (ngx_http_post_action(r) == NGX_OK) { |
3094 return; | |
3095 } | |
3096 | |
3049 | 3097 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
|
3098 return; |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3099 } |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3100 |
637 | 3101 if (rc >= NGX_HTTP_SPECIAL_RESPONSE |
3102 || rc == NGX_HTTP_CREATED | |
3103 || rc == NGX_HTTP_NO_CONTENT) | |
3104 { | |
587 | 3105 if (rc == NGX_HTTP_CLOSE) { |
7313
e45f09198dab
Allow resetting connections closed by "return 444" (ticket #905).
Ruslan Ermilov <ru@nginx.com>
parents:
7295
diff
changeset
|
3106 c->timedout = 1; |
3049 | 3107 ngx_http_terminate_request(r, rc); |
587 | 3108 return; |
3109 } | |
3110 | |
597 | 3111 if (r == r->main) { |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3112 if (c->read->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3113 ngx_del_timer(c->read); |
569 | 3114 } |
3115 | |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3116 if (c->write->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3117 ngx_del_timer(c->write); |
569 | 3118 } |
3119 } | |
3120 | |
2250
7fc20e1105cd
set request handlers, this fixes complex proxied 400 handler with SSI includes
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
3121 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
|
3122 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
|
3123 |
569 | 3124 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); |
3125 return; | |
3126 } | |
3127 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3128 if (r != r->main) { |
7006
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3129 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3130 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3131 if (r->background) { |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3132 if (!r->logged) { |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3133 if (clcf->log_subrequest) { |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3134 ngx_http_log_request(r); |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3135 } |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3136 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3137 r->logged = 1; |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3138 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3139 } else { |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3140 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3141 "subrequest: \"%V?%V\" logged again", |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3142 &r->uri, &r->args); |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3143 } |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3144 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3145 r->done = 1; |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3146 ngx_http_finalize_connection(r); |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3147 return; |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3148 } |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3149 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3150 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
|
3151 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3152 if (ngx_http_set_write_handler(r) != NGX_OK) { |
3049 | 3153 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
|
3154 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3155 |
525 | 3156 return; |
3157 } | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3158 |
509 | 3159 pr = r->parent; |
3160 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3161 if (r == c->data) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3162 |
3049 | 3163 r->main->count--; |
3164 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3165 if (!r->logged) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3166 if (clcf->log_subrequest) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3167 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
|
3168 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3169 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3170 r->logged = 1; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3171 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3172 } else { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3173 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
|
3174 "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
|
3175 &r->uri, &r->args); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3176 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3177 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3178 r->done = 1; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3179 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3180 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
|
3181 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
|
3182 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3183 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3184 c->data = pr; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3185 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3186 } else { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3187 |
4612
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
3188 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
3189 "http finalize non-active request: \"%V?%V\"", |
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
3190 &r->uri, &r->args); |
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
3191 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3192 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
|
3193 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3194 if (r->waited) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3195 r->done = 1; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3196 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3197 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3198 |
3064 | 3199 if (ngx_http_post_request(pr, NULL) != NGX_OK) { |
3049 | 3200 r->main->count++; |
3201 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
|
3202 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3203 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3204 |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3205 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
|
3206 "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
|
3207 &pr->uri, &pr->args); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3208 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3209 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3210 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3211 |
7011
5e05118678af
Fixed background requests with asynchronous operations.
Roman Arutyunyan <arut@nginx.com>
parents:
7008
diff
changeset
|
3212 if (r->buffered || c->buffered || r->postponed) { |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3213 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3214 if (ngx_http_set_write_handler(r) != NGX_OK) { |
3049 | 3215 ngx_http_terminate_request(r, 0); |
2261 | 3216 } |
3217 | |
509 | 3218 return; |
3219 } | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
3220 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3221 if (r != c->data) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3222 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
|
3223 "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
|
3224 &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
|
3225 return; |
527 | 3226 } |
3227 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3228 r->done = 1; |
7006
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3229 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3230 r->read_event_handler = ngx_http_block_reading; |
3415
1b8c3599e3ce
Fix segfault when while discarding body a write event handler is called,
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
3231 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
|
3232 |
629 | 3233 if (!r->post_action) { |
3234 r->request_complete = 1; | |
3235 } | |
3236 | |
613 | 3237 if (ngx_http_post_action(r) == NGX_OK) { |
577 | 3238 return; |
3239 } | |
3240 | |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3241 if (c->read->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3242 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
|
3243 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3244 |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3245 if (c->write->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3246 c->write->delayed = 0; |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3247 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
|
3248 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3249 |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
3250 if (c->read->eof) { |
1423
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
3251 ngx_http_close_request(r, 0); |
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
3252 return; |
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
3253 } |
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
3254 |
3049 | 3255 ngx_http_finalize_connection(r); |
3256 } | |
3257 | |
3258 | |
3259 static void | |
3260 ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc) | |
3261 { | |
3064 | 3262 ngx_http_cleanup_t *cln; |
3263 ngx_http_request_t *mr; | |
3264 ngx_http_ephemeral_t *e; | |
3049 | 3265 |
3266 mr = r->main; | |
3267 | |
3268 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
|
3269 "http terminate request count:%d", mr->count); |
3049 | 3270 |
3176
60bc5cc68d3b
log 499 instead 0, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3153
diff
changeset
|
3271 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
|
3272 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
|
3273 } |
60bc5cc68d3b
log 499 instead 0, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3153
diff
changeset
|
3274 |
3049 | 3275 cln = mr->cleanup; |
3276 mr->cleanup = NULL; | |
3277 | |
3278 while (cln) { | |
3279 if (cln->handler) { | |
3280 cln->handler(cln->data); | |
3281 } | |
3282 | |
3283 cln = cln->next; | |
3284 } | |
3285 | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3286 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
|
3287 "http terminate cleanup count:%d blk:%d", |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3288 mr->count, mr->blocked); |
3049 | 3289 |
3290 if (mr->write_event_handler) { | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3291 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3292 if (mr->blocked) { |
7011
5e05118678af
Fixed background requests with asynchronous operations.
Roman Arutyunyan <arut@nginx.com>
parents:
7008
diff
changeset
|
3293 r->connection->error = 1; |
5e05118678af
Fixed background requests with asynchronous operations.
Roman Arutyunyan <arut@nginx.com>
parents:
7008
diff
changeset
|
3294 r->write_event_handler = ngx_http_request_finalizer; |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3295 return; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3296 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3297 |
3064 | 3298 e = ngx_http_ephemeral(mr); |
3051 | 3299 mr->posted_requests = NULL; |
3300 mr->write_event_handler = ngx_http_terminate_handler; | |
3064 | 3301 (void) ngx_http_post_request(mr, &e->terminal_posted_request); |
3049 | 3302 return; |
3303 } | |
3304 | |
3305 ngx_http_close_request(mr, rc); | |
3306 } | |
3307 | |
3308 | |
3309 static void | |
3310 ngx_http_terminate_handler(ngx_http_request_t *r) | |
3311 { | |
3312 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
|
3313 "http terminate handler count:%d", r->count); |
3049 | 3314 |
3315 r->count = 1; | |
3316 | |
3317 ngx_http_close_request(r, 0); | |
3318 } | |
3319 | |
3320 | |
3321 static void | |
3322 ngx_http_finalize_connection(ngx_http_request_t *r) | |
3323 { | |
3324 ngx_http_core_loc_conf_t *clcf; | |
3325 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3326 #if (NGX_HTTP_V2) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3327 if (r->stream) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3328 ngx_http_close_request(r, 0); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3329 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3330 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3331 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3332 |
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
|
3333 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
|
3334 |
3049 | 3335 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
|
3336 |
3214
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
3337 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
|
3338 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
|
3339 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
|
3340 |
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
3341 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
|
3342 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
|
3343 + (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
|
3344 } |
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
|
3345 } |
3ea03c1fe050
add lingering timeout if a response is short and a request body is being
Igor Sysoev <igor@sysoev.ru>
parents:
3180
diff
changeset
|
3346 |
3049 | 3347 ngx_http_close_request(r, 0); |
3348 return; | |
3349 } | |
3350 | |
7006
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3351 r = r->main; |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
3352 |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
3353 if (r->reading_body) { |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
3354 r->keepalive = 0; |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
3355 r->lingering_close = 1; |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
3356 } |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
3357 |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
3358 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
|
3359 && !ngx_exiting |
2019 | 3360 && r->keepalive |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
3361 && 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
|
3362 { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3363 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
|
3364 return; |
3984
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
3365 } |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
3366 |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
3367 if (clcf->lingering_close == NGX_HTTP_LINGERING_ALWAYS |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
3368 || (clcf->lingering_close == NGX_HTTP_LINGERING_ON |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
3369 && (r->lingering_close |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
3370 || r->header_in->pos < r->header_in->last |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
3371 || r->connection->read->ready))) |
3981
77604e9a1ed8
enable lingering close for pipelined requests
Igor Sysoev <igor@sysoev.ru>
parents:
3978
diff
changeset
|
3372 { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3373 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
|
3374 return; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3375 } |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3376 |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
3377 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
|
3378 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3379 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3380 |
525 | 3381 static ngx_int_t |
501 | 3382 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
|
3383 { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3384 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
|
3385 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
|
3386 |
509 | 3387 r->http_state = NGX_HTTP_WRITING_REQUEST_STATE; |
3388 | |
3215
4edf28522d24
allow discarding body while a long response transfer
Igor Sysoev <igor@sysoev.ru>
parents:
3214
diff
changeset
|
3389 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
|
3390 ngx_http_discarded_request_body_handler: |
4edf28522d24
allow discarding body while a long response transfer
Igor Sysoev <igor@sysoev.ru>
parents:
3214
diff
changeset
|
3391 ngx_http_test_reading; |
525 | 3392 r->write_event_handler = ngx_http_writer; |
3393 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3394 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
|
3395 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
3396 if (wev->ready && wev->delayed) { |
525 | 3397 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
|
3398 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3399 |
509 | 3400 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
|
3401 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
|
3402 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
|
3403 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3404 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3405 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
|
3406 ngx_http_close_request(r, 0); |
525 | 3407 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
|
3408 } |
525 | 3409 |
3410 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
|
3411 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3412 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3413 |
509 | 3414 static void |
3415 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
|
3416 { |
6964 | 3417 ngx_int_t rc; |
509 | 3418 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
|
3419 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
|
3420 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
|
3421 |
509 | 3422 c = r->connection; |
3423 wev = c->write; | |
3424 | |
583 | 3425 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
3426 "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
|
3427 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3428 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
|
3429 |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
3430 if (wev->timedout) { |
6961
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3431 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3432 "client timed out"); |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3433 c->timedout = 1; |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3434 |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3435 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT); |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3436 return; |
4195
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
3437 } |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
3438 |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
3439 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
|
3440 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
|
3441 "http writer delayed"); |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
3442 |
6961
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3443 if (!wev->delayed) { |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3444 ngx_add_timer(wev, clcf->send_timeout); |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3445 } |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
3446 |
4195
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
3447 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
|
3448 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
|
3449 } |
4195
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
3450 |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
3451 return; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
3452 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
3453 |
583 | 3454 rc = ngx_http_output_filter(r, NULL); |
3455 | |
3456 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
6964 | 3457 "http writer output filter: %i, \"%V?%V\"", |
583 | 3458 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
|
3459 |
2883
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
3460 if (rc == NGX_ERROR) { |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
3461 ngx_http_finalize_request(r, rc); |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
3462 return; |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
3463 } |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
3464 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3465 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
|
3466 |
4194
7ce8f2cde0af
Fix for connection drops with AIO.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4033
diff
changeset
|
3467 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
|
3468 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
|
3469 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3470 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3471 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { |
569 | 3472 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
|
3473 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3474 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3475 return; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3476 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3477 |
583 | 3478 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
3479 "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
|
3480 |
3216
79ae445ec57b
fix two previous commits: an early parallel body discarding completion
Igor Sysoev <igor@sysoev.ru>
parents:
3215
diff
changeset
|
3481 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
|
3482 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3483 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
|
3484 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3485 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3486 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3487 static void |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3488 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
|
3489 { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3490 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
|
3491 "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
|
3492 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3493 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
|
3494 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3495 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3496 |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3497 void |
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3498 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
|
3499 { |
1283
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3500 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
|
3501 "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
|
3502 |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3503 /* 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
|
3504 |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3505 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
|
3506 && 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
|
3507 { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3508 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
|
3509 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
|
3510 } |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3511 } |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3512 } |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3513 |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3514 |
2294 | 3515 void |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3516 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
|
3517 { |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3518 int n; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3519 char buf[1]; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3520 ngx_err_t err; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3521 ngx_event_t *rev; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3522 ngx_connection_t *c; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3523 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3524 c = r->connection; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3525 rev = c->read; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3526 |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3527 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
|
3528 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3529 #if (NGX_HTTP_V2) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3530 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3531 if (r->stream) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3532 if (c->error) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3533 err = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3534 goto closed; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3535 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3536 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3537 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3538 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3539 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3540 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3541 |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3542 #if (NGX_HAVE_KQUEUE) |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3543 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3544 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
|
3545 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3546 if (!rev->pending_eof) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3547 return; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3548 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3549 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3550 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3551 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3552 err = rev->kq_errno; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3553 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3554 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3555 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3556 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3557 #endif |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3558 |
5374
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3559 #if (NGX_HAVE_EPOLLRDHUP) |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3560 |
6536
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3561 if ((ngx_event_flags & NGX_USE_EPOLL_EVENT) && ngx_use_epoll_rdhup) { |
5374
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3562 socklen_t len; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3563 |
6536
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3564 if (!rev->pending_eof) { |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3565 return; |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3566 } |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3567 |
5374
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3568 rev->eof = 1; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3569 c->error = 1; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3570 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3571 err = 0; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3572 len = sizeof(ngx_err_t); |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3573 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3574 /* |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3575 * BSDs and Linux return 0 and set a pending error in err |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3576 * Solaris returns -1 and sets errno |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3577 */ |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3578 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3579 if (getsockopt(c->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len) |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3580 == -1) |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3581 { |
5557
188481078faf
Use ngx_socket_errno where appropriate.
Piotr Sikora <piotr@cloudflare.com>
parents:
5548
diff
changeset
|
3582 err = ngx_socket_errno; |
5374
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3583 } |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3584 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3585 goto closed; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3586 } |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3587 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3588 #endif |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3589 |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3590 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
|
3591 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3592 if (n == 0) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3593 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3594 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3595 err = 0; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3596 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3597 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3598 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3599 } else if (n == -1) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3600 err = ngx_socket_errno; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3601 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3602 if (err != NGX_EAGAIN) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3603 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3604 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3605 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3606 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3607 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3608 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3609 |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
3610 /* 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
|
3611 |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3612 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
|
3613 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3614 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
|
3615 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
|
3616 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
3617 } |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3618 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3619 return; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3620 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3621 closed: |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3622 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3623 if (err) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3624 rev->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3625 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3626 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3627 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
|
3628 "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
|
3629 |
5289
aadfadd5af2b
Fixed ngx_http_test_reading() to finalize request properly.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5210
diff
changeset
|
3630 ngx_http_finalize_request(r, NGX_HTTP_CLIENT_CLOSED_REQUEST); |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3631 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3632 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3633 |
501 | 3634 static void |
3635 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
|
3636 { |
452 | 3637 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
|
3638 ngx_buf_t *b, *f; |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3639 ngx_chain_t *cl, *ln; |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
3640 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
|
3641 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
|
3642 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
|
3643 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
|
3644 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3645 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
|
3646 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
|
3647 |
1373
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
3648 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
|
3649 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3650 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
|
3651 |
1373
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
3652 if (r->discard_body) { |
2489
d1a7203a8a44
avoid a double redirect response if
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
3653 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
|
3654 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
|
3655 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
|
3656 return; |
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
3657 } |
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
3658 |
483 | 3659 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
|
3660 |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
3661 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
|
3662 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
|
3663 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3664 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
|
3665 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3666 /* 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
|
3667 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3668 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
|
3669 |
455 | 3670 /* |
3671 * If the large header buffers were allocated while the previous | |
3672 * 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
|
3673 * the pipelined request (see ngx_http_create_request()). |
577 | 3674 * |
455 | 3675 * Now we would move the large header buffers to the free list. |
3676 */ | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3677 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3678 for (cl = hc->busy; cl; /* void */) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3679 ln = cl; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3680 cl = cl->next; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3681 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3682 if (ln->buf == b) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3683 ngx_free_chain(c->pool, ln); |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3684 continue; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3685 } |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3686 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3687 f = ln->buf; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3688 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
|
3689 f->last = f->start; |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3690 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3691 ln->next = hc->free; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3692 hc->free = ln; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3693 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3694 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3695 cl = ngx_alloc_chain_link(c->pool); |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3696 if (cl == NULL) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3697 ngx_http_close_request(r, 0); |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3698 return; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3699 } |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3700 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3701 cl->buf = b; |
6942
1c43ac026c1d
Fixed CPU hog while freeing hc->busy after e662cbf1b932 (1.11.11).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6926
diff
changeset
|
3702 cl->next = NULL; |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3703 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3704 hc->busy = cl; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3705 hc->nbusy = 1; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3706 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3707 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3708 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3709 /* 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
|
3710 r->keepalive = 0; |
0e420f3f8e18
clear r->keepalive to disable preventively calling
Igor Sysoev <igor@sysoev.ru>
parents:
3176
diff
changeset
|
3711 |
3049 | 3712 ngx_http_free_request(r, 0); |
569 | 3713 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
3714 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
|
3715 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3716 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
|
3717 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
|
3718 return; |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3719 } |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
3720 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
3721 wev = c->write; |
509 | 3722 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
|
3723 |
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
|
3724 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
|
3725 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3726 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
|
3727 |
483 | 3728 c->log->action = "reading client pipelined request line"; |
567 | 3729 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3730 r = ngx_http_create_request(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3731 if (r == NULL) { |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3732 ngx_http_close_connection(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3733 return; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3734 } |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3735 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3736 r->pipeline = 1; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3737 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3738 c->data = r; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3739 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3740 c->sent = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3741 c->destroyed = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3742 |
5102
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3743 if (rev->timer_set) { |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3744 ngx_del_timer(rev); |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3745 } |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3746 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3747 rev->handler = ngx_http_process_request_line; |
2014 | 3748 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
|
3749 return; |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
3750 } |
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
3751 |
455 | 3752 /* |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3753 * 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
|
3754 * 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
|
3755 * 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
|
3756 * c->pool and are freed too. |
455 | 3757 */ |
3758 | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3759 b = c->buffer; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3760 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3761 if (ngx_pfree(c->pool, b->start) == NGX_OK) { |
455 | 3762 |
3763 /* | |
3764 * the special note for ngx_http_keepalive_handler() that | |
3765 * c->buffer's memory was freed | |
3766 */ | |
3767 | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3768 b->pos = NULL; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3769 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3770 } else { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3771 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
|
3772 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
|
3773 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3774 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3775 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc free: %p", |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3776 hc->free); |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3777 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3778 if (hc->free) { |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3779 for (cl = hc->free; cl; /* void */) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3780 ln = cl; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3781 cl = cl->next; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3782 ngx_pfree(c->pool, ln->buf->start); |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3783 ngx_free_chain(c->pool, ln); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3784 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3785 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3786 hc->free = NULL; |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3787 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3788 |
6480 | 3789 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc busy: %p %i", |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3790 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
|
3791 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3792 if (hc->busy) { |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3793 for (cl = hc->busy; cl; /* void */) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3794 ln = cl; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3795 cl = cl->next; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3796 ngx_pfree(c->pool, ln->buf->start); |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3797 ngx_free_chain(c->pool, ln); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3798 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3799 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3800 hc->busy = NULL; |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3801 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
|
3802 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3803 |
1779
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
3804 #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
|
3805 if (c->ssl) { |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
3806 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
|
3807 } |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
3808 #endif |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
3809 |
509 | 3810 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
|
3811 |
583 | 3812 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
|
3813 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) != NGX_OK) { |
583 | 3814 ngx_http_close_connection(c); |
3815 return; | |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3816 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3817 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3818 |
483 | 3819 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
|
3820 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
3821 if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) { |
501 | 3822 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
|
3823 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
|
3824 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
|
3825 return; |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
3826 } |
452 | 3827 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
3828 c->tcp_nopush = NGX_TCP_NOPUSH_UNSET; |
473 | 3829 tcp_nodelay = ngx_tcp_nodelay_and_tcp_nopush ? 1 : 0; |
452 | 3830 |
3831 } else { | |
473 | 3832 tcp_nodelay = 1; |
3833 } | |
3834 | |
7007
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
7006
diff
changeset
|
3835 if (tcp_nodelay && clcf->tcp_nodelay && ngx_tcp_nodelay(c) != NGX_OK) { |
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
7006
diff
changeset
|
3836 ngx_http_close_connection(c); |
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
7006
diff
changeset
|
3837 return; |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
3838 } |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
3839 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3840 #if 0 |
455 | 3841 /* 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
|
3842 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
|
3843 #endif |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
3844 |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
3845 c->idle = 1; |
3880
e3cb8e27e413
reuse keepalive connections if there are no free worker connections
Igor Sysoev <igor@sysoev.ru>
parents:
3848
diff
changeset
|
3846 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
|
3847 |
5102
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3848 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
|
3849 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
3850 if (rev->ready) { |
2014 | 3851 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
|
3852 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3853 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3854 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3855 |
501 | 3856 static void |
3857 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
|
3858 { |
501 | 3859 size_t size; |
3860 ssize_t n; | |
3861 ngx_buf_t *b; | |
3862 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
|
3863 |
394
e7a68e14ccd3
nginx-0.0.7-2004-07-16-10:33:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
3864 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
|
3865 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3866 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
|
3867 |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
3868 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
|
3869 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
|
3870 return; |
68
d549fdc17d7e
nginx-0.0.1-2003-03-12-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
3871 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3872 |
469 | 3873 #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
|
3874 |
455 | 3875 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
587 | 3876 if (rev->pending_eof) { |
483 | 3877 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
|
3878 ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno, |
461 | 3879 "kevent() reported that client %V closed " |
483 | 3880 "keepalive connection", &c->addr_text); |
473 | 3881 #if (NGX_HTTP_SSL) |
3882 if (c->ssl) { | |
547 | 3883 c->ssl->no_send_shutdown = 1; |
473 | 3884 } |
3885 #endif | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3886 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
|
3887 return; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3888 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3889 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3890 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3891 #endif |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3892 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3893 b = c->buffer; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3894 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
|
3895 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3896 if (b->pos == NULL) { |
455 | 3897 |
3898 /* | |
3899 * The c->buffer's memory was freed by ngx_http_set_keepalive(). | |
3900 * However, the c->buffer->start and c->buffer->end were not changed | |
3901 * to keep the buffer size. | |
3902 */ | |
3903 | |
501 | 3904 b->pos = ngx_palloc(c->pool, size); |
3905 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
|
3906 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
|
3907 return; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3908 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3909 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3910 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
|
3911 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
|
3912 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
|
3913 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3914 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3915 /* |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3916 * 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
|
3917 * 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
|
3918 */ |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3919 |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
3920 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
|
3921 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
|
3922 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3923 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
|
3924 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
|
3925 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3926 if (n == NGX_AGAIN) { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3927 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
475 | 3928 ngx_http_close_connection(c); |
5082
42a888fdad0b
Fixed potential segfault in ngx_http_keepalive_handler().
Valentin Bartenev <vbart@nginx.com>
parents:
5072
diff
changeset
|
3929 return; |
475 | 3930 } |
3931 | |
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
|
3932 /* |
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
|
3933 * 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
|
3934 * 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
|
3935 */ |
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
|
3936 |
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
|
3937 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
|
3938 |
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
|
3939 /* |
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
|
3940 * 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
|
3941 */ |
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
|
3942 |
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
|
3943 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
|
3944 } |
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
|
3945 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3946 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3947 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3948 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3949 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
|
3950 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
|
3951 return; |
68
d549fdc17d7e
nginx-0.0.1-2003-03-12-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
3952 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3953 |
483 | 3954 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
|
3955 |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3956 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
|
3957 ngx_log_error(NGX_LOG_INFO, c->log, ngx_socket_errno, |
483 | 3958 "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
|
3959 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
|
3960 return; |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3961 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3962 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3963 b->last += n; |
483 | 3964 |
3965 c->log->handler = ngx_http_log_error; | |
3966 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
|
3967 |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
3968 c->idle = 0; |
3880
e3cb8e27e413
reuse keepalive connections if there are no free worker connections
Igor Sysoev <igor@sysoev.ru>
parents:
3848
diff
changeset
|
3969 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
|
3970 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3971 c->data = ngx_http_create_request(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3972 if (c->data == NULL) { |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3973 ngx_http_close_connection(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3974 return; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3975 } |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3976 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3977 c->sent = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3978 c->destroyed = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3979 |
5102
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3980 ngx_del_timer(rev); |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3981 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3982 rev->handler = ngx_http_process_request_line; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3983 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
|
3984 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3985 |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3986 |
501 | 3987 static void |
3988 ngx_http_set_lingering_close(ngx_http_request_t *r) | |
577 | 3989 { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3990 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
|
3991 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
|
3992 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
|
3993 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3994 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
|
3995 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3996 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
|
3997 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3998 rev = c->read; |
509 | 3999 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
|
4000 |
557 | 4001 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
|
4002 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
|
4003 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
4004 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
|
4005 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
|
4006 return; |
53
d1e42f1b8fd4
nginx-0.0.1-2003-01-27-00:08:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
52
diff
changeset
|
4007 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
4008 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
4009 wev = c->write; |
509 | 4010 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
|
4011 |
583 | 4012 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
|
4013 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) != NGX_OK) { |
583 | 4014 ngx_http_close_request(r, 0); |
4015 return; | |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
4016 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
4017 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
4018 |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
4019 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
|
4020 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
|
4021 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
|
4022 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
|
4023 return; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
4024 } |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
4025 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
4026 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
|
4027 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
|
4028 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
4029 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
4030 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
4031 |
501 | 4032 static void |
4033 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
|
4034 { |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
4035 ssize_t n; |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
4036 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
|
4037 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
|
4038 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
|
4039 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
|
4040 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
|
4041 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
4042 c = rev->data; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
4043 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
|
4044 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
4045 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
|
4046 "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
|
4047 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
4048 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
|
4049 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
|
4050 return; |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
4051 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
4052 |
5210
ea2ba6dbe361
Fixed lingering_time check.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5200
diff
changeset
|
4053 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
|
4054 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
|
4055 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
|
4056 return; |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
4057 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
4058 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
4059 do { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
4060 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
|
4061 |
6480 | 4062 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "lingering read: %z", n); |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
4063 |
7351
2b5528023f6b
Lingering close changed to handle NGX_AGAIN.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7318
diff
changeset
|
4064 if (n == NGX_AGAIN) { |
2b5528023f6b
Lingering close changed to handle NGX_AGAIN.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7318
diff
changeset
|
4065 break; |
2b5528023f6b
Lingering close changed to handle NGX_AGAIN.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7318
diff
changeset
|
4066 } |
2b5528023f6b
Lingering close changed to handle NGX_AGAIN.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7318
diff
changeset
|
4067 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
4068 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
|
4069 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
|
4070 return; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
4071 } |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
4072 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
4073 } 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
|
4074 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
4075 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
477 | 4076 ngx_http_close_request(r, 0); |
475 | 4077 return; |
4078 } | |
4079 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
4080 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
|
4081 |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
4082 timer *= 1000; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
4083 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
4084 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
|
4085 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
|
4086 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
4087 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
4088 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
|
4089 } |
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
4090 |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
4091 |
501 | 4092 void |
4093 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
|
4094 { |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
4095 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
|
4096 |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
4097 return; |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
4098 } |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
4099 |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
4100 |
509 | 4101 void |
4102 ngx_http_request_empty_handler(ngx_http_request_t *r) | |
4103 { | |
4104 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
583 | 4105 "http request empty handler"); |
509 | 4106 |
4107 return; | |
4108 } | |
4109 | |
4110 | |
501 | 4111 ngx_int_t |
581 | 4112 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
|
4113 { |
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
|
4114 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
|
4115 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
|
4116 |
501 | 4117 b = ngx_calloc_buf(r->pool); |
4118 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
|
4119 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
|
4120 } |
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
|
4121 |
581 | 4122 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
|
4123 |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
4124 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
|
4125 b->last_buf = 1; |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
4126 |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
4127 } else { |
2993
f592d466bbda
fix r2972, it caused "zero size buf" alert.
Igor Sysoev <igor@sysoev.ru>
parents:
2992
diff
changeset
|
4128 b->sync = 1; |
2971
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
4129 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
|
4130 } |
581 | 4131 } |
4132 | |
4133 if (flags & NGX_HTTP_FLUSH) { | |
4134 b->flush = 1; | |
4135 } | |
4136 | |
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
|
4137 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
|
4138 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
|
4139 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
4140 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
|
4141 } |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
4142 |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
4143 |
613 | 4144 static ngx_int_t |
4145 ngx_http_post_action(ngx_http_request_t *r) | |
4146 { | |
4147 ngx_http_core_loc_conf_t *clcf; | |
4148 | |
4149 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
4150 | |
4151 if (clcf->post_action.data == NULL) { | |
4152 return NGX_DECLINED; | |
4153 } | |
4154 | |
4472
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
4155 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
|
4156 return NGX_DECLINED; |
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
4157 } |
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
4158 |
623 | 4159 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
4160 "post action: \"%V\"", &clcf->post_action); | |
4161 | |
3145
9160a117a46a
fix request counter for post_action, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3076
diff
changeset
|
4162 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
|
4163 |
613 | 4164 r->http_version = NGX_HTTP_VERSION_9; |
4165 r->header_only = 1; | |
629 | 4166 r->post_action = 1; |
613 | 4167 |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
4168 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
|
4169 |
1894
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
4170 if (clcf->post_action.data[0] == '/') { |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
4171 ngx_http_internal_redirect(r, &clcf->post_action, NULL); |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
4172 |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
4173 } else { |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
4174 ngx_http_named_location(r, &clcf->post_action); |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
4175 } |
613 | 4176 |
4177 return NGX_OK; | |
4178 } | |
4179 | |
4180 | |
4181 static void | |
3049 | 4182 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
|
4183 { |
639 | 4184 ngx_connection_t *c; |
569 | 4185 |
3049 | 4186 r = r->main; |
569 | 4187 c = r->connection; |
639 | 4188 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
4189 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
|
4190 "http request count:%d blk:%d", r->count, r->blocked); |
3049 | 4191 |
4192 if (r->count == 0) { | |
4193 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "http request count is zero"); | |
4194 } | |
4195 | |
4196 r->count--; | |
4197 | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
4198 if (r->count || r->blocked) { |
3049 | 4199 return; |
4200 } | |
4201 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
4202 #if (NGX_HTTP_V2) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
4203 if (r->stream) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
4204 ngx_http_v2_close_stream(r->stream, rc); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
4205 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
4206 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
4207 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
4208 |
3049 | 4209 ngx_http_free_request(r, rc); |
569 | 4210 ngx_http_close_connection(c); |
4211 } | |
4212 | |
4213 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
4214 void |
3049 | 4215 ngx_http_free_request(ngx_http_request_t *r, ngx_int_t rc) |
569 | 4216 { |
2261 | 4217 ngx_log_t *log; |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
4218 ngx_pool_t *pool; |
2261 | 4219 struct linger linger; |
4220 ngx_http_cleanup_t *cln; | |
4221 ngx_http_log_ctx_t *ctx; | |
4222 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
|
4223 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
4224 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
|
4225 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
4226 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
|
4227 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
4228 if (r->pool == NULL) { |
531 | 4229 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
|
4230 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
4231 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
4232 |
5363
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
4233 cln = r->cleanup; |
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
4234 r->cleanup = NULL; |
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
4235 |
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
4236 while (cln) { |
639 | 4237 if (cln->handler) { |
4238 cln->handler(cln->data); | |
4239 } | |
5363
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
4240 |
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
4241 cln = cln->next; |
639 | 4242 } |
4243 | |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
4244 #if (NGX_STAT_STUB) |
567 | 4245 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
4246 if (r->stat_reading) { |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
4247 (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
|
4248 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
4249 |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
4250 if (r->stat_writing) { |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
4251 (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
|
4252 } |
567 | 4253 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
4254 #endif |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
4255 |
3049 | 4256 if (rc > 0 && (r->headers_out.status == 0 || r->connection->sent == 0)) { |
4257 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
|
4258 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
4259 |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
4260 if (!r->logged) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
4261 log->action = "logging request"; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
4262 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
4263 ngx_http_log_request(r); |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
4264 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
4265 |
2077 | 4266 log->action = "closing request"; |
4267 | |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
4268 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
|
4269 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
|
4270 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
4271 if (clcf->reset_timedout_connection) { |
509 | 4272 linger.l_onoff = 1; |
4273 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
|
4274 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
4275 if (setsockopt(r->connection->fd, SOL_SOCKET, SO_LINGER, |
509 | 4276 (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
|
4277 { |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
4278 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
|
4279 "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
|
4280 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
4281 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
4282 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
4283 |
509 | 4284 /* 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
|
4285 ctx = log->data; |
461 | 4286 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
|
4287 |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
4288 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
|
4289 |
583 | 4290 r->connection->destroyed = 1; |
4291 | |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
4292 /* |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
4293 * 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
|
4294 * 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
|
4295 */ |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
4296 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
4297 pool = r->pool; |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
4298 r->pool = NULL; |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
4299 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
4300 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
|
4301 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
4302 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
4303 |
531 | 4304 static void |
2261 | 4305 ngx_http_log_request(ngx_http_request_t *r) |
4306 { | |
4307 ngx_uint_t i, n; | |
4308 ngx_http_handler_pt *log_handler; | |
4309 ngx_http_core_main_conf_t *cmcf; | |
4310 | |
4311 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
4312 | |
4313 log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts; | |
4314 n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts; | |
4315 | |
4316 for (i = 0; i < n; i++) { | |
4317 log_handler[i](r); | |
4318 } | |
4319 } | |
4320 | |
4321 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
4322 void |
501 | 4323 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
|
4324 { |
479 | 4325 ngx_pool_t *pool; |
4326 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
4327 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
|
4328 "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
|
4329 |
539 | 4330 #if (NGX_HTTP_SSL) |
452 | 4331 |
4332 if (c->ssl) { | |
4333 if (ngx_ssl_shutdown(c) == NGX_AGAIN) { | |
577 | 4334 c->ssl->handler = ngx_http_close_connection; |
452 | 4335 return; |
4336 } | |
4337 } | |
4338 | |
4339 #endif | |
4340 | |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
4341 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
4342 (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
|
4343 #endif |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
4344 |
583 | 4345 c->destroyed = 1; |
4346 | |
479 | 4347 pool = c->pool; |
4348 | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
416
diff
changeset
|
4349 ngx_close_connection(c); |
479 | 4350 |
501 | 4351 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
|
4352 } |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
4353 |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
4354 |
501 | 4355 static u_char * |
4356 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
|
4357 { |
483 | 4358 u_char *p; |
505 | 4359 ngx_http_request_t *r; |
483 | 4360 ngx_http_log_ctx_t *ctx; |
461 | 4361 |
483 | 4362 if (log->action) { |
509 | 4363 p = ngx_snprintf(buf, len, " while %s", log->action); |
461 | 4364 len -= p - buf; |
505 | 4365 buf = p; |
461 | 4366 } |
4367 | |
509 | 4368 ctx = log->data; |
4369 | |
1810 | 4370 p = ngx_snprintf(buf, len, ", client: %V", &ctx->connection->addr_text); |
509 | 4371 len -= p - buf; |
505 | 4372 |
4373 r = ctx->request; | |
4374 | |
509 | 4375 if (r) { |
665 | 4376 return r->log_handler(r, ctx->current_request, p, len); |
1810 | 4377 |
4378 } else { | |
4379 p = ngx_snprintf(p, len, ", server: %V", | |
4380 &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
|
4381 } |
461 | 4382 |
509 | 4383 return p; |
4384 } | |
4385 | |
4386 | |
4387 static u_char * | |
665 | 4388 ngx_http_log_error_handler(ngx_http_request_t *r, ngx_http_request_t *sr, |
4389 u_char *buf, size_t len) | |
509 | 4390 { |
1811 | 4391 char *uri_separator; |
4392 u_char *p; | |
4393 ngx_http_upstream_t *u; | |
4394 ngx_http_core_srv_conf_t *cscf; | |
4395 | |
4396 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | |
4397 | |
4398 p = ngx_snprintf(buf, len, ", server: %V", &cscf->server_name); | |
4399 len -= p - buf; | |
4400 buf = p; | |
503 | 4401 |
1656
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
4402 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
|
4403 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
|
4404 if (*p == CR || *p == LF) { |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
4405 break; |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
4406 } |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
4407 } |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
4408 |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
4409 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
|
4410 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
|
4411 } |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
4412 |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
4413 if (r->request_line.len) { |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
4414 p = ngx_snprintf(buf, len, ", request: \"%V\"", &r->request_line); |
505 | 4415 len -= p - buf; |
4416 buf = p; | |
461 | 4417 } |
4418 | |
665 | 4419 if (r != sr) { |
4420 p = ngx_snprintf(buf, len, ", subrequest: \"%V\"", &sr->uri); | |
4421 len -= p - buf; | |
4422 buf = p; | |
4423 } | |
4424 | |
4425 u = sr->upstream; | |
4426 | |
884 | 4427 if (u && u->peer.name) { |
4428 | |
4429 uri_separator = ""; | |
4430 | |
4431 #if (NGX_HAVE_UNIX_DOMAIN) | |
4432 if (u->peer.sockaddr && u->peer.sockaddr->sa_family == AF_UNIX) { | |
4433 uri_separator = ":"; | |
4434 } | |
4435 #endif | |
665 | 4436 |
4437 p = ngx_snprintf(buf, len, ", upstream: \"%V%V%s%V\"", | |
1658 | 4438 &u->schema, u->peer.name, |
884 | 4439 uri_separator, &u->uri); |
665 | 4440 len -= p - buf; |
4441 buf = p; | |
4442 } | |
4443 | |
505 | 4444 if (r->headers_in.host) { |
4445 p = ngx_snprintf(buf, len, ", host: \"%V\"", | |
4446 &r->headers_in.host->value); | |
4447 len -= p - buf; | |
4448 buf = p; | |
4449 } | |
4450 | |
4451 if (r->headers_in.referer) { | |
4452 p = ngx_snprintf(buf, len, ", referrer: \"%V\"", | |
4453 &r->headers_in.referer->value); | |
4454 buf = p; | |
4455 } | |
4456 | |
4457 return buf; | |
4458 } |