annotate src/http/ngx_http_request.c @ 7876:b290610bf812

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