Mercurial > hg > nginx-quic
annotate src/http/ngx_http_request.c @ 7794:e76be8639621 quic
Added basic offset support in client CRYPTO frames.
The offset in client CRYPTO frames is tracked in c->quic->crypto_offset_in.
This means that CRYPTO frames with non-zero offset are now accepted making
possible to finish handshake with client certificates that exceed max packet
size (if no reordering happens).
The c->quic->crypto_offset field is renamed to crypto_offset_out to avoid
confusion with tracking of incoming CRYPTO stream.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Tue, 07 Apr 2020 15:50:38 +0300 |
parents | 5649079a41f4 |
children | 5b7ec588de48 |
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); |
539 | 65 #endif |
66 | |
7681 | 67 #if (NGX_HTTP_V3) |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
68 static void ngx_http_quic_stream_handler(ngx_connection_t *c); |
7681 | 69 #endif |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
70 |
505 | 71 static char *ngx_http_client_errors[] = { |
72 | |
73 /* NGX_HTTP_PARSE_INVALID_METHOD */ | |
74 "client sent invalid method", | |
75 | |
76 /* NGX_HTTP_PARSE_INVALID_REQUEST */ | |
77 "client sent invalid request", | |
78 | |
6993
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
79 /* 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
|
80 "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
|
81 |
505 | 82 /* NGX_HTTP_PARSE_INVALID_09_METHOD */ |
83 "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
|
84 }; |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
85 |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
86 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
87 ngx_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
|
88 { 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
|
89 ngx_http_process_host }, |
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
90 |
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
91 { 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
|
92 ngx_http_process_connection }, |
509 | 93 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
94 { ngx_string("If-Modified-Since"), |
509 | 95 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
|
96 ngx_http_process_unique_header_line }, |
509 | 97 |
3814
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
98 { ngx_string("If-Unmodified-Since"), |
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
99 offsetof(ngx_http_headers_in_t, if_unmodified_since), |
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
100 ngx_http_process_unique_header_line }, |
e6e453203bae
"If-Unmodified-Since" support
Igor Sysoev <igor@sysoev.ru>
parents:
3674
diff
changeset
|
101 |
4744
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
102 { ngx_string("If-Match"), |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
103 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
|
104 ngx_http_process_unique_header_line }, |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
105 |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
106 { ngx_string("If-None-Match"), |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
107 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
|
108 ngx_http_process_unique_header_line }, |
5b93a9ac60ed
Entity tags: basic support in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4739
diff
changeset
|
109 |
2193
1d37b13ef004
fix $r->header_in() for "User-Agent", "Connection", and "Host"
Igor Sysoev <igor@sysoev.ru>
parents:
2137
diff
changeset
|
110 { 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
|
111 ngx_http_process_user_agent }, |
509 | 112 |
113 { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer), | |
114 ngx_http_process_header_line }, | |
115 | |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
116 { ngx_string("Content-Length"), |
509 | 117 offsetof(ngx_http_headers_in_t, content_length), |
523 | 118 ngx_http_process_unique_header_line }, |
509 | 119 |
6538
055cbb52ac1d
Dav: return 501 on PUT with ranges (ticket #948).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
120 { ngx_string("Content-Range"), |
055cbb52ac1d
Dav: return 501 on PUT with ranges (ticket #948).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6536
diff
changeset
|
121 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
|
122 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
|
123 |
479 | 124 { ngx_string("Content-Type"), |
509 | 125 offsetof(ngx_http_headers_in_t, content_type), |
126 ngx_http_process_header_line }, | |
127 | |
128 { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range), | |
129 ngx_http_process_header_line }, | |
130 | |
1630 | 131 { ngx_string("If-Range"), |
132 offsetof(ngx_http_headers_in_t, if_range), | |
133 ngx_http_process_unique_header_line }, | |
134 | |
581 | 135 { ngx_string("Transfer-Encoding"), |
136 offsetof(ngx_http_headers_in_t, transfer_encoding), | |
7625
aca005d232ff
Disabled multiple Transfer-Encoding headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7475
diff
changeset
|
137 ngx_http_process_unique_header_line }, |
581 | 138 |
7234
c693daca57f7
gRPC: special handling of the TE request header.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7206
diff
changeset
|
139 { ngx_string("TE"), |
c693daca57f7
gRPC: special handling of the TE request header.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7206
diff
changeset
|
140 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
|
141 ngx_http_process_header_line }, |
c693daca57f7
gRPC: special handling of the TE request header.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7206
diff
changeset
|
142 |
2067 | 143 { ngx_string("Expect"), |
144 offsetof(ngx_http_headers_in_t, expect), | |
145 ngx_http_process_unique_header_line }, | |
146 | |
5072
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
147 { ngx_string("Upgrade"), |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
148 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
|
149 ngx_http_process_header_line }, |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4930
diff
changeset
|
150 |
7206
33edea74bd58
Expose more headers with NGX_HTTP_HEADERS.
Ruslan Ermilov <ru@nginx.com>
parents:
7193
diff
changeset
|
151 #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
|
152 { ngx_string("Accept-Encoding"), |
509 | 153 offsetof(ngx_http_headers_in_t, accept_encoding), |
154 ngx_http_process_header_line }, | |
155 | |
156 { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via), | |
157 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
|
158 #endif |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
159 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
160 { ngx_string("Authorization"), |
509 | 161 offsetof(ngx_http_headers_in_t, authorization), |
523 | 162 ngx_http_process_unique_header_line }, |
509 | 163 |
164 { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive), | |
165 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
|
166 |
4697
09187f9b0950
Fixed compile-time conditionals used to detect if X-Forwarded-For support
Ruslan Ermilov <ru@nginx.com>
parents:
4675
diff
changeset
|
167 #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
|
168 { ngx_string("X-Forwarded-For"), |
509 | 169 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
|
170 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
|
171 #endif |
479 | 172 |
573 | 173 #if (NGX_HTTP_REALIP) |
174 { ngx_string("X-Real-IP"), | |
175 offsetof(ngx_http_headers_in_t, x_real_ip), | |
176 ngx_http_process_header_line }, | |
177 #endif | |
178 | |
489 | 179 #if (NGX_HTTP_HEADERS) |
509 | 180 { ngx_string("Accept"), offsetof(ngx_http_headers_in_t, accept), |
181 ngx_http_process_header_line }, | |
182 | |
489 | 183 { ngx_string("Accept-Language"), |
509 | 184 offsetof(ngx_http_headers_in_t, accept_language), |
185 ngx_http_process_header_line }, | |
489 | 186 #endif |
187 | |
637 | 188 #if (NGX_HTTP_DAV) |
189 { ngx_string("Depth"), offsetof(ngx_http_headers_in_t, depth), | |
190 ngx_http_process_header_line }, | |
191 | |
192 { ngx_string("Destination"), offsetof(ngx_http_headers_in_t, destination), | |
193 ngx_http_process_header_line }, | |
681 | 194 |
1059 | 195 { ngx_string("Overwrite"), offsetof(ngx_http_headers_in_t, overwrite), |
196 ngx_http_process_header_line }, | |
197 | |
681 | 198 { ngx_string("Date"), offsetof(ngx_http_headers_in_t, date), |
199 ngx_http_process_header_line }, | |
637 | 200 #endif |
201 | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
202 { 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
|
203 ngx_http_process_multi_header_lines }, |
509 | 204 |
205 { 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
|
206 }; |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
207 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
208 |
501 | 209 void |
210 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
|
211 { |
5085
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 #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
|
220 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
|
221 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
|
222 #endif |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
223 |
7681 | 224 #if (NGX_HTTP_V3) |
225 if (c->type == SOCK_DGRAM) { | |
226 hc = ngx_pcalloc(c->pool, sizeof(ngx_http_v3_connection_t)); | |
227 hc->quic = 1; | |
7738
7f0981be07c4
Fixed client certificate verification.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7737
diff
changeset
|
228 hc->ssl = 1; |
7681 | 229 |
230 } else | |
231 #endif | |
232 hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)); | |
233 | |
5085
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
234 if (hc == NULL) { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
235 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
|
236 return; |
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 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
239 c->data = hc; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
240 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
241 /* 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
|
242 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
243 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
|
244 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
245 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
|
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 * 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
|
249 * 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
|
250 * 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
|
251 */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
252 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
253 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
|
254 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
|
255 return; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
256 } |
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 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
|
259 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
260 #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
|
261 case AF_INET6: |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
262 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
|
263 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
264 addr6 = port->addrs; |
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 /* 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
|
267 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
268 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
|
269 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
|
270 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
271 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
272 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
273 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
274 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
|
275 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
276 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
277 #endif |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
278 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
279 default: /* AF_INET */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
280 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
|
281 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
282 addr = port->addrs; |
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 /* 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
|
285 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
286 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
|
287 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
|
288 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
289 } |
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 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
292 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
|
293 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
294 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
295 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
296 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
297 } else { |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
298 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
299 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
|
300 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
301 #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
|
302 case AF_INET6: |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
303 addr6 = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
304 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
|
305 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
306 #endif |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
307 |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
308 default: /* AF_INET */ |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
309 addr = port->addrs; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
310 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
|
311 break; |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
312 } |
7f1cbcc71327
The default server lookup is now done only once per connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5084
diff
changeset
|
313 } |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
314 |
5089
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
315 /* 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
|
316 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
|
317 |
501 | 318 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); |
319 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
|
320 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
|
321 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
322 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
323 |
1810 | 324 ctx->connection = c; |
461 | 325 ctx->request = NULL; |
665 | 326 ctx->current_request = NULL; |
483 | 327 |
328 c->log->connection = c->number; | |
329 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
|
330 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
|
331 c->log->action = "waiting for request"; |
483 | 332 |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
333 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
|
334 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
335 rev = c->read; |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
336 rev->handler = ngx_http_wait_request_handler; |
569 | 337 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
|
338 |
7632
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
339 if (c->shared) { |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
340 rev->ready = 1; |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
341 } |
7999d3fbb765
HTTP UDP layer, QUIC support autotest.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7628
diff
changeset
|
342 |
7681 | 343 #if (NGX_HTTP_V3) |
344 if (hc->quic) { | |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7699
diff
changeset
|
345 ngx_http_v3_srv_conf_t *v3cf; |
7681 | 346 ngx_http_ssl_srv_conf_t *sscf; |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
347 |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7699
diff
changeset
|
348 v3cf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_v3_module); |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
349 sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module); |
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
350 |
7737
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7713
diff
changeset
|
351 ngx_quic_run(c, &sscf->ssl, &v3cf->quic, ngx_http_quic_stream_handler); |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
352 return; |
7633
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7632
diff
changeset
|
353 } |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7632
diff
changeset
|
354 #endif |
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7632
diff
changeset
|
355 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
356 #if (NGX_HTTP_V2) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
357 if (hc->addr_conf->http2) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
358 rev->handler = ngx_http_v2_init; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
359 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
360 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
361 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
362 #if (NGX_HTTP_SSL) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
363 { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
364 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
|
365 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
366 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
|
367 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
368 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
|
369 hc->ssl = 1; |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
370 c->log->action = "SSL handshaking"; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
371 rev->handler = ngx_http_ssl_handshake; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
372 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
373 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
374 #endif |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
375 |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
376 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
|
377 hc->proxy_protocol = 1; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
378 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
|
379 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
380 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
381 if (rev->ready) { |
6126
adba26ff70b5
Removed the obsolete rtsig module.
Ruslan Ermilov <ru@nginx.com>
parents:
6125
diff
changeset
|
382 /* 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
|
383 |
611 | 384 if (ngx_use_accept_mutex) { |
563 | 385 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
|
386 return; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
387 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
388 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
389 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
|
390 return; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
55
diff
changeset
|
391 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
392 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
393 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
|
394 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
|
395 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
396 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
|
397 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
|
398 return; |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
399 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
400 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
401 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
402 |
7681 | 403 #if (NGX_HTTP_V3) |
404 | |
641 | 405 static void |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
406 ngx_http_quic_stream_handler(ngx_connection_t *c) |
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
407 { |
7681 | 408 ngx_event_t *rev; |
409 ngx_connection_t *pc; | |
410 ngx_http_log_ctx_t *ctx; | |
411 ngx_http_connection_t *hc; | |
412 ngx_http_v3_connection_t *h3c; | |
413 | |
414 pc = c->qs->parent; | |
415 h3c = pc->data; | |
416 | |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7742
diff
changeset
|
417 if (c->qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
7681 | 418 ngx_http_v3_handle_client_uni_stream(c); |
419 return; | |
420 } | |
421 | |
422 hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)); | |
423 if (hc == NULL) { | |
424 ngx_http_close_connection(c); | |
425 return; | |
426 } | |
427 | |
428 ngx_memcpy(hc, h3c, sizeof(ngx_http_connection_t)); | |
429 c->data = hc; | |
430 | |
431 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); | |
432 if (ctx == NULL) { | |
433 ngx_http_close_connection(c); | |
434 return; | |
435 } | |
436 | |
437 ctx->connection = c; | |
438 ctx->request = NULL; | |
439 ctx->current_request = NULL; | |
440 | |
441 c->log->connection = c->number; | |
442 c->log->handler = ngx_http_log_error; | |
443 c->log->data = ctx; | |
444 c->log->action = "waiting for request"; | |
445 | |
446 c->log_error = NGX_ERROR_INFO; | |
7677
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7676
diff
changeset
|
447 |
7676 | 448 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
7681 | 449 "http3 new stream id:0x%uXL", c->qs->id); |
450 | |
451 rev = c->read; | |
452 rev->handler = ngx_http_wait_request_handler; | |
453 c->write->handler = ngx_http_empty_handler; | |
454 | |
455 rev->handler(rev); | |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
456 } |
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
457 |
7681 | 458 #endif |
459 | |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
460 |
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7648
diff
changeset
|
461 static void |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
462 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
|
463 { |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
464 u_char *p; |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
465 size_t size; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
466 ssize_t n; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
467 ngx_buf_t *b; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
468 ngx_connection_t *c; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
469 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
|
470 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
|
471 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
472 c = rev->data; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
473 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
474 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
|
475 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
476 if (rev->timedout) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
477 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
|
478 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
|
479 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
480 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
481 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
482 if (c->close) { |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
483 ngx_http_close_connection(c); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
484 return; |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
485 } |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
486 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
487 hc = c->data; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
488 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
|
489 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
490 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
|
491 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
492 b = c->buffer; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
493 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
494 if (b == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
495 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
|
496 if (b == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
497 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
|
498 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
499 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
500 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
501 c->buffer = b; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
502 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
503 } 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
|
504 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
505 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
|
506 if (b->start == NULL) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
507 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
|
508 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
509 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
510 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
511 b->pos = b->start; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
512 b->last = b->start; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
513 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
|
514 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
515 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
516 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
|
517 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
518 if (n == NGX_AGAIN) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
519 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
520 if (!rev->timer_set) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
521 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
|
522 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
|
523 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
524 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
525 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
|
526 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
|
527 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
528 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
529 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
530 /* |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
531 * 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
|
532 */ |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
533 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
534 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
|
535 b->start = NULL; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
536 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
537 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
538 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
539 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
540 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
541 if (n == NGX_ERROR) { |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
542 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
|
543 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
544 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
545 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
546 if (n == 0) { |
5109
44bd04fbbb4f
Fixed logging in ngx_http_wait_request_handler().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5105
diff
changeset
|
547 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
|
548 "client closed connection"); |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
549 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
|
550 return; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
551 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
552 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
553 b->last += n; |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
554 |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
555 if (hc->proxy_protocol) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
556 hc->proxy_protocol = 0; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
557 |
6185
a420cb1c170b
Core: renamed ngx_proxy_protocol_parse to ngx_proxy_protocol_read.
Roman Arutyunyan <arut@nginx.com>
parents:
6129
diff
changeset
|
558 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
|
559 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
560 if (p == NULL) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
561 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
|
562 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
563 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
564 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
565 b->pos = p; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
566 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
567 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
|
568 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
|
569 b->pos = b->start; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
570 b->last = b->start; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
571 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
|
572 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
573 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
574 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
575 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
576 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
|
577 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
578 ngx_reusable_connection(c, 0); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
579 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
580 c->data = ngx_http_create_request(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
581 if (c->data == NULL) { |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
582 ngx_http_close_connection(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
583 return; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
584 } |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
585 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
586 rev->handler = ngx_http_process_request_line; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
587 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
|
588 } |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
589 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
590 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
591 ngx_http_request_t * |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
592 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
|
593 { |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
594 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
|
595 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
|
596 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
|
597 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
598 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
|
599 if (r == NULL) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
600 return NULL; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
601 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
602 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
603 c->requests++; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
604 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
605 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
|
606 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
607 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
|
608 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
609 ctx = c->log->data; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
610 ctx->request = r; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
611 ctx->current_request = r; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
612 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
613 #if (NGX_STAT_STUB) |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
614 (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
|
615 r->stat_reading = 1; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
616 (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
|
617 #endif |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
618 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
619 return r; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
620 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
621 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
622 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
623 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
|
624 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
|
625 { |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
626 ngx_pool_t *pool; |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
627 ngx_time_t *tp; |
573 | 628 ngx_http_request_t *r; |
629 ngx_http_connection_t *hc; | |
630 ngx_http_core_srv_conf_t *cscf; | |
631 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
|
632 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
633 hc = c->data; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
634 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
635 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
|
636 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
637 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
|
638 if (pool == NULL) { |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
639 return NULL; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
640 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
641 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
642 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
|
643 if (r == NULL) { |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
644 ngx_destroy_pool(pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
645 return NULL; |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
646 } |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
647 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
648 r->pool = pool; |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
649 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
650 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
|
651 r->signature = NGX_HTTP_MODULE; |
1805 | 652 r->connection = c; |
653 | |
5089
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
654 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
|
655 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
|
656 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
|
657 |
3000
66ef86affbb8
fix segfault if 400 or 414 errors are handled intricately
Igor Sysoev <igor@sysoev.ru>
parents:
2994
diff
changeset
|
658 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
|
659 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
660 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
|
661 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
662 if (ngx_list_init(&r->headers_out.headers, r->pool, 20, |
581 | 663 sizeof(ngx_table_elt_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2534
diff
changeset
|
664 != NGX_OK) |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
665 { |
2902
a1a1c7e3fb8d
fix "out of memory" case handling
Igor Sysoev <igor@sysoev.ru>
parents:
2888
diff
changeset
|
666 ngx_destroy_pool(r->pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
667 return NULL; |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
668 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
669 |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
670 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
|
671 sizeof(ngx_table_elt_t)) |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
672 != NGX_OK) |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
673 { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
674 ngx_destroy_pool(r->pool); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
675 return NULL; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
676 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
7011
diff
changeset
|
677 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
678 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
|
679 if (r->ctx == NULL) { |
2902
a1a1c7e3fb8d
fix "out of memory" case handling
Igor Sysoev <igor@sysoev.ru>
parents:
2888
diff
changeset
|
680 ngx_destroy_pool(r->pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
681 return NULL; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
682 } |
10
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
683 |
573 | 684 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
685 | |
686 r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts | |
687 * sizeof(ngx_http_variable_value_t)); | |
688 if (r->variables == NULL) { | |
2902
a1a1c7e3fb8d
fix "out of memory" case handling
Igor Sysoev <igor@sysoev.ru>
parents:
2888
diff
changeset
|
689 ngx_destroy_pool(r->pool); |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
690 return NULL; |
573 | 691 } |
692 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
693 #if (NGX_HTTP_SSL) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
694 if (c->ssl) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
695 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
|
696 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
697 #endif |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
698 |
553 | 699 r->main = r; |
3049 | 700 r->count = 1; |
553 | 701 |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
702 tp = ngx_timeofday(); |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
703 r->start_sec = tp->sec; |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
704 r->start_msec = tp->msec; |
497 | 705 |
631 | 706 r->method = NGX_HTTP_UNKNOWN; |
5354
62be77b0608f
Assume the HTTP/1.0 version by default.
Valentin Bartenev <vbart@nginx.com>
parents:
5289
diff
changeset
|
707 r->http_version = NGX_HTTP_VERSION_10; |
631 | 708 |
7681 | 709 #if (NGX_HTTP_V3) |
710 if (hc->quic) { | |
711 r->http_version = NGX_HTTP_VERSION_30; | |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
712 r->headers_in.chunked = 1; |
7681 | 713 } |
714 #endif | |
715 | |
82
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
716 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
|
717 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
|
718 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
|
719 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
|
720 |
675 | 721 r->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1; |
722 r->subrequests = NGX_HTTP_MAX_SUBREQUESTS + 1; | |
723 | |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
724 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
|
725 |
509 | 726 r->log_handler = ngx_http_log_error_handler; |
505 | 727 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
728 return r; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
729 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
730 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
731 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
732 #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
|
733 |
7633
5d91389e0fd3
Initial QUIC support in http.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7632
diff
changeset
|
734 static void |
501 | 735 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
|
736 { |
7008
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
737 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
|
738 size_t size; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
739 ssize_t n; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
740 ngx_err_t err; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
741 ngx_int_t rc; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
742 ngx_connection_t *c; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
743 ngx_http_connection_t *hc; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
744 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
|
745 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
|
746 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
747 c = rev->data; |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
748 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
|
749 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
750 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
|
751 "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
|
752 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
753 if (rev->timedout) { |
505 | 754 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
|
755 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
|
756 return; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
757 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
758 |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
759 if (c->close) { |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
760 ngx_http_close_connection(c); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
761 return; |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
762 } |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
763 |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
764 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
|
765 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
766 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
|
767 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
768 err = ngx_socket_errno; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
769 |
6480 | 770 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
|
771 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
772 if (n == -1) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
773 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
|
774 rev->ready = 0; |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
775 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
776 if (!rev->timer_set) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
777 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
|
778 ngx_reusable_connection(c, 1); |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
779 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
780 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
781 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
|
782 ngx_http_close_connection(c); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
783 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
784 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
785 return; |
1855 | 786 } |
787 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
788 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
|
789 ngx_http_close_connection(c); |
1858 | 790 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
791 return; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
792 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
793 |
5605
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
794 if (hc->proxy_protocol) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
795 hc->proxy_protocol = 0; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
796 |
6185
a420cb1c170b
Core: renamed ngx_proxy_protocol_parse to ngx_proxy_protocol_read.
Roman Arutyunyan <arut@nginx.com>
parents:
6129
diff
changeset
|
797 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
|
798 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
799 if (p == NULL) { |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
800 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
|
801 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
802 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
803 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
804 size = p - buf; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
805 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
806 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
|
807 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
|
808 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
809 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
810 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
811 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
|
812 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
813 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
|
814 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
|
815 return; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
816 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
817 |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
818 n = 1; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
819 buf[0] = *p; |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
820 } |
3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Roman Arutyunyan <arut@nginx.com>
parents:
5557
diff
changeset
|
821 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
822 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
|
823 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
|
824 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
461 | 825 "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
|
826 |
7008
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
827 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
|
828 ngx_http_core_module); |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
829 |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
830 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
|
831 ngx_http_close_connection(c); |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
832 return; |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
833 } |
29c6d66b83ba
SSL: set TCP_NODELAY on SSL connections before handshake.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
834 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
835 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
|
836 ngx_http_ssl_module); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
837 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
838 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
|
839 != NGX_OK) |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
840 { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
841 ngx_http_close_connection(c); |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
842 return; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
843 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
844 |
7628
2e3bfd696ecb
Disabled connection reuse while in SSL handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7627
diff
changeset
|
845 ngx_reusable_connection(c, 0); |
2e3bfd696ecb
Disabled connection reuse while in SSL handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7627
diff
changeset
|
846 |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
847 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
|
848 |
547 | 849 if (rc == NGX_AGAIN) { |
1829
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
850 |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
851 if (!rev->timer_set) { |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
852 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
|
853 } |
81831a2bc67a
fix socket leak if deferred accept was used
Igor Sysoev <igor@sysoev.ru>
parents:
1812
diff
changeset
|
854 |
547 | 855 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
|
856 return; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
857 } |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
858 |
547 | 859 ngx_http_ssl_handshake_handler(c); |
860 | |
861 return; | |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
862 } |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
863 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
864 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
|
865 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
866 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
|
867 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
868 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
|
869 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
|
870 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
871 return; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
872 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
873 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
874 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
|
875 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
|
876 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
877 |
547 | 878 |
879 static void | |
880 ngx_http_ssl_handshake_handler(ngx_connection_t *c) | |
881 { | |
882 if (c->ssl->handshaked) { | |
883 | |
884 /* | |
885 * The majority of browsers do not send the "close notify" alert. | |
886 * Among them are MSIE, old Mozilla, Netscape 4, Konqueror, | |
887 * and Links. And what is more, MSIE ignores the server's alert. | |
888 * | |
889 * Opera and recent Mozilla send the alert. | |
890 */ | |
891 | |
892 c->ssl->no_wait_shutdown = 1; | |
893 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
894 #if (NGX_HTTP_V2 \ |
5545
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
895 && (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
|
896 || defined TLSEXT_TYPE_next_proto_neg)) |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
897 { |
6289
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
898 unsigned int len; |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
899 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
|
900 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
|
901 |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
902 hc = c->data; |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
903 |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
904 if (hc->addr_conf->http2) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
905 |
5545
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
906 #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
|
907 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
|
908 |
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
909 #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
|
910 if (len == 0) { |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
911 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
|
912 } |
5545
01e2a5bcdd8f
SSL: support ALPN (IETF's successor to NPN).
Piotr Sikora <piotr@cloudflare.com>
parents:
5541
diff
changeset
|
913 #endif |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
914 |
5547
2e40188f83ef
Fixed a compile warning introduced by 01e2a5bcdd8f.
Ruslan Ermilov <ru@nginx.com>
parents:
5545
diff
changeset
|
915 #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
|
916 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
|
917 #endif |
2e40188f83ef
Fixed a compile warning introduced by 01e2a5bcdd8f.
Ruslan Ermilov <ru@nginx.com>
parents:
5545
diff
changeset
|
918 |
6289
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
919 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
|
920 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
|
921 return; |
909b5b191f25
SSL: only select HTTP/2 using NPN if "http2" is enabled.
Valentin Bartenev <vbart@nginx.com>
parents:
6246
diff
changeset
|
922 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
923 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
924 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
925 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
926 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
927 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
|
928 |
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
929 c->read->handler = ngx_http_wait_request_handler; |
547 | 930 /* STUB: epoll edge */ c->write->handler = ngx_http_empty_handler; |
931 | |
5114
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
932 ngx_reusable_connection(c, 1); |
a46c1cfe7263
Allow to reuse connections that wait their first request.
Valentin Bartenev <vbart@nginx.com>
parents:
5109
diff
changeset
|
933 |
5101
d346adac0462
Create request object only after the first byte was received.
Valentin Bartenev <vbart@nginx.com>
parents:
5096
diff
changeset
|
934 ngx_http_wait_request_handler(c->read); |
547 | 935 |
936 return; | |
937 } | |
938 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
939 if (c->read->timedout) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
940 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
|
941 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
942 |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
943 ngx_http_close_connection(c); |
547 | 944 } |
945 | |
7458 | 946 |
1219 | 947 #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME |
948 | |
949 int | |
950 ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg) | |
951 { | |
7472
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
952 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
|
953 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
|
954 const char *servername; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
955 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
|
956 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
|
957 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
|
958 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
|
959 ngx_http_core_srv_conf_t *cscf; |
1219 | 960 |
961 c = ngx_ssl_get_connection(ssl_conn); | |
962 | |
7367
bf1ac3dc1e68
SSL: fixed segfault on renegotiation (ticket #1646).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7354
diff
changeset
|
963 if (c->ssl->handshaked) { |
7472
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
964 *ad = SSL_AD_NO_RENEGOTIATION; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
965 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
|
966 } |
a6902a941279
SSL: fixed possible segfault on renegotiation (ticket #845).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6306
diff
changeset
|
967 |
7475
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
968 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
|
969 |
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
970 if (servername == NULL) { |
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
971 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
|
972 } |
49f9d2f7d887
SSL: moved c->ssl->handshaked check in server name callback.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7472
diff
changeset
|
973 |
1219 | 974 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
975 "SSL server name: \"%s\"", servername); | |
976 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
977 host.len = ngx_strlen(servername); |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
978 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
979 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
|
980 return SSL_TLSEXT_ERR_OK; |
2195 | 981 } |
982 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
983 host.data = (u_char *) servername; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
984 |
7472
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
985 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
|
986 |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
987 if (rc == NGX_ERROR) { |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
988 *ad = SSL_AD_INTERNAL_ERROR; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
989 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
|
990 } |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
991 |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
992 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
|
993 return SSL_TLSEXT_ERR_OK; |
3152 | 994 } |
995 | |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
996 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
|
997 |
7472
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
998 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
|
999 NULL, &cscf); |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1000 |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1001 if (rc == NGX_ERROR) { |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1002 *ad = SSL_AD_INTERNAL_ERROR; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1003 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
|
1004 } |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1005 |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1006 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
|
1007 return SSL_TLSEXT_ERR_OK; |
1219 | 1008 } |
1009 | |
5093
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1010 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
|
1011 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
|
1012 *ad = SSL_AD_INTERNAL_ERROR; |
d430babbe643
SSL: server name callback changed to return fatal errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7471
diff
changeset
|
1013 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
|
1014 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1015 |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
1016 *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
|
1017 |
5089
903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5088
diff
changeset
|
1018 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
|
1019 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1020 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
|
1021 |
6129
187aa751ad62
Core: the ngx_set_connection_log() macro.
Vladimir Homutov <vl@nginx.com>
parents:
6126
diff
changeset
|
1022 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
|
1023 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
1024 sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module); |
1219 | 1025 |
6901
72bb626484a4
SSL: fixed ssl_buffer_size on SNI virtual hosts (ticket #1192).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6584
diff
changeset
|
1026 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
|
1027 |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1028 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
|
1029 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
|
1030 |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1031 /* |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1032 * 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
|
1033 * 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
|
1034 */ |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1035 |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1036 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
|
1037 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
|
1038 |
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1039 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
|
1040 |
7318
3443fe40bdc7
SSL: fixed SSL_clear_options() usage with OpenSSL 1.1.0+.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7313
diff
changeset
|
1041 #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
|
1042 /* 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
|
1043 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
|
1044 ~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
|
1045 #endif |
4e1a489c26cd
Better handling of various per-server ssl options with SNI.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3985
diff
changeset
|
1046 |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1047 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
|
1048 |
bf1ac3dc1e68
SSL: fixed segfault on renegotiation (ticket #1646).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7354
diff
changeset
|
1049 #ifdef SSL_OP_NO_RENEGOTIATION |
bf1ac3dc1e68
SSL: fixed segfault on renegotiation (ticket #1646).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7354
diff
changeset
|
1050 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
|
1051 #endif |
4304
ed922fb9d6c1
Fixed segfault on ssl servers without cert with SNI (ticket #54).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4195
diff
changeset
|
1052 } |
4033
4e1a489c26cd
Better handling of various per-server ssl options with SNI.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3985
diff
changeset
|
1053 |
1219 | 1054 return SSL_TLSEXT_ERR_OK; |
1055 } | |
1056 | |
1057 #endif | |
547 | 1058 |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1059 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1060 #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
|
1061 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1062 int |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1063 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
|
1064 { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1065 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
|
1066 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
|
1067 ngx_connection_t *c; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1068 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
|
1069 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
|
1070 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
|
1071 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1072 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
|
1073 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1074 if (c->ssl->handshaked) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1075 return 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1076 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1077 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1078 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
|
1079 if (r == NULL) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1080 return 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1081 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1082 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1083 r->logged = 1; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1084 |
7466
48c87377aabd
SSL: fixed possible segfault with dynamic certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7463
diff
changeset
|
1085 sscf = arg; |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1086 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1087 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
|
1088 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
|
1089 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
|
1090 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1091 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
|
1092 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1093 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
|
1094 goto failed; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1095 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1096 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1097 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
|
1098 "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
|
1099 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1100 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
|
1101 goto failed; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1102 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1103 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1104 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
|
1105 "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
|
1106 |
7463
180df83473a4
SSL: passwords support for dynamic certificate loading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7462
diff
changeset
|
1107 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
|
1108 sscf->passwords) |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1109 != NGX_OK) |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1110 { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1111 goto failed; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1112 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1113 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1114 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1115 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
|
1116 c->destroyed = 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1117 return 1; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1118 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1119 failed: |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1120 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1121 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
|
1122 c->destroyed = 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1123 return 0; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1124 } |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1125 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1126 #endif |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
1127 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1128 #endif |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1129 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
1130 |
501 | 1131 static void |
1132 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
|
1133 { |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1134 ssize_t n; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1135 ngx_int_t rc, rv; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1136 ngx_str_t host; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1137 ngx_connection_t *c; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1138 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
|
1139 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1140 c = rev->data; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1141 r = c->data; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1142 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1143 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
|
1144 "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
|
1145 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
1146 if (rev->timedout) { |
505 | 1147 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
1148 c->timedout = 1; | |
1149 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
|
1150 return; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
1151 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1152 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1153 rc = NGX_AGAIN; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1154 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1155 for ( ;; ) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1156 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1157 if (rc == NGX_AGAIN) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1158 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
|
1159 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1160 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
|
1161 break; |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1162 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1163 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1164 |
7681 | 1165 switch (r->http_version) { |
1166 #if (NGX_HTTP_V3) | |
1167 case NGX_HTTP_VERSION_30: | |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1168 rc = ngx_http_v3_parse_header(r, r->header_in); |
7681 | 1169 break; |
1170 #endif | |
1171 | |
1172 default: /* HTTP/1.x */ | |
1173 rc = ngx_http_parse_request_line(r, r->header_in); | |
1174 } | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1175 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1176 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
|
1177 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1178 /* 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
|
1179 |
461 | 1180 r->request_line.len = r->request_end - r->request_start; |
1181 r->request_line.data = r->request_start; | |
7699
1e45c02f6376
HTTP/3 $request_line variable.
Roman Arutyunyan <arut@nginx.com>
parents:
7692
diff
changeset
|
1182 r->request_length = r->header_in->pos - r->request_start; /* XXX */ |
461 | 1183 |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1184 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
|
1185 "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
|
1186 |
7681 | 1187 r->method_name.len = r->method_end - r->method_start; |
1188 r->method_name.data = r->method_start; | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1189 |
479 | 1190 if (r->http_protocol.data) { |
1191 r->http_protocol.len = r->request_end - r->http_protocol.data; | |
1192 } | |
1193 | |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1194 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
|
1195 break; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1196 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1197 |
7295 | 1198 if (r->schema_end) { |
1199 r->schema.len = r->schema_end - r->schema_start; | |
1200 r->schema.data = r->schema_start; | |
1201 } | |
1202 | |
7294
21ad2af3262c
Removed extraneous check while processing request line.
Ruslan Ermilov <ru@nginx.com>
parents:
7269
diff
changeset
|
1203 if (r->host_end) { |
3152 | 1204 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1205 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
|
1206 host.data = r->host_start; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1207 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1208 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
|
1209 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1210 if (rc == NGX_DECLINED) { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1211 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
|
1212 "client sent invalid host in request line"); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1213 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
|
1214 break; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1215 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1216 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1217 if (rc == NGX_ERROR) { |
3152 | 1218 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
|
1219 break; |
3152 | 1220 } |
1221 | |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1222 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
|
1223 break; |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1224 } |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1225 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1226 r->headers_in.server = host; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1227 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1228 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1229 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
|
1230 |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1231 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
|
1232 && 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
|
1233 == NGX_ERROR) |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1234 { |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1235 break; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1236 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1237 |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1238 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
|
1239 break; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1240 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1241 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1242 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1243 if (ngx_list_init(&r->headers_in.headers, r->pool, 20, |
581 | 1244 sizeof(ngx_table_elt_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2534
diff
changeset
|
1245 != NGX_OK) |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1246 { |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1247 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
|
1248 break; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1249 } |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
1250 |
483 | 1251 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
|
1252 |
509 | 1253 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
|
1254 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
|
1255 |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1256 break; |
505 | 1257 } |
1258 | |
7681 | 1259 if (rc == NGX_DONE) { |
1260 if (ngx_handle_read_event(rev, 0) != NGX_OK) { | |
1261 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
1262 return; | |
1263 } | |
1264 | |
1265 break; | |
1266 } | |
1267 | |
505 | 1268 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
|
1269 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1270 /* 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
|
1271 |
505 | 1272 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
1273 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
|
1274 |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1275 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
|
1276 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
|
1277 |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1278 } else { |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1279 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
|
1280 } |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6964
diff
changeset
|
1281 |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1282 break; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
1283 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
1284 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1285 /* 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
|
1286 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1287 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
|
1288 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1289 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
|
1290 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1291 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
|
1292 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
|
1293 break; |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
1294 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1295 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1296 if (rv == NGX_DECLINED) { |
505 | 1297 r->request_line.len = r->header_in->end - r->request_start; |
1298 r->request_line.data = r->request_start; | |
1299 | |
1300 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
1301 "client sent too long URI"); | |
1302 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
|
1303 break; |
66
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
1304 } |
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
1305 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
1306 } |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1307 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1308 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
|
1309 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1310 |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
1311 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
1312 ngx_int_t |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1313 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
|
1314 { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1315 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
|
1316 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1317 if (r->args_start) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1318 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
|
1319 } else { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1320 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
|
1321 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1322 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1323 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
|
1324 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1325 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
|
1326 if (r->uri.data == NULL) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1327 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
|
1328 return NGX_ERROR; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1329 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1330 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1331 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
|
1332 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1333 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
|
1334 r->uri.len = 0; |
e0aa54a4357e
Reset of r->uri.len on URI parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5605
diff
changeset
|
1335 |
5119
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1336 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
|
1337 "client sent invalid request"); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1338 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
|
1339 return NGX_ERROR; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1340 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1341 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1342 } else { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1343 r->uri.data = r->uri_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1344 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1345 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1346 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
|
1347 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
|
1348 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1349 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
|
1350 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1351 if (r->uri_ext) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1352 if (r->args_start) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1353 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
|
1354 } else { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1355 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
|
1356 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1357 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1358 r->exten.data = r->uri_ext; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1359 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1360 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1361 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
|
1362 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
|
1363 r->args.data = r->args_start; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1364 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1365 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1366 #if (NGX_WIN32) |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1367 { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1368 u_char *p, *last; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1369 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1370 p = r->uri.data; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1371 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
|
1372 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1373 while (p < last) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1374 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1375 if (*p++ == ':') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1376 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1377 /* |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1378 * 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
|
1379 * ":$i30:$index_allocation" |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1380 */ |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1381 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1382 if (p < last && *p == '$') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1383 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
|
1384 "client sent unsafe win32 URI"); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1385 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
|
1386 return NGX_ERROR; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1387 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1388 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1389 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1390 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1391 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
|
1392 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1393 while (p > r->uri.data) { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1394 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1395 if (*p == ' ') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1396 p--; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1397 continue; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1398 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1399 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1400 if (*p == '.') { |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1401 p--; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1402 continue; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1403 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1404 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1405 break; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1406 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1407 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1408 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
|
1409 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
|
1410 ngx_http_set_exten(r); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1411 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1412 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1413 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1414 #endif |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1415 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1416 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
|
1417 "http uri: \"%V\"", &r->uri); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1418 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1419 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
|
1420 "http args: \"%V\"", &r->args); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1421 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1422 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
|
1423 "http exten: \"%V\"", &r->exten); |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1424 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1425 return NGX_OK; |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1426 } |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1427 |
f10108c92fef
URI processing code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5114
diff
changeset
|
1428 |
501 | 1429 static void |
1430 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
|
1431 { |
3076 | 1432 u_char *p; |
1433 size_t len; | |
507 | 1434 ssize_t n; |
1435 ngx_int_t rc, rv; | |
509 | 1436 ngx_table_elt_t *h; |
507 | 1437 ngx_connection_t *c; |
1438 ngx_http_header_t *hh; | |
1439 ngx_http_request_t *r; | |
511 | 1440 ngx_http_core_srv_conf_t *cscf; |
507 | 1441 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
|
1442 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1443 c = rev->data; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
1444 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
|
1445 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1446 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
|
1447 "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
|
1448 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1449 if (rev->timedout) { |
505 | 1450 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
1451 c->timedout = 1; | |
1452 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
|
1453 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1454 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1455 |
507 | 1456 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
1457 | |
7681 | 1458 rc = NGX_OK; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1459 |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
1460 for ( ;; ) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1461 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1462 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
|
1463 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1464 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
|
1465 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1466 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
|
1467 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1468 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
|
1469 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
|
1470 break; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1471 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1472 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1473 if (rv == NGX_DECLINED) { |
3076 | 1474 p = r->header_name_start; |
1475 | |
3848
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1476 r->lingering_close = 1; |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1477 |
3287
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1478 if (p == NULL) { |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1479 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
|
1480 "client sent too large request"); |
3848
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1481 ngx_http_finalize_request(r, |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1482 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
|
1483 break; |
3287
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1484 } |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1485 |
e07630a9547d
fix segfault if there is single large_client_header_buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3228
diff
changeset
|
1486 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
|
1487 |
3076 | 1488 if (len > NGX_MAX_ERROR_STR - 300) { |
1489 len = NGX_MAX_ERROR_STR - 300; | |
531 | 1490 } |
1491 | |
505 | 1492 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
|
1493 "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
|
1494 len, r->header_name_start); |
3848
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1495 |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1496 ngx_http_finalize_request(r, |
de59ad6bf557
introduce 494 code "Request Header Too Large"
Igor Sysoev <igor@sysoev.ru>
parents:
3814
diff
changeset
|
1497 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
|
1498 break; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1499 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1500 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1501 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1502 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
|
1503 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1504 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
|
1505 break; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1506 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1507 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1508 |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1509 /* 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
|
1510 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
|
1511 |
7681 | 1512 switch (r->http_version) { |
1513 #if (NGX_HTTP_V3) | |
1514 case NGX_HTTP_VERSION_30: | |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1515 rc = ngx_http_v3_parse_header(r, r->header_in); |
7681 | 1516 break; |
1517 #endif | |
1518 | |
1519 default: /* HTTP/1.x */ | |
1520 rc = ngx_http_parse_header_line(r, r->header_in, | |
1521 cscf->underscores_in_headers); | |
1522 } | |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
1523 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1524 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
|
1525 |
7681 | 1526 /* XXX */ |
4739
986cc869b09d
Corrected $request_length calculation for pipelined requests.
Andrey Belov <defan@nginx.com>
parents:
4697
diff
changeset
|
1527 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
|
1528 |
511 | 1529 if (r->invalid_header && cscf->ignore_invalid_headers) { |
503 | 1530 |
1531 /* there was error while a header line parsing */ | |
1532 | |
505 | 1533 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
3076 | 1534 "client sent invalid header line: \"%*s\"", |
1535 r->header_end - r->header_name_start, | |
1536 r->header_name_start); | |
503 | 1537 continue; |
1538 } | |
1539 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1540 /* 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
|
1541 |
501 | 1542 h = ngx_list_push(&r->headers_in.headers); |
1543 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
|
1544 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
|
1545 break; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1546 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1547 |
507 | 1548 h->hash = r->header_hash; |
1549 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1550 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
|
1551 h->key.data = r->header_name_start; |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1552 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1553 if (h->key.data[h->key.len]) { |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1554 h->key.data[h->key.len] = '\0'; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1555 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1556 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1557 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
|
1558 h->value.data = r->header_start; |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1559 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1560 if (h->value.data[h->value.len]) { |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1561 h->value.data[h->value.len] = '\0'; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
1562 } |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
1563 |
2049 | 1564 h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); |
649 | 1565 if (h->lowcase_key == NULL) { |
1566 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
|
1567 break; |
649 | 1568 } |
1569 | |
1570 if (h->key.len == r->lowcase_index) { | |
1571 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1572 | |
1573 } else { | |
2135 | 1574 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
|
1575 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1576 |
649 | 1577 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, |
1578 h->lowcase_key, h->key.len); | |
1579 | |
1580 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
|
1581 break; |
649 | 1582 } |
1583 | |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
1584 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 1585 "http header: \"%V: %V\"", |
1586 &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
|
1587 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
1588 continue; |
505 | 1589 } |
1590 | |
1591 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
|
1592 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1593 /* 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
|
1594 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
1595 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
|
1596 "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
|
1597 |
7699
1e45c02f6376
HTTP/3 $request_line variable.
Roman Arutyunyan <arut@nginx.com>
parents:
7692
diff
changeset
|
1598 r->request_length += r->header_in->pos - r->header_name_start; /* XXX */ |
475 | 1599 |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
1600 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
|
1601 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1602 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
|
1603 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1604 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
|
1605 break; |
82
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
1606 } |
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
1607 |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
1608 ngx_http_process_request(r); |
537 | 1609 |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1610 break; |
505 | 1611 } |
1612 | |
1613 if (rc == NGX_AGAIN) { | |
1614 | |
1615 /* a header line parsing is still not complete */ | |
1616 | |
1617 continue; | |
66
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
1618 } |
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
1619 |
6409
71edd9192f24
Fixed buffer over-read while logging invalid request headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6320
diff
changeset
|
1620 /* rc == NGX_HTTP_PARSE_INVALID_HEADER */ |
505 | 1621 |
1622 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
|
1623 "client sent invalid header line"); |
71edd9192f24
Fixed buffer over-read while logging invalid request headers.
Valentin Bartenev <vbart@nginx.com>
parents:
6320
diff
changeset
|
1624 |
1427 | 1625 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
|
1626 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
|
1627 } |
7354
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1628 |
1812f1d79d84
Fixed socket leak with "return 444" in error_page (ticket #274).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7351
diff
changeset
|
1629 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
|
1630 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
1631 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
1632 |
501 | 1633 static ssize_t |
1634 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
|
1635 { |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
1636 ssize_t n; |
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
1637 ngx_event_t *rev; |
681 | 1638 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
|
1639 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
|
1640 |
681 | 1641 c = r->connection; |
1642 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
|
1643 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1644 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
|
1645 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1646 if (n > 0) { |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1647 return n; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1648 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1649 |
523 | 1650 if (rev->ready) { |
681 | 1651 n = c->recv(c, r->header_in->last, |
1652 r->header_in->end - r->header_in->last); | |
523 | 1653 } else { |
1654 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
|
1655 } |
c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
1656 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1657 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
|
1658 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
|
1659 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
|
1660 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
|
1661 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1662 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
1663 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
|
1664 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
|
1665 return NGX_ERROR; |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
1666 } |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
1667 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1668 return NGX_AGAIN; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1669 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1670 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1671 if (n == 0) { |
681 | 1672 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
|
1673 "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
|
1674 } |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1675 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1676 if (n == 0 || n == NGX_ERROR) { |
991 | 1677 c->error = 1; |
992 | 1678 c->log->action = "reading client request headers"; |
681 | 1679 |
991 | 1680 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
|
1681 return NGX_ERROR; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1682 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1683 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1684 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
|
1685 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1686 return n; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1687 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1688 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
1689 |
501 | 1690 static ngx_int_t |
1691 ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, | |
1692 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
|
1693 { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1694 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
|
1695 ngx_buf_t *b; |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1696 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
|
1697 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
|
1698 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
|
1699 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1700 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
|
1701 "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
|
1702 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1703 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
|
1704 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1705 /* 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
|
1706 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1707 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
|
1708 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
|
1709 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1710 return NGX_OK; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1711 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1712 |
7681 | 1713 old = request_line ? r->request_start : r->header_name_start; /* XXX */ |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1714 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1715 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
|
1716 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1717 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
|
1718 && (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
|
1719 >= 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
|
1720 { |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1721 return NGX_DECLINED; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1722 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1723 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1724 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
|
1725 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1726 if (hc->free) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1727 cl = hc->free; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1728 hc->free = cl->next; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1729 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1730 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
|
1731 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1732 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 1733 "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
|
1734 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
|
1735 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1736 } 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
|
1737 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1738 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
|
1739 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
|
1740 if (b == NULL) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1741 return NGX_ERROR; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1742 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1743 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1744 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
|
1745 if (cl == NULL) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1746 return NGX_ERROR; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1747 } |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1748 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1749 cl->buf = b; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1750 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1751 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 1752 "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
|
1753 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
|
1754 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1755 } else { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1756 return NGX_DECLINED; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1757 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1758 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1759 cl->next = hc->busy; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1760 hc->busy = cl; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
1761 hc->nbusy++; |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1762 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1763 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
|
1764 /* |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1765 * 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
|
1766 * 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
|
1767 * 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
|
1768 */ |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1769 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1770 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
|
1771 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1772 return NGX_OK; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1773 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1774 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1775 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6480 | 1776 "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
|
1777 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1778 new = b->start; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1779 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1780 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
|
1781 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1782 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
|
1783 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
|
1784 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1785 if (request_line) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1786 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
|
1787 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1788 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
|
1789 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
|
1790 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1791 |
7681 | 1792 if (r->method_start >= old && r->method_start < r->header_in->pos) { |
1793 r->method_start = new + (r->method_start - old); | |
1794 r->method_end = new + (r->method_end - old); | |
1795 } | |
1796 | |
1797 if (r->uri_start >= old && r->uri_start < r->header_in->pos) { | |
1798 r->uri_start = new + (r->uri_start - old); | |
1799 r->uri_end = new + (r->uri_end - old); | |
1800 } | |
1801 | |
1802 if (r->schema_start >= old && r->schema_start < r->header_in->pos) { | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1803 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
|
1804 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
|
1805 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1806 |
7681 | 1807 if (r->host_start >= old && r->host_start < r->header_in->pos) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1808 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
|
1809 if (r->host_end) { |
a6fe6bedb9e3
fix segfault when $host is used and
Igor Sysoev <igor@sysoev.ru>
parents:
895
diff
changeset
|
1810 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
|
1811 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1812 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1813 |
7681 | 1814 if (r->port_start >= old && r->port_start < r->header_in->pos) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1815 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
|
1816 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
|
1817 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1818 |
7681 | 1819 if (r->uri_ext >= old && r->uri_ext < r->header_in->pos) { |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1820 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
|
1821 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1822 |
7681 | 1823 if (r->args_start >= old && r->args_start < r->header_in->pos) { |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1824 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
|
1825 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1826 |
7681 | 1827 if (r->http_protocol.data >= old |
1828 && r->http_protocol.data < r->header_in->pos) | |
1829 { | |
1677
c997912a8f0b
copy protocol value when large request line is copied,
Igor Sysoev <igor@sysoev.ru>
parents:
1676
diff
changeset
|
1830 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
|
1831 } |
c997912a8f0b
copy protocol value when large request line is copied,
Igor Sysoev <igor@sysoev.ru>
parents:
1676
diff
changeset
|
1832 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1833 } else { |
7681 | 1834 if (r->header_name_start >= old |
1835 && r->header_name_start < r->header_in->pos) | |
1836 { | |
1837 r->header_name_start = new; | |
1838 r->header_name_end = new + (r->header_name_end - old); | |
1839 } | |
1840 | |
1841 if (r->header_start >= old && r->header_start < r->header_in->pos) { | |
1842 r->header_start = new + (r->header_start - old); | |
1843 r->header_end = new + (r->header_end - old); | |
1844 } | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1845 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1846 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1847 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
|
1848 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1849 return NGX_OK; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1850 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1851 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1852 |
501 | 1853 static ngx_int_t |
509 | 1854 ngx_http_process_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, |
1855 ngx_uint_t offset) | |
1856 { | |
1857 ngx_table_elt_t **ph; | |
1858 | |
1859 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
1860 | |
1861 if (*ph == NULL) { | |
1862 *ph = h; | |
1863 } | |
1864 | |
1865 return NGX_OK; | |
1866 } | |
1867 | |
1868 | |
1869 static ngx_int_t | |
523 | 1870 ngx_http_process_unique_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, |
1871 ngx_uint_t offset) | |
1872 { | |
1873 ngx_table_elt_t **ph; | |
1874 | |
1875 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
1876 | |
1877 if (*ph == NULL) { | |
1878 *ph = h; | |
1879 return NGX_OK; | |
1880 } | |
1881 | |
1882 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
681 | 1883 "client sent duplicate header line: \"%V: %V\", " |
1884 "previous value: \"%V: %V\"", | |
1885 &h->key, &h->value, &(*ph)->key, &(*ph)->value); | |
523 | 1886 |
1887 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
1888 | |
1889 return NGX_ERROR; | |
1890 } | |
1891 | |
1892 | |
1893 static ngx_int_t | |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1894 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
|
1895 ngx_uint_t offset) |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1896 { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1897 ngx_int_t rc; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1898 ngx_str_t host; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1899 |
7627
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
1900 if (r->headers_in.host) { |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
1901 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
|
1902 "client sent duplicate host header: \"%V: %V\", " |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
1903 "previous value: \"%V: %V\"", |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
1904 &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
|
1905 &r->headers_in.host->value); |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
1906 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
|
1907 return NGX_ERROR; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1908 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1909 |
7627
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
1910 r->headers_in.host = h; |
4f18393a1d51
Disabled duplicate "Host" headers (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7626
diff
changeset
|
1911 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1912 host = h->value; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1913 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1914 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
|
1915 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1916 if (rc == NGX_DECLINED) { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1917 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
|
1918 "client sent invalid host header"); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1919 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
|
1920 return NGX_ERROR; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1921 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1922 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1923 if (rc == NGX_ERROR) { |
3152 | 1924 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1925 return NGX_ERROR; | |
1926 } | |
1927 | |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1928 if (r->headers_in.server.len) { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1929 return NGX_OK; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1930 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1931 |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1932 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
|
1933 return NGX_ERROR; |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1934 } |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
1935 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
1936 r->headers_in.server = host; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1937 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1938 return NGX_OK; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1939 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1940 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1941 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
1942 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
|
1943 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
|
1944 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
|
1945 { |
1549 | 1946 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
|
1947 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
|
1948 |
1549 | 1949 } 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
|
1950 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
|
1951 } |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1952 |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1953 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
|
1954 } |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1955 |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1956 |
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
1957 static ngx_int_t |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1958 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
|
1959 ngx_uint_t offset) |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1960 { |
2205 | 1961 u_char *user_agent, *msie; |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1962 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1963 if (r->headers_in.user_agent) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1964 return NGX_OK; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1965 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1966 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1967 r->headers_in.user_agent = h; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1968 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1969 /* 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
|
1970 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1971 user_agent = h->value.data; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1972 |
2205 | 1973 msie = ngx_strstrn(user_agent, "MSIE ", 5 - 1); |
1974 | |
1975 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
|
1976 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1977 r->headers_in.msie = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1978 |
2205 | 1979 if (msie[6] == '.') { |
1980 | |
1981 switch (msie[5]) { | |
1982 case '4': | |
1983 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
|
1984 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
|
1985 break; |
2205 | 1986 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
|
1987 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
|
1988 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
|
1989 } |
a137de814516
do not disable gzip for MSIE 6.0 SV1 in "gzip_disable msie6"
Igor Sysoev <igor@sysoev.ru>
parents:
3052
diff
changeset
|
1990 break; |
2205 | 1991 } |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1992 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1993 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1994 #if 0 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1995 /* MSIE ignores the SSL "close notify" alert */ |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1996 if (c->ssl) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1997 c->ssl->no_send_shutdown = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1998 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
1999 #endif |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2000 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2001 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2002 if (ngx_strstrn(user_agent, "Opera", 5 - 1)) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2003 r->headers_in.opera = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2004 r->headers_in.msie = 0; |
2205 | 2005 r->headers_in.msie6 = 0; |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2006 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2007 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2008 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
|
2009 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2010 if (ngx_strstrn(user_agent, "Gecko/", 6 - 1)) { |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2011 r->headers_in.gecko = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2012 |
3315 | 2013 } else if (ngx_strstrn(user_agent, "Chrome/", 7 - 1)) { |
2014 r->headers_in.chrome = 1; | |
2015 | |
4552
b00098cbc44d
Restricted keepalive_disable safari to OS X only.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4472
diff
changeset
|
2016 } 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
|
2017 && 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
|
2018 { |
3419
fcd72b8d69f3
disable keepalive for Safari:
Igor Sysoev <igor@sysoev.ru>
parents:
3416
diff
changeset
|
2019 r->headers_in.safari = 1; |
fcd72b8d69f3
disable keepalive for Safari:
Igor Sysoev <igor@sysoev.ru>
parents:
3416
diff
changeset
|
2020 |
2004
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2021 } 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
|
2022 r->headers_in.konqueror = 1; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2023 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2024 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2025 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2026 return NGX_OK; |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2027 } |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2028 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2029 |
38fa1d3a31b7
test user agent in header callback
Igor Sysoev <igor@sysoev.ru>
parents:
1974
diff
changeset
|
2030 static ngx_int_t |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2031 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
|
2032 ngx_uint_t offset) |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2033 { |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2034 ngx_array_t *headers; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2035 ngx_table_elt_t **ph; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2036 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2037 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
|
2038 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2039 if (headers->elts == NULL) { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2040 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
|
2041 != NGX_OK) |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2042 { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2043 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
|
2044 return NGX_ERROR; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2045 } |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2046 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2047 |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2048 ph = ngx_array_push(headers); |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2049 if (ph == NULL) { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2050 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
|
2051 return NGX_ERROR; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2052 } |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2053 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2054 *ph = h; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5082
diff
changeset
|
2055 return NGX_OK; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2056 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2057 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2058 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2059 ngx_int_t |
501 | 2060 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
|
2061 { |
5092
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
2062 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
|
2063 && 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
|
2064 == NGX_ERROR) |
c4d3310574e0
Apply server configuration as soon as host is known.
Valentin Bartenev <vbart@nginx.com>
parents:
5091
diff
changeset
|
2065 { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2066 return NGX_ERROR; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2067 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2068 |
7681 | 2069 if (r->headers_in.host == NULL && r->http_version == NGX_HTTP_VERSION_11) { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2070 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
|
2071 "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
|
2072 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
|
2073 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
|
2074 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2075 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2076 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
|
2077 r->headers_in.content_length_n = |
663 | 2078 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
|
2079 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
|
2080 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2081 if (r->headers_in.content_length_n == NGX_ERROR) { |
505 | 2082 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
2083 "client sent invalid \"Content-Length\" header"); | |
4930
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2084 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
505 | 2085 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
|
2086 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2087 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2088 |
6306
b1858fc47e3b
Style: unified request method checks.
Ruslan Ermilov <ru@nginx.com>
parents:
6289
diff
changeset
|
2089 if (r->method == NGX_HTTP_TRACE) { |
1151 | 2090 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
2091 "client sent TRACE method"); | |
2092 ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED); | |
2093 return NGX_ERROR; | |
2094 } | |
2095 | |
4930
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2096 if (r->headers_in.transfer_encoding) { |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2097 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
|
2098 && 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
|
2099 (u_char *) "chunked", 7) == 0) |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2100 { |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2101 r->headers_in.content_length = NULL; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2102 r->headers_in.content_length_n = -1; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2103 r->headers_in.chunked = 1; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2104 |
7626
fe5976aae0e3
Removed "Transfer-Encoding: identity" support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7625
diff
changeset
|
2105 } else { |
4930
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2106 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
|
2107 "client sent unknown \"Transfer-Encoding\": \"%V\"", |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2108 &r->headers_in.transfer_encoding->value); |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2109 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
|
2110 return NGX_ERROR; |
6f085bfcdb4d
Request body: chunked transfer encoding support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4891
diff
changeset
|
2111 } |
298
4a3f18406832
nginx-0.0.3-2004-03-30-10:27:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
2112 } |
4a3f18406832
nginx-0.0.3-2004-03-30-10:27:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
2113 |
1467
e5352b711c47
there may be several "Connection" header lines and each may have several tokens
Igor Sysoev <igor@sysoev.ru>
parents:
1464
diff
changeset
|
2114 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
|
2115 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
|
2116 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
|
2117 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
|
2118 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
|
2119 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2120 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2121 |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2122 return NGX_OK; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2123 } |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2124 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2125 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2126 void |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2127 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
|
2128 { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1677
diff
changeset
|
2129 ngx_connection_t *c; |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2130 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2131 c = r->connection; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2132 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2133 #if (NGX_HTTP_SSL) |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2134 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2135 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
|
2136 long rc; |
1974
f32cc6df6bd6
fix memory leak when ssl_verify_client is on
Igor Sysoev <igor@sysoev.ru>
parents:
1924
diff
changeset
|
2137 X509 *cert; |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1677
diff
changeset
|
2138 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
|
2139 |
5091
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2140 if (c->ssl == NULL) { |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2141 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
|
2142 "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
|
2143 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
|
2144 return; |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2145 } |
d3e256c67d6d
SSL: do not treat SSL handshake as request.
Valentin Bartenev <vbart@nginx.com>
parents:
5090
diff
changeset
|
2146 |
669 | 2147 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); |
2148 | |
2994 | 2149 if (sscf->verify) { |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2150 rc = SSL_get_verify_result(c->ssl->connection); |
669 | 2151 |
4884
e406c997470a
SSL: the "ssl_verify_client" directive parameter "optional_no_ca".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4770
diff
changeset
|
2152 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
|
2153 && (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
|
2154 { |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2155 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
671 | 2156 "client SSL certificate verify error: (%l:%s)", |
669 | 2157 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
|
2158 |
7193
9d14931cec8c
SSL: using default server context in session remove (closes #1464).
Sergey Kandaurov <pluknet@nginx.com>
parents:
7156
diff
changeset
|
2159 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
|
2160 (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
|
2161 |
669 | 2162 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
|
2163 return; |
669 | 2164 } |
2165 | |
2994 | 2166 if (sscf->verify == 1) { |
2167 cert = SSL_get_peer_certificate(c->ssl->connection); | |
2168 | |
2169 if (cert == NULL) { | |
2170 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
2171 "client sent no required SSL certificate"); | |
2172 | |
7193
9d14931cec8c
SSL: using default server context in session remove (closes #1464).
Sergey Kandaurov <pluknet@nginx.com>
parents:
7156
diff
changeset
|
2173 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
|
2174 (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
|
2175 |
2994 | 2176 ngx_http_finalize_request(r, NGX_HTTPS_NO_CERT); |
2177 return; | |
2178 } | |
2179 | |
2180 X509_free(cert); | |
669 | 2181 } |
2182 } | |
2183 } | |
2184 | |
2185 #endif | |
2186 | |
1233
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2187 if (c->read->timer_set) { |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2188 ngx_del_timer(c->read); |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2189 } |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2190 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2191 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
2192 (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
|
2193 r->stat_reading = 0; |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
2194 (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
|
2195 r->stat_writing = 1; |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2196 #endif |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2197 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2198 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
|
2199 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
|
2200 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
|
2201 |
754f3648642d
fix ssl_verify_client for HTTP/0.9
Igor Sysoev <igor@sysoev.ru>
parents:
1219
diff
changeset
|
2202 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
|
2203 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2204 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2205 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2206 static ngx_int_t |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2207 ngx_http_validate_host(ngx_str_t *host, ngx_pool_t *pool, ngx_uint_t alloc) |
477 | 2208 { |
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
|
2209 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
|
2210 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
|
2211 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2212 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
|
2213 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
|
2214 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
|
2215 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
|
2216 } 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
|
2217 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2218 dot_pos = host->len; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2219 host_len = host->len; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2220 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2221 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
|
2222 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2223 state = sw_usual; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2224 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2225 for (i = 0; i < host->len; i++) { |
3152 | 2226 ch = h[i]; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2227 |
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
|
2228 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
|
2229 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2230 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
|
2231 if (dot_pos == i - 1) { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2232 return NGX_DECLINED; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2233 } |
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
|
2234 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
|
2235 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
|
2236 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2237 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
|
2238 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
|
2239 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
|
2240 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
|
2241 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2242 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
|
2243 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2244 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
|
2245 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
|
2246 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
|
2247 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2248 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
|
2249 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2250 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
|
2251 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
|
2252 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
|
2253 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
|
2254 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2255 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
|
2256 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2257 case '\0': |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2258 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
|
2259 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2260 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
|
2261 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2262 if (ngx_path_separator(ch)) { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2263 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
|
2264 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2265 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2266 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
|
2267 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
|
2268 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2269 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4304
diff
changeset
|
2270 break; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2271 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2272 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2273 |
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
|
2274 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
|
2275 host_len--; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2276 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2277 |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2278 if (host_len == 0) { |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2279 return NGX_DECLINED; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2280 } |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2281 |
3152 | 2282 if (alloc) { |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2283 host->data = ngx_pnalloc(pool, host_len); |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2284 if (host->data == NULL) { |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2285 return NGX_ERROR; |
3152 | 2286 } |
2287 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2288 ngx_strlow(host->data, h, host_len); |
3152 | 2289 } |
2290 | |
5087
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2291 host->len = host_len; |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2292 |
66e0f9adbc8c
Changed interface of ngx_http_validate_host().
Valentin Bartenev <vbart@nginx.com>
parents:
5086
diff
changeset
|
2293 return NGX_OK; |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2294 } |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2295 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2296 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2297 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
|
2298 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
|
2299 { |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2300 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
|
2301 ngx_http_connection_t *hc; |
593 | 2302 ngx_http_core_loc_conf_t *clcf; |
2303 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
|
2304 |
5548
4d47722d76b2
Fixed false compiler warning.
Vladimir Homutov <vl@nginx.com>
parents:
5547
diff
changeset
|
2305 #if (NGX_SUPPRESS_WARN) |
4d47722d76b2
Fixed false compiler warning.
Vladimir Homutov <vl@nginx.com>
parents:
5547
diff
changeset
|
2306 cscf = NULL; |
4d47722d76b2
Fixed false compiler warning.
Vladimir Homutov <vl@nginx.com>
parents:
5547
diff
changeset
|
2307 #endif |
4d47722d76b2
Fixed false compiler warning.
Vladimir Homutov <vl@nginx.com>
parents:
5547
diff
changeset
|
2308 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2309 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
|
2310 |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2311 #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
|
2312 |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2313 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
|
2314 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
|
2315 && 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
|
2316 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
|
2317 { |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2318 #if (NGX_PCRE) |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2319 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
|
2320 && 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
|
2321 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
|
2322 { |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2323 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
|
2324 return NGX_ERROR; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2325 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2326 #endif |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2327 return NGX_OK; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2328 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2329 } |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2330 |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2331 #endif |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2332 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2333 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
|
2334 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
|
2335 host, r, &cscf); |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2336 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2337 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
|
2338 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
|
2339 return NGX_ERROR; |
477 | 2340 } |
2341 | |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2342 #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
|
2343 |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2344 if (hc->ssl_servername) { |
5095
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2345 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
|
2346 |
5094
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2347 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
|
2348 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
|
2349 rc = NGX_OK; |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2350 } |
5095
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2351 |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2352 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
|
2353 |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2354 if (sscf->verify) { |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2355 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
|
2356 "client attempted to request the server name " |
6584
690b15cc8915
Fixed an error log message.
Valentin Bartenev <vbart@nginx.com>
parents:
6556
diff
changeset
|
2357 "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
|
2358 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
|
2359 return NGX_ERROR; |
4fbef397c753
SNI: added restriction on requesting host other than negotiated.
Valentin Bartenev <vbart@nginx.com>
parents:
5094
diff
changeset
|
2360 } |
5094
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2361 } |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2362 |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2363 #endif |
e0a3714a36f8
SNI: reset to default server if requested host was not found.
Valentin Bartenev <vbart@nginx.com>
parents:
5093
diff
changeset
|
2364 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2365 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
|
2366 return NGX_OK; |
1387 | 2367 } |
2368 | |
593 | 2369 r->srv_conf = cscf->ctx->srv_conf; |
2370 r->loc_conf = cscf->ctx->loc_conf; | |
509 | 2371 |
2372 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
|
2373 |
6129
187aa751ad62
Core: the ngx_set_connection_log() macro.
Vladimir Homutov <vl@nginx.com>
parents:
6126
diff
changeset
|
2374 ngx_set_connection_log(r->connection, clcf->error_log); |
477 | 2375 |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
2005
diff
changeset
|
2376 return NGX_OK; |
477 | 2377 } |
2378 | |
2379 | |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2380 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
|
2381 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
|
2382 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
|
2383 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
|
2384 { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2385 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
|
2386 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2387 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
|
2388 return NGX_DECLINED; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2389 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2390 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2391 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
|
2392 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
|
2393 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
|
2394 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2395 if (cscf) { |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2396 *cscfp = cscf; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2397 return NGX_OK; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2398 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2399 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2400 #if (NGX_PCRE) |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2401 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2402 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
|
2403 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
|
2404 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
|
2405 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
|
2406 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2407 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
|
2408 |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2409 #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
|
2410 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2411 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
|
2412 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
|
2413 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2414 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
|
2415 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2416 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
|
2417 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2418 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
|
2419 continue; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2420 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2421 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2422 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
|
2423 hc = c->data; |
68ca3e824115
SNI: avoid surplus lookup of virtual server if SNI was used.
Valentin Bartenev <vbart@nginx.com>
parents:
5092
diff
changeset
|
2424 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
|
2425 |
5088
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2426 *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
|
2427 return NGX_OK; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2428 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2429 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2430 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
|
2431 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
|
2432 "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
|
2433 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
|
2434 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2435 return NGX_ERROR; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2436 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2437 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2438 return NGX_DECLINED; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2439 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2440 |
5200
9d83ec073c51
Fixed build with --with-mail_ssl_module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5121
diff
changeset
|
2441 #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
|
2442 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2443 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
|
2444 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2445 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
|
2446 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2447 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
|
2448 continue; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2449 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2450 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2451 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
|
2452 *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
|
2453 return NGX_OK; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2454 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2455 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2456 return NGX_ERROR; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2457 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2458 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2459 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2460 #endif /* NGX_PCRE */ |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2461 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2462 return NGX_DECLINED; |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2463 } |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2464 |
ac31fcecb464
SNI: ignore captures in server_name regexes when matching by SNI.
Valentin Bartenev <vbart@nginx.com>
parents:
5087
diff
changeset
|
2465 |
509 | 2466 static void |
2467 ngx_http_request_handler(ngx_event_t *ev) | |
2468 { | |
2469 ngx_connection_t *c; | |
2470 ngx_http_request_t *r; | |
2471 | |
2472 c = ev->data; | |
2473 r = c->data; | |
2474 | |
5928
8dfee01ff0bd
Upstream: improved subrequest logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5871
diff
changeset
|
2475 ngx_http_set_log_request(c->log, r); |
665 | 2476 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2477 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
|
2478 "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
|
2479 |
7156
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2480 if (c->close) { |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2481 r->main->count++; |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2482 ngx_http_terminate_request(r, 0); |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2483 ngx_http_run_posted_requests(c); |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2484 return; |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2485 } |
9c29644f6d03
Fixed worker_shutdown_timeout in various cases.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7034
diff
changeset
|
2486 |
6961
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2487 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
|
2488 ev->delayed = 0; |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2489 ev->timedout = 0; |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2490 } |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2491 |
509 | 2492 if (ev->write) { |
2493 r->write_event_handler(r); | |
2494 | |
2495 } else { | |
2496 r->read_event_handler(r); | |
2497 } | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2498 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2499 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
|
2500 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2501 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2502 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2503 void |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2504 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
|
2505 { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2506 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
|
2507 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
|
2508 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2509 for ( ;; ) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2510 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2511 if (c->destroyed) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2512 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2513 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2514 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2515 r = c->data; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2516 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
|
2517 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2518 if (pr == NULL) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2519 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2520 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2521 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2522 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
|
2523 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2524 r = pr->request; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2525 |
5928
8dfee01ff0bd
Upstream: improved subrequest logging.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5871
diff
changeset
|
2526 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
|
2527 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2528 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
|
2529 "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
|
2530 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2531 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
|
2532 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2533 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2534 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2535 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2536 ngx_int_t |
3064 | 2537 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
|
2538 { |
3064 | 2539 ngx_http_posted_request_t **p; |
2540 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2541 if (pr == NULL) { |
3064 | 2542 pr = ngx_palloc(r->pool, sizeof(ngx_http_posted_request_t)); |
2543 if (pr == NULL) { | |
2544 return NGX_ERROR; | |
2545 } | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2546 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2547 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2548 pr->request = r; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2549 pr->next = NULL; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2550 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2551 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
|
2552 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2553 *p = pr; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2554 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2555 return NGX_OK; |
509 | 2556 } |
2557 | |
2558 | |
501 | 2559 void |
509 | 2560 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
|
2561 { |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2562 ngx_connection_t *c; |
509 | 2563 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
|
2564 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
|
2565 |
3049 | 2566 c = r->connection; |
2567 | |
2568 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
6480 | 2569 "http finalize request: %i, \"%V?%V\" a:%d, c:%d", |
3049 | 2570 rc, &r->uri, &r->args, r == c->data, r->main->count); |
2571 | |
509 | 2572 if (rc == NGX_DONE) { |
3049 | 2573 ngx_http_finalize_connection(r); |
509 | 2574 return; |
2575 } | |
2576 | |
2819
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
2577 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
|
2578 c->error = 1; |
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
2579 } |
43fe53832da7
handle big responses for "size" and "test" image_filters
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
2580 |
681 | 2581 if (rc == NGX_DECLINED) { |
2582 r->content_handler = NULL; | |
2583 r->write_event_handler = ngx_http_core_run_phases; | |
2584 ngx_http_core_run_phases(r); | |
2585 return; | |
2586 } | |
2587 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
716
diff
changeset
|
2588 if (r != r->main && r->post_subrequest) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
716
diff
changeset
|
2589 rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc); |
667 | 2590 } |
2591 | |
1783 | 2592 if (rc == NGX_ERROR |
2593 || rc == NGX_HTTP_REQUEST_TIME_OUT | |
2594 || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST | |
2595 || c->error) | |
2596 { | |
613 | 2597 if (ngx_http_post_action(r) == NGX_OK) { |
2598 return; | |
2599 } | |
2600 | |
3049 | 2601 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
|
2602 return; |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2603 } |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2604 |
637 | 2605 if (rc >= NGX_HTTP_SPECIAL_RESPONSE |
2606 || rc == NGX_HTTP_CREATED | |
2607 || rc == NGX_HTTP_NO_CONTENT) | |
2608 { | |
587 | 2609 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
|
2610 c->timedout = 1; |
3049 | 2611 ngx_http_terminate_request(r, rc); |
587 | 2612 return; |
2613 } | |
2614 | |
597 | 2615 if (r == r->main) { |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2616 if (c->read->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2617 ngx_del_timer(c->read); |
569 | 2618 } |
2619 | |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2620 if (c->write->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2621 ngx_del_timer(c->write); |
569 | 2622 } |
2623 } | |
2624 | |
2250
7fc20e1105cd
set request handlers, this fixes complex proxied 400 handler with SSI includes
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
2625 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
|
2626 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
|
2627 |
569 | 2628 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); |
2629 return; | |
2630 } | |
2631 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2632 if (r != r->main) { |
7006
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2633 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
|
2634 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2635 if (r->background) { |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2636 if (!r->logged) { |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2637 if (clcf->log_subrequest) { |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2638 ngx_http_log_request(r); |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2639 } |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2640 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2641 r->logged = 1; |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2642 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2643 } else { |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2644 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2645 "subrequest: \"%V?%V\" logged again", |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2646 &r->uri, &r->args); |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2647 } |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2648 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2649 r->done = 1; |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2650 ngx_http_finalize_connection(r); |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2651 return; |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2652 } |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2653 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2654 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
|
2655 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2656 if (ngx_http_set_write_handler(r) != NGX_OK) { |
3049 | 2657 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
|
2658 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2659 |
525 | 2660 return; |
2661 } | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2662 |
509 | 2663 pr = r->parent; |
2664 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2665 if (r == c->data) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2666 |
3049 | 2667 r->main->count--; |
2668 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2669 if (!r->logged) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2670 if (clcf->log_subrequest) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2671 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
|
2672 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2673 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2674 r->logged = 1; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2675 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2676 } else { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2677 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
|
2678 "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
|
2679 &r->uri, &r->args); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2680 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2681 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2682 r->done = 1; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2683 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2684 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
|
2685 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
|
2686 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2687 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2688 c->data = pr; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2689 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2690 } else { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2691 |
4612
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
2692 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
2693 "http finalize non-active request: \"%V?%V\"", |
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
2694 &r->uri, &r->args); |
c42553296af1
Removed surplus condition.
Valentin Bartenev <vbart@nginx.com>
parents:
4594
diff
changeset
|
2695 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2696 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
|
2697 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2698 if (r->waited) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2699 r->done = 1; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2700 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2701 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2702 |
3064 | 2703 if (ngx_http_post_request(pr, NULL) != NGX_OK) { |
3049 | 2704 r->main->count++; |
2705 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
|
2706 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2707 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2708 |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2709 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
|
2710 "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
|
2711 &pr->uri, &pr->args); |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2712 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2713 return; |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2714 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2715 |
7011
5e05118678af
Fixed background requests with asynchronous operations.
Roman Arutyunyan <arut@nginx.com>
parents:
7008
diff
changeset
|
2716 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
|
2717 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2718 if (ngx_http_set_write_handler(r) != NGX_OK) { |
3049 | 2719 ngx_http_terminate_request(r, 0); |
2261 | 2720 } |
2721 | |
509 | 2722 return; |
2723 } | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
2724 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2725 if (r != c->data) { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2726 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
|
2727 "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
|
2728 &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
|
2729 return; |
527 | 2730 } |
2731 | |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2732 r->done = 1; |
7006
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2733 |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2734 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
|
2735 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
|
2736 |
629 | 2737 if (!r->post_action) { |
2738 r->request_complete = 1; | |
2739 } | |
2740 | |
613 | 2741 if (ngx_http_post_action(r) == NGX_OK) { |
577 | 2742 return; |
2743 } | |
2744 | |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2745 if (c->read->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2746 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
|
2747 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2748 |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2749 if (c->write->timer_set) { |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2750 c->write->delayed = 0; |
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2751 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
|
2752 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2753 |
1424
937fbbf611cd
optimize r->connection in ngx_http_finalize_request()
Igor Sysoev <igor@sysoev.ru>
parents:
1423
diff
changeset
|
2754 if (c->read->eof) { |
1423
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
2755 ngx_http_close_request(r, 0); |
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
2756 return; |
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
2757 } |
75e908236701
cancel keep-alive and lingering close on EOF
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
2758 |
3049 | 2759 ngx_http_finalize_connection(r); |
2760 } | |
2761 | |
2762 | |
2763 static void | |
2764 ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc) | |
2765 { | |
3064 | 2766 ngx_http_cleanup_t *cln; |
2767 ngx_http_request_t *mr; | |
2768 ngx_http_ephemeral_t *e; | |
3049 | 2769 |
2770 mr = r->main; | |
2771 | |
2772 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
|
2773 "http terminate request count:%d", mr->count); |
3049 | 2774 |
3176
60bc5cc68d3b
log 499 instead 0, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3153
diff
changeset
|
2775 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
|
2776 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
|
2777 } |
60bc5cc68d3b
log 499 instead 0, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3153
diff
changeset
|
2778 |
3049 | 2779 cln = mr->cleanup; |
2780 mr->cleanup = NULL; | |
2781 | |
2782 while (cln) { | |
2783 if (cln->handler) { | |
2784 cln->handler(cln->data); | |
2785 } | |
2786 | |
2787 cln = cln->next; | |
2788 } | |
2789 | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2790 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
|
2791 "http terminate cleanup count:%d blk:%d", |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2792 mr->count, mr->blocked); |
3049 | 2793 |
2794 if (mr->write_event_handler) { | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2795 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2796 if (mr->blocked) { |
7011
5e05118678af
Fixed background requests with asynchronous operations.
Roman Arutyunyan <arut@nginx.com>
parents:
7008
diff
changeset
|
2797 r->connection->error = 1; |
5e05118678af
Fixed background requests with asynchronous operations.
Roman Arutyunyan <arut@nginx.com>
parents:
7008
diff
changeset
|
2798 r->write_event_handler = ngx_http_request_finalizer; |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2799 return; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2800 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
2801 |
3064 | 2802 e = ngx_http_ephemeral(mr); |
3051 | 2803 mr->posted_requests = NULL; |
2804 mr->write_event_handler = ngx_http_terminate_handler; | |
3064 | 2805 (void) ngx_http_post_request(mr, &e->terminal_posted_request); |
3049 | 2806 return; |
2807 } | |
2808 | |
2809 ngx_http_close_request(mr, rc); | |
2810 } | |
2811 | |
2812 | |
2813 static void | |
2814 ngx_http_terminate_handler(ngx_http_request_t *r) | |
2815 { | |
2816 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
|
2817 "http terminate handler count:%d", r->count); |
3049 | 2818 |
2819 r->count = 1; | |
2820 | |
2821 ngx_http_close_request(r, 0); | |
2822 } | |
2823 | |
2824 | |
2825 static void | |
2826 ngx_http_finalize_connection(ngx_http_request_t *r) | |
2827 { | |
2828 ngx_http_core_loc_conf_t *clcf; | |
2829 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
2830 #if (NGX_HTTP_V2) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
2831 if (r->stream) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2832 ngx_http_close_request(r, 0); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2833 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2834 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2835 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
2836 |
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
|
2837 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
|
2838 |
3049 | 2839 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
|
2840 |
3214
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
2841 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
|
2842 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
|
2843 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
|
2844 |
798a7f1d3b2f
restore discard body handler after ngx_http_set_writer() set it to
Igor Sysoev <igor@sysoev.ru>
parents:
3211
diff
changeset
|
2845 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
|
2846 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
|
2847 + (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
|
2848 } |
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
|
2849 } |
3ea03c1fe050
add lingering timeout if a response is short and a request body is being
Igor Sysoev <igor@sysoev.ru>
parents:
3180
diff
changeset
|
2850 |
3049 | 2851 ngx_http_close_request(r, 0); |
2852 return; | |
2853 } | |
2854 | |
7006
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2855 r = r->main; |
9552758a786e
Background subrequests for cache updates.
Roman Arutyunyan <arut@nginx.com>
parents:
6993
diff
changeset
|
2856 |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
2857 if (r->reading_body) { |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
2858 r->keepalive = 0; |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
2859 r->lingering_close = 1; |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
2860 } |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5993
diff
changeset
|
2861 |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
2862 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
|
2863 && !ngx_exiting |
2019 | 2864 && r->keepalive |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
2865 && 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
|
2866 { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2867 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
|
2868 return; |
3984
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2869 } |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2870 |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2871 if (clcf->lingering_close == NGX_HTTP_LINGERING_ALWAYS |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2872 || (clcf->lingering_close == NGX_HTTP_LINGERING_ON |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2873 && (r->lingering_close |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2874 || r->header_in->pos < r->header_in->last |
3e51832c8215
lingering_close "off|on|always"
Igor Sysoev <igor@sysoev.ru>
parents:
3983
diff
changeset
|
2875 || r->connection->read->ready))) |
3981
77604e9a1ed8
enable lingering close for pipelined requests
Igor Sysoev <igor@sysoev.ru>
parents:
3978
diff
changeset
|
2876 { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2877 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
|
2878 return; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2879 } |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2880 |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
2881 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
|
2882 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2883 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2884 |
525 | 2885 static ngx_int_t |
501 | 2886 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
|
2887 { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2888 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
|
2889 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
|
2890 |
509 | 2891 r->http_state = NGX_HTTP_WRITING_REQUEST_STATE; |
2892 | |
3215
4edf28522d24
allow discarding body while a long response transfer
Igor Sysoev <igor@sysoev.ru>
parents:
3214
diff
changeset
|
2893 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
|
2894 ngx_http_discarded_request_body_handler: |
4edf28522d24
allow discarding body while a long response transfer
Igor Sysoev <igor@sysoev.ru>
parents:
3214
diff
changeset
|
2895 ngx_http_test_reading; |
525 | 2896 r->write_event_handler = ngx_http_writer; |
2897 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2898 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
|
2899 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
2900 if (wev->ready && wev->delayed) { |
525 | 2901 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
|
2902 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2903 |
509 | 2904 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
|
2905 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
|
2906 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
|
2907 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2908 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2909 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
|
2910 ngx_http_close_request(r, 0); |
525 | 2911 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
|
2912 } |
525 | 2913 |
2914 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
|
2915 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2916 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2917 |
509 | 2918 static void |
2919 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
|
2920 { |
6964 | 2921 ngx_int_t rc; |
509 | 2922 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
|
2923 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
|
2924 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
|
2925 |
509 | 2926 c = r->connection; |
2927 wev = c->write; | |
2928 | |
583 | 2929 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
2930 "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
|
2931 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2932 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
|
2933 |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
2934 if (wev->timedout) { |
6961
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2935 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
|
2936 "client timed out"); |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2937 c->timedout = 1; |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2938 |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2939 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
|
2940 return; |
4195
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2941 } |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2942 |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2943 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
|
2944 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
|
2945 "http writer delayed"); |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2946 |
6961
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2947 if (!wev->delayed) { |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2948 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
|
2949 } |
903fb1ddc07f
Moved handling of wev->delayed to the connection event handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6942
diff
changeset
|
2950 |
4195
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2951 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
|
2952 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
|
2953 } |
4195
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2954 |
35f4997c08ce
Fix for socket leak with "aio sendfile" and "limit_rate".
Maxim Dounin <mdounin@mdounin.ru>
parents:
4194
diff
changeset
|
2955 return; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
2956 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
2957 |
583 | 2958 rc = ngx_http_output_filter(r, NULL); |
2959 | |
2960 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
6964 | 2961 "http writer output filter: %i, \"%V?%V\"", |
583 | 2962 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
|
2963 |
2883
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2964 if (rc == NGX_ERROR) { |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2965 ngx_http_finalize_request(r, rc); |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2966 return; |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2967 } |
d0cba58e5bfa
fix socket leak introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
2968 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2969 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
|
2970 |
4194
7ce8f2cde0af
Fix for connection drops with AIO.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4033
diff
changeset
|
2971 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
|
2972 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
|
2973 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2974 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
2975 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { |
569 | 2976 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
|
2977 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2978 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2979 return; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2980 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2981 |
583 | 2982 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
2983 "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
|
2984 |
3216
79ae445ec57b
fix two previous commits: an early parallel body discarding completion
Igor Sysoev <igor@sysoev.ru>
parents:
3215
diff
changeset
|
2985 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
|
2986 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2987 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
|
2988 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2989 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2990 |
2377
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2991 static void |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2992 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
|
2993 { |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2994 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
|
2995 "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
|
2996 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2997 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
|
2998 } |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
2999 |
87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
Igor Sysoev <igor@sysoev.ru>
parents:
2370
diff
changeset
|
3000 |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3001 void |
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3002 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
|
3003 { |
1283
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3004 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
|
3005 "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
|
3006 |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3007 /* 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
|
3008 |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3009 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
|
3010 && 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
|
3011 { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3012 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
|
3013 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
|
3014 } |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3015 } |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3016 } |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3017 |
a3f8d6d17b94
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
Igor Sysoev <igor@sysoev.ru>
parents:
1253
diff
changeset
|
3018 |
2294 | 3019 void |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3020 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
|
3021 { |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3022 int n; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3023 char buf[1]; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3024 ngx_err_t err; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3025 ngx_event_t *rev; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3026 ngx_connection_t *c; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3027 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3028 c = r->connection; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3029 rev = c->read; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3030 |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3031 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
|
3032 |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3033 #if (NGX_HTTP_V2) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3034 |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3035 if (r->stream) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3036 if (c->error) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3037 err = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3038 goto closed; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3039 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3040 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3041 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3042 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3043 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3044 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3045 |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3046 #if (NGX_HAVE_KQUEUE) |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3047 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3048 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
|
3049 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3050 if (!rev->pending_eof) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3051 return; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3052 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3053 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3054 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3055 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3056 err = rev->kq_errno; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3057 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3058 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3059 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3060 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3061 #endif |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3062 |
5374
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3063 #if (NGX_HAVE_EPOLLRDHUP) |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3064 |
6536
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3065 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
|
3066 socklen_t len; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3067 |
6536
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3068 if (!rev->pending_eof) { |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3069 return; |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3070 } |
f7849bfb6d21
Improved EPOLLRDHUP handling.
Valentin Bartenev <vbart@nginx.com>
parents:
6480
diff
changeset
|
3071 |
5374
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3072 rev->eof = 1; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3073 c->error = 1; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3074 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3075 err = 0; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3076 len = sizeof(ngx_err_t); |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3077 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3078 /* |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3079 * 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
|
3080 * 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
|
3081 */ |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3082 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3083 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
|
3084 == -1) |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3085 { |
5557
188481078faf
Use ngx_socket_errno where appropriate.
Piotr Sikora <piotr@cloudflare.com>
parents:
5548
diff
changeset
|
3086 err = ngx_socket_errno; |
5374
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3087 } |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3088 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3089 goto closed; |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3090 } |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3091 |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3092 #endif |
ef3d094bb6d3
Use EPOLLRDHUP in ngx_http_test_reading() (ticket #320).
Valentin Bartenev <vbart@nginx.com>
parents:
5363
diff
changeset
|
3093 |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3094 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
|
3095 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3096 if (n == 0) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3097 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3098 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3099 err = 0; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3100 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3101 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3102 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3103 } else if (n == -1) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3104 err = ngx_socket_errno; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3105 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3106 if (err != NGX_EAGAIN) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3107 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3108 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3109 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3110 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3111 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3112 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3113 |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
3114 /* 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
|
3115 |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3116 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
|
3117 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3118 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
|
3119 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
|
3120 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
3121 } |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3122 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3123 return; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3124 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3125 closed: |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3126 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3127 if (err) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3128 rev->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3129 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3130 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
3131 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
|
3132 "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
|
3133 |
5289
aadfadd5af2b
Fixed ngx_http_test_reading() to finalize request properly.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5210
diff
changeset
|
3134 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
|
3135 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3136 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3137 |
501 | 3138 static void |
3139 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
|
3140 { |
452 | 3141 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
|
3142 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
|
3143 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
|
3144 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
|
3145 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
|
3146 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
|
3147 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
|
3148 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3149 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
|
3150 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
|
3151 |
1373
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
3152 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
|
3153 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3154 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
|
3155 |
1373
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
3156 if (r->discard_body) { |
2489
d1a7203a8a44
avoid a double redirect response if
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
3157 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
|
3158 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
|
3159 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
|
3160 return; |
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
3161 } |
fdea12ffb24a
discard request body before going to keep-alive state and use lingering timeouts
Igor Sysoev <igor@sysoev.ru>
parents:
1368
diff
changeset
|
3162 |
483 | 3163 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
|
3164 |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
3165 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
|
3166 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
|
3167 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3168 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
|
3169 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3170 /* 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
|
3171 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3172 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
|
3173 |
455 | 3174 /* |
3175 * If the large header buffers were allocated while the previous | |
3176 * 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
|
3177 * the pipelined request (see ngx_http_create_request()). |
577 | 3178 * |
455 | 3179 * Now we would move the large header buffers to the free list. |
3180 */ | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3181 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3182 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
|
3183 ln = cl; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3184 cl = cl->next; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3185 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3186 if (ln->buf == b) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3187 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
|
3188 continue; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3189 } |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3190 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3191 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
|
3192 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
|
3193 f->last = f->start; |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3194 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3195 ln->next = hc->free; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3196 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
|
3197 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3198 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3199 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
|
3200 if (cl == NULL) { |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3201 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
|
3202 return; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3203 } |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3204 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3205 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
|
3206 cl->next = NULL; |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3207 |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3208 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
|
3209 hc->nbusy = 1; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3210 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3211 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3212 |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3213 /* 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
|
3214 r->keepalive = 0; |
0e420f3f8e18
clear r->keepalive to disable preventively calling
Igor Sysoev <igor@sysoev.ru>
parents:
3176
diff
changeset
|
3215 |
3049 | 3216 ngx_http_free_request(r, 0); |
569 | 3217 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
3218 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
|
3219 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3220 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
|
3221 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
|
3222 return; |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3223 } |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
3224 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
3225 wev = c->write; |
509 | 3226 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
|
3227 |
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
|
3228 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
|
3229 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3230 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
|
3231 |
483 | 3232 c->log->action = "reading client pipelined request line"; |
567 | 3233 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3234 r = ngx_http_create_request(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3235 if (r == NULL) { |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3236 ngx_http_close_connection(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3237 return; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3238 } |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3239 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3240 r->pipeline = 1; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3241 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3242 c->data = r; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3243 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3244 c->sent = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3245 c->destroyed = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3246 |
5102
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3247 if (rev->timer_set) { |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3248 ngx_del_timer(rev); |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3249 } |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3250 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3251 rev->handler = ngx_http_process_request_line; |
2014 | 3252 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
|
3253 return; |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
3254 } |
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
3255 |
455 | 3256 /* |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3257 * 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
|
3258 * 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
|
3259 * 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
|
3260 * c->pool and are freed too. |
455 | 3261 */ |
3262 | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3263 b = c->buffer; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3264 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3265 if (ngx_pfree(c->pool, b->start) == NGX_OK) { |
455 | 3266 |
3267 /* | |
3268 * the special note for ngx_http_keepalive_handler() that | |
3269 * c->buffer's memory was freed | |
3270 */ | |
3271 | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3272 b->pos = NULL; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3273 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3274 } else { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3275 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
|
3276 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
|
3277 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3278 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3279 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
|
3280 hc->free); |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3281 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3282 if (hc->free) { |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3283 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
|
3284 ln = cl; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3285 cl = cl->next; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3286 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
|
3287 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
|
3288 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3289 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3290 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
|
3291 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3292 |
6480 | 3293 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
|
3294 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
|
3295 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3296 if (hc->busy) { |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3297 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
|
3298 ln = cl; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3299 cl = cl->next; |
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3300 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
|
3301 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
|
3302 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3303 |
6926
e662cbf1b932
Converted hc->busy/hc->free to use chain links.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6901
diff
changeset
|
3304 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
|
3305 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
|
3306 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3307 |
1779
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
3308 #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
|
3309 if (c->ssl) { |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
3310 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
|
3311 } |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
3312 #endif |
06014cfdb5b1
create ssl buffer on demand and free it before keep-alive
Igor Sysoev <igor@sysoev.ru>
parents:
1776
diff
changeset
|
3313 |
509 | 3314 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
|
3315 |
583 | 3316 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
|
3317 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) != NGX_OK) { |
583 | 3318 ngx_http_close_connection(c); |
3319 return; | |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3320 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3321 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3322 |
483 | 3323 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
|
3324 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
3325 if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) { |
501 | 3326 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
|
3327 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
|
3328 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
|
3329 return; |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
3330 } |
452 | 3331 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
3332 c->tcp_nopush = NGX_TCP_NOPUSH_UNSET; |
473 | 3333 tcp_nodelay = ngx_tcp_nodelay_and_tcp_nopush ? 1 : 0; |
452 | 3334 |
3335 } else { | |
473 | 3336 tcp_nodelay = 1; |
3337 } | |
3338 | |
7007
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
7006
diff
changeset
|
3339 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
|
3340 ngx_http_close_connection(c); |
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
7006
diff
changeset
|
3341 return; |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
3342 } |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
3343 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3344 #if 0 |
455 | 3345 /* 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
|
3346 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
|
3347 #endif |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
3348 |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
3349 c->idle = 1; |
3880
e3cb8e27e413
reuse keepalive connections if there are no free worker connections
Igor Sysoev <igor@sysoev.ru>
parents:
3848
diff
changeset
|
3350 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
|
3351 |
5102
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3352 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
|
3353 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
3354 if (rev->ready) { |
2014 | 3355 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
|
3356 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3357 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3358 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3359 |
501 | 3360 static void |
3361 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
|
3362 { |
501 | 3363 size_t size; |
3364 ssize_t n; | |
3365 ngx_buf_t *b; | |
3366 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
|
3367 |
394
e7a68e14ccd3
nginx-0.0.7-2004-07-16-10:33:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
3368 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
|
3369 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3370 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
|
3371 |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
3372 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
|
3373 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
|
3374 return; |
68
d549fdc17d7e
nginx-0.0.1-2003-03-12-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
3375 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3376 |
469 | 3377 #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
|
3378 |
455 | 3379 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
587 | 3380 if (rev->pending_eof) { |
483 | 3381 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
|
3382 ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno, |
461 | 3383 "kevent() reported that client %V closed " |
483 | 3384 "keepalive connection", &c->addr_text); |
473 | 3385 #if (NGX_HTTP_SSL) |
3386 if (c->ssl) { | |
547 | 3387 c->ssl->no_send_shutdown = 1; |
473 | 3388 } |
3389 #endif | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3390 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
|
3391 return; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3392 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3393 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3394 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3395 #endif |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3396 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3397 b = c->buffer; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3398 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
|
3399 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3400 if (b->pos == NULL) { |
455 | 3401 |
3402 /* | |
3403 * The c->buffer's memory was freed by ngx_http_set_keepalive(). | |
3404 * However, the c->buffer->start and c->buffer->end were not changed | |
3405 * to keep the buffer size. | |
3406 */ | |
3407 | |
501 | 3408 b->pos = ngx_palloc(c->pool, size); |
3409 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
|
3410 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
|
3411 return; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3412 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3413 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3414 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
|
3415 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
|
3416 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
|
3417 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3418 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3419 /* |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3420 * 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
|
3421 * 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
|
3422 */ |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3423 |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
3424 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
|
3425 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
|
3426 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
3427 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
|
3428 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
|
3429 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3430 if (n == NGX_AGAIN) { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3431 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
475 | 3432 ngx_http_close_connection(c); |
5082
42a888fdad0b
Fixed potential segfault in ngx_http_keepalive_handler().
Valentin Bartenev <vbart@nginx.com>
parents:
5072
diff
changeset
|
3433 return; |
475 | 3434 } |
3435 | |
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
|
3436 /* |
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
|
3437 * 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
|
3438 * 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
|
3439 */ |
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
|
3440 |
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
|
3441 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
|
3442 |
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
|
3443 /* |
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
|
3444 * 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
|
3445 */ |
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
|
3446 |
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
|
3447 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
|
3448 } |
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
|
3449 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3450 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3451 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3452 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3453 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
|
3454 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
|
3455 return; |
68
d549fdc17d7e
nginx-0.0.1-2003-03-12-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
3456 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3457 |
483 | 3458 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
|
3459 |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3460 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
|
3461 ngx_log_error(NGX_LOG_INFO, c->log, ngx_socket_errno, |
483 | 3462 "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
|
3463 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
|
3464 return; |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3465 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3466 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3467 b->last += n; |
483 | 3468 |
3469 c->log->handler = ngx_http_log_error; | |
3470 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
|
3471 |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1115
diff
changeset
|
3472 c->idle = 0; |
3880
e3cb8e27e413
reuse keepalive connections if there are no free worker connections
Igor Sysoev <igor@sysoev.ru>
parents:
3848
diff
changeset
|
3473 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
|
3474 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3475 c->data = ngx_http_create_request(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3476 if (c->data == NULL) { |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3477 ngx_http_close_connection(c); |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3478 return; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3479 } |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3480 |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3481 c->sent = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3482 c->destroyed = 0; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3483 |
5102
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3484 ngx_del_timer(rev); |
f597c9be5c92
Use "client_header_timeout" for all requests in a connection.
Valentin Bartenev <vbart@nginx.com>
parents:
5101
diff
changeset
|
3485 |
5105
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3486 rev->handler = ngx_http_process_request_line; |
4d67b696388f
Refactored ngx_http_init_request().
Valentin Bartenev <vbart@nginx.com>
parents:
5104
diff
changeset
|
3487 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
|
3488 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3489 |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
3490 |
501 | 3491 static void |
3492 ngx_http_set_lingering_close(ngx_http_request_t *r) | |
577 | 3493 { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3494 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
|
3495 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
|
3496 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
|
3497 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3498 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
|
3499 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3500 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
|
3501 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3502 rev = c->read; |
509 | 3503 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
|
3504 |
557 | 3505 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
|
3506 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
|
3507 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3508 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
|
3509 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
|
3510 return; |
53
d1e42f1b8fd4
nginx-0.0.1-2003-01-27-00:08:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
52
diff
changeset
|
3511 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3512 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
3513 wev = c->write; |
509 | 3514 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
|
3515 |
583 | 3516 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
|
3517 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) != NGX_OK) { |
583 | 3518 ngx_http_close_request(r, 0); |
3519 return; | |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3520 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3521 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3522 |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3523 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
|
3524 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
|
3525 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
|
3526 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
|
3527 return; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
3528 } |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
3529 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
3530 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
|
3531 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
|
3532 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3533 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3534 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
3535 |
501 | 3536 static void |
3537 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
|
3538 { |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3539 ssize_t n; |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3540 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
|
3541 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
|
3542 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
|
3543 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
|
3544 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
|
3545 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3546 c = rev->data; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3547 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
|
3548 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3549 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
|
3550 "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
|
3551 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3552 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
|
3553 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
|
3554 return; |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
3555 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3556 |
5210
ea2ba6dbe361
Fixed lingering_time check.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5200
diff
changeset
|
3557 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
|
3558 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
|
3559 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
|
3560 return; |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
3561 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3562 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3563 do { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3564 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
|
3565 |
6480 | 3566 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
|
3567 |
7351
2b5528023f6b
Lingering close changed to handle NGX_AGAIN.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7318
diff
changeset
|
3568 if (n == NGX_AGAIN) { |
2b5528023f6b
Lingering close changed to handle NGX_AGAIN.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7318
diff
changeset
|
3569 break; |
2b5528023f6b
Lingering close changed to handle NGX_AGAIN.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7318
diff
changeset
|
3570 } |
2b5528023f6b
Lingering close changed to handle NGX_AGAIN.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7318
diff
changeset
|
3571 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3572 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
|
3573 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
|
3574 return; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3575 } |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3576 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3577 } 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
|
3578 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2385
diff
changeset
|
3579 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
477 | 3580 ngx_http_close_request(r, 0); |
475 | 3581 return; |
3582 } | |
3583 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3584 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
|
3585 |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
3586 timer *= 1000; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
3587 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
3588 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
|
3589 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
|
3590 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3591 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
3592 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
|
3593 } |
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
3594 |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
3595 |
501 | 3596 void |
3597 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
|
3598 { |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3599 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
|
3600 |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3601 return; |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3602 } |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3603 |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
3604 |
509 | 3605 void |
3606 ngx_http_request_empty_handler(ngx_http_request_t *r) | |
3607 { | |
3608 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
583 | 3609 "http request empty handler"); |
509 | 3610 |
3611 return; | |
3612 } | |
3613 | |
3614 | |
501 | 3615 ngx_int_t |
581 | 3616 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
|
3617 { |
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
|
3618 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
|
3619 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
|
3620 |
501 | 3621 b = ngx_calloc_buf(r->pool); |
3622 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
|
3623 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
|
3624 } |
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
|
3625 |
581 | 3626 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
|
3627 |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3628 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
|
3629 b->last_buf = 1; |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3630 |
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3631 } else { |
2993
f592d466bbda
fix r2972, it caused "zero size buf" alert.
Igor Sysoev <igor@sysoev.ru>
parents:
2992
diff
changeset
|
3632 b->sync = 1; |
2971
87ddbe960172
fix ngx_http_send_special() for subrequests handled by perl
Igor Sysoev <igor@sysoev.ru>
parents:
2951
diff
changeset
|
3633 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
|
3634 } |
581 | 3635 } |
3636 | |
3637 if (flags & NGX_HTTP_FLUSH) { | |
3638 b->flush = 1; | |
3639 } | |
3640 | |
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
|
3641 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
|
3642 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
|
3643 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
3644 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
|
3645 } |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3646 |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
3647 |
613 | 3648 static ngx_int_t |
3649 ngx_http_post_action(ngx_http_request_t *r) | |
3650 { | |
3651 ngx_http_core_loc_conf_t *clcf; | |
3652 | |
3653 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
3654 | |
3655 if (clcf->post_action.data == NULL) { | |
3656 return NGX_DECLINED; | |
3657 } | |
3658 | |
4472
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
3659 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
|
3660 return NGX_DECLINED; |
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
3661 } |
c95b828912a3
Core: protection from cycles with named locations and post_action.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4471
diff
changeset
|
3662 |
623 | 3663 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3664 "post action: \"%V\"", &clcf->post_action); | |
3665 | |
3145
9160a117a46a
fix request counter for post_action, the bug was introduced in r3050
Igor Sysoev <igor@sysoev.ru>
parents:
3076
diff
changeset
|
3666 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
|
3667 |
613 | 3668 r->http_version = NGX_HTTP_VERSION_9; |
3669 r->header_only = 1; | |
629 | 3670 r->post_action = 1; |
613 | 3671 |
1368
202cae9a0c2b
rename ngx_http_block_read() and ngx_http_test_read() to ..._reading()
Igor Sysoev <igor@sysoev.ru>
parents:
1283
diff
changeset
|
3672 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
|
3673 |
1894
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3674 if (clcf->post_action.data[0] == '/') { |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3675 ngx_http_internal_redirect(r, &clcf->post_action, NULL); |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3676 |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3677 } else { |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3678 ngx_http_named_location(r, &clcf->post_action); |
22e28e77246b
named locations in post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1858
diff
changeset
|
3679 } |
613 | 3680 |
3681 return NGX_OK; | |
3682 } | |
3683 | |
3684 | |
3685 static void | |
3049 | 3686 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
|
3687 { |
639 | 3688 ngx_connection_t *c; |
569 | 3689 |
3049 | 3690 r = r->main; |
569 | 3691 c = r->connection; |
639 | 3692 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3693 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
|
3694 "http request count:%d blk:%d", r->count, r->blocked); |
3049 | 3695 |
3696 if (r->count == 0) { | |
3697 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "http request count is zero"); | |
3698 } | |
3699 | |
3700 r->count--; | |
3701 | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3051
diff
changeset
|
3702 if (r->count || r->blocked) { |
3049 | 3703 return; |
3704 } | |
3705 | |
6246
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3706 #if (NGX_HTTP_V2) |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3707 if (r->stream) { |
257b51c37c5a
The HTTP/2 implementation (RFC 7240, 7241).
Valentin Bartenev <vbart@nginx.com>
parents:
6237
diff
changeset
|
3708 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
|
3709 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3710 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3711 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3712 |
3049 | 3713 ngx_http_free_request(r, rc); |
569 | 3714 ngx_http_close_connection(c); |
3715 } | |
3716 | |
3717 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3718 void |
3049 | 3719 ngx_http_free_request(ngx_http_request_t *r, ngx_int_t rc) |
569 | 3720 { |
2261 | 3721 ngx_log_t *log; |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3722 ngx_pool_t *pool; |
2261 | 3723 struct linger linger; |
3724 ngx_http_cleanup_t *cln; | |
3725 ngx_http_log_ctx_t *ctx; | |
3726 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
|
3727 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
3728 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
|
3729 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
3730 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
|
3731 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3732 if (r->pool == NULL) { |
531 | 3733 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
|
3734 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3735 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3736 |
5363
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
3737 cln = r->cleanup; |
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
3738 r->cleanup = NULL; |
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
3739 |
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
3740 while (cln) { |
639 | 3741 if (cln->handler) { |
3742 cln->handler(cln->data); | |
3743 } | |
5363
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
3744 |
31af4ae8ad9c
Request cleanup code unified, no functional changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5354
diff
changeset
|
3745 cln = cln->next; |
639 | 3746 } |
3747 | |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3748 #if (NGX_STAT_STUB) |
567 | 3749 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3750 if (r->stat_reading) { |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
3751 (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
|
3752 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3753 |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3754 if (r->stat_writing) { |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
3755 (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
|
3756 } |
567 | 3757 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3758 #endif |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
3759 |
3049 | 3760 if (rc > 0 && (r->headers_out.status == 0 || r->connection->sent == 0)) { |
3761 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
|
3762 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3763 |
7462
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
3764 if (!r->logged) { |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
3765 log->action = "logging request"; |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
3766 |
be2af41d3620
SSL: variables support in ssl_certificate and ssl_certificate_key.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7458
diff
changeset
|
3767 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
|
3768 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3769 |
2077 | 3770 log->action = "closing request"; |
3771 | |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3772 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
|
3773 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
|
3774 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3775 if (clcf->reset_timedout_connection) { |
509 | 3776 linger.l_onoff = 1; |
3777 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
|
3778 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3779 if (setsockopt(r->connection->fd, SOL_SOCKET, SO_LINGER, |
509 | 3780 (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
|
3781 { |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3782 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
|
3783 "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
|
3784 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3785 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3786 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
3787 |
509 | 3788 /* 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
|
3789 ctx = log->data; |
461 | 3790 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
|
3791 |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
3792 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
|
3793 |
583 | 3794 r->connection->destroyed = 1; |
3795 | |
5096
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3796 /* |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3797 * 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
|
3798 * 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
|
3799 */ |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3800 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3801 pool = r->pool; |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3802 r->pool = NULL; |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3803 |
63014d919fec
Allocate request object from its own pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5095
diff
changeset
|
3804 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
|
3805 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3806 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
3807 |
531 | 3808 static void |
2261 | 3809 ngx_http_log_request(ngx_http_request_t *r) |
3810 { | |
3811 ngx_uint_t i, n; | |
3812 ngx_http_handler_pt *log_handler; | |
3813 ngx_http_core_main_conf_t *cmcf; | |
3814 | |
3815 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
3816 | |
3817 log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts; | |
3818 n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts; | |
3819 | |
3820 for (i = 0; i < n; i++) { | |
3821 log_handler[i](r); | |
3822 } | |
3823 } | |
3824 | |
3825 | |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
5119
diff
changeset
|
3826 void |
501 | 3827 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
|
3828 { |
479 | 3829 ngx_pool_t *pool; |
3830 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
3831 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
|
3832 "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
|
3833 |
539 | 3834 #if (NGX_HTTP_SSL) |
452 | 3835 |
3836 if (c->ssl) { | |
3837 if (ngx_ssl_shutdown(c) == NGX_AGAIN) { | |
577 | 3838 c->ssl->handler = ngx_http_close_connection; |
452 | 3839 return; |
3840 } | |
3841 } | |
3842 | |
3843 #endif | |
3844 | |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
3845 #if (NGX_STAT_STUB) |
2951
5acd98486a33
ignore ngx_atomic_fetch_add() result
Igor Sysoev <igor@sysoev.ru>
parents:
2902
diff
changeset
|
3846 (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
|
3847 #endif |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
3848 |
583 | 3849 c->destroyed = 1; |
3850 | |
479 | 3851 pool = c->pool; |
3852 | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
416
diff
changeset
|
3853 ngx_close_connection(c); |
479 | 3854 |
501 | 3855 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
|
3856 } |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
3857 |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
3858 |
501 | 3859 static u_char * |
3860 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
|
3861 { |
483 | 3862 u_char *p; |
505 | 3863 ngx_http_request_t *r; |
483 | 3864 ngx_http_log_ctx_t *ctx; |
461 | 3865 |
483 | 3866 if (log->action) { |
509 | 3867 p = ngx_snprintf(buf, len, " while %s", log->action); |
461 | 3868 len -= p - buf; |
505 | 3869 buf = p; |
461 | 3870 } |
3871 | |
509 | 3872 ctx = log->data; |
3873 | |
1810 | 3874 p = ngx_snprintf(buf, len, ", client: %V", &ctx->connection->addr_text); |
509 | 3875 len -= p - buf; |
505 | 3876 |
3877 r = ctx->request; | |
3878 | |
509 | 3879 if (r) { |
665 | 3880 return r->log_handler(r, ctx->current_request, p, len); |
1810 | 3881 |
3882 } else { | |
3883 p = ngx_snprintf(p, len, ", server: %V", | |
3884 &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
|
3885 } |
461 | 3886 |
509 | 3887 return p; |
3888 } | |
3889 | |
3890 | |
3891 static u_char * | |
665 | 3892 ngx_http_log_error_handler(ngx_http_request_t *r, ngx_http_request_t *sr, |
3893 u_char *buf, size_t len) | |
509 | 3894 { |
1811 | 3895 char *uri_separator; |
3896 u_char *p; | |
3897 ngx_http_upstream_t *u; | |
3898 ngx_http_core_srv_conf_t *cscf; | |
3899 | |
3900 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | |
3901 | |
3902 p = ngx_snprintf(buf, len, ", server: %V", &cscf->server_name); | |
3903 len -= p - buf; | |
3904 buf = p; | |
503 | 3905 |
1656
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3906 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
|
3907 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
|
3908 if (*p == CR || *p == LF) { |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3909 break; |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3910 } |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3911 } |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3912 |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3913 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
|
3914 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
|
3915 } |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3916 |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3917 if (r->request_line.len) { |
7a9b44e35c53
log entire request line instead of URI only
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
3918 p = ngx_snprintf(buf, len, ", request: \"%V\"", &r->request_line); |
505 | 3919 len -= p - buf; |
3920 buf = p; | |
461 | 3921 } |
3922 | |
665 | 3923 if (r != sr) { |
3924 p = ngx_snprintf(buf, len, ", subrequest: \"%V\"", &sr->uri); | |
3925 len -= p - buf; | |
3926 buf = p; | |
3927 } | |
3928 | |
3929 u = sr->upstream; | |
3930 | |
884 | 3931 if (u && u->peer.name) { |
3932 | |
3933 uri_separator = ""; | |
3934 | |
3935 #if (NGX_HAVE_UNIX_DOMAIN) | |
3936 if (u->peer.sockaddr && u->peer.sockaddr->sa_family == AF_UNIX) { | |
3937 uri_separator = ":"; | |
3938 } | |
3939 #endif | |
665 | 3940 |
3941 p = ngx_snprintf(buf, len, ", upstream: \"%V%V%s%V\"", | |
1658 | 3942 &u->schema, u->peer.name, |
884 | 3943 uri_separator, &u->uri); |
665 | 3944 len -= p - buf; |
3945 buf = p; | |
3946 } | |
3947 | |
505 | 3948 if (r->headers_in.host) { |
3949 p = ngx_snprintf(buf, len, ", host: \"%V\"", | |
3950 &r->headers_in.host->value); | |
3951 len -= p - buf; | |
3952 buf = p; | |
3953 } | |
3954 | |
3955 if (r->headers_in.referer) { | |
3956 p = ngx_snprintf(buf, len, ", referrer: \"%V\"", | |
3957 &r->headers_in.referer->value); | |
3958 buf = p; | |
3959 } | |
3960 | |
3961 return buf; | |
3962 } |