Mercurial > hg > nginx
annotate src/http/ngx_http_request.c @ 1122:3728476ab96d
stop on superfluous closing "}"
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 20 Feb 2007 14:33:26 +0000 |
parents | f07a5f4017d9 |
children | 03f1133f24e8 |
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 |
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
|
4 */ |
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 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #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
|
8 #include <ngx_core.h> |
50
b288069a8696
nginx-0.0.1-2003-01-23-21:47:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
47
diff
changeset
|
9 #include <ngx_event.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 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
13 static void ngx_http_init_request(ngx_event_t *ev); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
14 static void ngx_http_process_request_line(ngx_event_t *rev); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
15 static void ngx_http_process_request_headers(ngx_event_t *rev); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
16 static ssize_t ngx_http_read_request_header(ngx_http_request_t *r); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
17 static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, |
501 | 18 ngx_uint_t request_line); |
509 | 19 |
20 static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r, | |
21 ngx_table_elt_t *h, ngx_uint_t offset); | |
523 | 22 static ngx_int_t ngx_http_process_unique_header_line(ngx_http_request_t *r, |
23 ngx_table_elt_t *h, ngx_uint_t offset); | |
509 | 24 static ngx_int_t ngx_http_process_cookie(ngx_http_request_t *r, |
25 ngx_table_elt_t *h, ngx_uint_t offset); | |
26 | |
356
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
27 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); |
649 | 28 static void ngx_http_find_virtual_server(ngx_http_request_t *r, |
29 ngx_http_virtual_names_t *vn, ngx_uint_t hash); | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
30 |
509 | 31 static void ngx_http_request_handler(ngx_event_t *ev); |
525 | 32 static ngx_int_t ngx_http_set_write_handler(ngx_http_request_t *r); |
509 | 33 static void ngx_http_writer(ngx_http_request_t *r); |
34 | |
35 static void ngx_http_block_read(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
|
36 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
|
37 static void ngx_http_keepalive_handler(ngx_event_t *ev); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
38 static void ngx_http_set_lingering_close(ngx_http_request_t *r); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
39 static void ngx_http_lingering_close_handler(ngx_event_t *ev); |
613 | 40 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r); |
531 | 41 static void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error); |
569 | 42 static void ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error); |
531 | 43 static void ngx_http_close_connection(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
|
44 |
483 | 45 static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len); |
665 | 46 static u_char *ngx_http_log_error_handler(ngx_http_request_t *r, |
47 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
|
48 |
539 | 49 #if (NGX_HTTP_SSL) |
50 static void ngx_http_ssl_handshake(ngx_event_t *rev); | |
547 | 51 static void ngx_http_ssl_handshake_handler(ngx_connection_t *c); |
539 | 52 #endif |
53 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 |
505 | 55 static char *ngx_http_client_errors[] = { |
56 | |
57 /* NGX_HTTP_PARSE_INVALID_METHOD */ | |
58 "client sent invalid method", | |
59 | |
60 /* NGX_HTTP_PARSE_INVALID_REQUEST */ | |
61 "client sent invalid request", | |
62 | |
63 /* NGX_HTTP_PARSE_INVALID_09_METHOD */ | |
64 "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
|
65 }; |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
66 |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
67 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
68 ngx_http_header_t ngx_http_headers_in[] = { |
509 | 69 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host), |
523 | 70 ngx_http_process_unique_header_line }, |
509 | 71 |
72 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection), | |
523 | 73 ngx_http_process_unique_header_line }, |
509 | 74 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
75 { ngx_string("If-Modified-Since"), |
509 | 76 offsetof(ngx_http_headers_in_t, if_modified_since), |
77 ngx_http_process_header_line }, | |
78 | |
79 { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent), | |
80 ngx_http_process_header_line }, | |
81 | |
82 { ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer), | |
83 ngx_http_process_header_line }, | |
84 | |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
85 { ngx_string("Content-Length"), |
509 | 86 offsetof(ngx_http_headers_in_t, content_length), |
523 | 87 ngx_http_process_unique_header_line }, |
509 | 88 |
479 | 89 { ngx_string("Content-Type"), |
509 | 90 offsetof(ngx_http_headers_in_t, content_type), |
91 ngx_http_process_header_line }, | |
92 | |
93 { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range), | |
94 ngx_http_process_header_line }, | |
95 | |
581 | 96 { ngx_string("Transfer-Encoding"), |
97 offsetof(ngx_http_headers_in_t, transfer_encoding), | |
98 ngx_http_process_header_line }, | |
99 | |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
100 #if (NGX_HTTP_GZIP) |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
101 { ngx_string("Accept-Encoding"), |
509 | 102 offsetof(ngx_http_headers_in_t, accept_encoding), |
103 ngx_http_process_header_line }, | |
104 | |
105 { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via), | |
106 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
|
107 #endif |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
108 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
109 { ngx_string("Authorization"), |
509 | 110 offsetof(ngx_http_headers_in_t, authorization), |
523 | 111 ngx_http_process_unique_header_line }, |
509 | 112 |
113 { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive), | |
114 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
|
115 |
573 | 116 #if (NGX_HTTP_PROXY || NGX_HTTP_REALIP) |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
117 { ngx_string("X-Forwarded-For"), |
509 | 118 offsetof(ngx_http_headers_in_t, x_forwarded_for), |
119 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
|
120 #endif |
479 | 121 |
573 | 122 #if (NGX_HTTP_REALIP) |
123 { ngx_string("X-Real-IP"), | |
124 offsetof(ngx_http_headers_in_t, x_real_ip), | |
125 ngx_http_process_header_line }, | |
126 #endif | |
127 | |
489 | 128 #if (NGX_HTTP_HEADERS) |
509 | 129 { ngx_string("Accept"), offsetof(ngx_http_headers_in_t, accept), |
130 ngx_http_process_header_line }, | |
131 | |
489 | 132 { ngx_string("Accept-Language"), |
509 | 133 offsetof(ngx_http_headers_in_t, accept_language), |
134 ngx_http_process_header_line }, | |
489 | 135 #endif |
136 | |
637 | 137 #if (NGX_HTTP_DAV) |
138 { ngx_string("Depth"), offsetof(ngx_http_headers_in_t, depth), | |
139 ngx_http_process_header_line }, | |
140 | |
141 { ngx_string("Destination"), offsetof(ngx_http_headers_in_t, destination), | |
142 ngx_http_process_header_line }, | |
681 | 143 |
1059 | 144 { ngx_string("Overwrite"), offsetof(ngx_http_headers_in_t, overwrite), |
145 ngx_http_process_header_line }, | |
146 | |
681 | 147 { ngx_string("Date"), offsetof(ngx_http_headers_in_t, date), |
148 ngx_http_process_header_line }, | |
637 | 149 #endif |
150 | |
509 | 151 { ngx_string("Cookie"), 0, ngx_http_process_cookie }, |
152 | |
153 { 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
|
154 }; |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
155 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
156 |
501 | 157 void |
158 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
|
159 { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
160 ngx_event_t *rev; |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
189
diff
changeset
|
161 ngx_http_log_ctx_t *ctx; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
162 |
501 | 163 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); |
164 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
|
165 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
|
166 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
167 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
168 |
461 | 169 ctx->client = &c->addr_text; |
170 ctx->request = NULL; | |
665 | 171 ctx->current_request = NULL; |
483 | 172 |
173 c->log->connection = c->number; | |
174 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
|
175 c->log->data = ctx; |
483 | 176 c->log->action = "reading client request line"; |
177 | |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
178 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
|
179 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
180 rev = c->read; |
509 | 181 rev->handler = ngx_http_init_request; |
569 | 182 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
|
183 |
567 | 184 #if (NGX_STAT_STUB) |
185 ngx_atomic_fetch_add(ngx_stat_reading, 1); | |
186 #endif | |
187 | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
188 if (rev->ready) { |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
189 /* the deferred accept(), rtsig, aio, iocp */ |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
190 |
611 | 191 if (ngx_use_accept_mutex) { |
563 | 192 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
|
193 return; |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
194 } |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
299
diff
changeset
|
195 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
196 ngx_http_init_request(rev); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
197 return; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
55
diff
changeset
|
198 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
199 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
200 ngx_add_timer(rev, c->listening->post_accept_timeout); |
53
d1e42f1b8fd4
nginx-0.0.1-2003-01-27-00:08:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
52
diff
changeset
|
201 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
202 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { |
567 | 203 #if (NGX_STAT_STUB) |
204 ngx_atomic_fetch_add(ngx_stat_reading, -1); | |
205 #endif | |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
206 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
|
207 return; |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
208 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
210 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
211 |
641 | 212 static void |
213 ngx_http_init_request(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
|
214 { |
641 | 215 socklen_t len; |
573 | 216 ngx_uint_t i; |
217 struct sockaddr_in sin; | |
218 ngx_connection_t *c; | |
219 ngx_http_request_t *r; | |
593 | 220 ngx_http_in_port_t *hip; |
221 ngx_http_in_addr_t *hia; | |
573 | 222 ngx_http_log_ctx_t *ctx; |
223 ngx_http_connection_t *hc; | |
224 ngx_http_core_srv_conf_t *cscf; | |
225 ngx_http_core_loc_conf_t *clcf; | |
226 ngx_http_core_main_conf_t *cmcf; | |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
227 #if (NGX_HTTP_SSL) |
573 | 228 ngx_http_ssl_srv_conf_t *sscf; |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
229 #endif |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
230 |
567 | 231 #if (NGX_STAT_STUB) |
232 ngx_atomic_fetch_add(ngx_stat_reading, -1); | |
233 #endif | |
234 | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
235 c = rev->data; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
236 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
237 if (rev->timedout) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
238 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
239 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
240 ngx_http_close_connection(c); |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
241 return; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
242 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
243 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
244 hc = c->data; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
245 |
567 | 246 if (hc == NULL) { |
501 | 247 hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)); |
248 if (hc == NULL) { | |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
249 ngx_http_close_connection(c); |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
250 return; |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
251 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
252 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
253 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
254 r = hc->request; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
255 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
256 if (r) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
257 ngx_memzero(r, sizeof(ngx_http_request_t)); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
258 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
259 r->pipeline = hc->pipeline; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
260 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
261 if (hc->nbusy) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
262 r->header_in = hc->busy[0]; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
263 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
264 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
265 } else { |
501 | 266 r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)); |
267 if (r == NULL) { | |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
268 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
|
269 return; |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
270 } |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
271 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
272 hc->request = r; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
273 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
274 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
275 c->data = r; |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
276 r->http_connection = hc; |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
277 |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
278 c->sent = 0; |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
279 r->signature = NGX_HTTP_MODULE; |
216
f1d0e5f09c1e
nginx-0.0.1-2003-12-25-23:26:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
215
diff
changeset
|
280 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
281 /* find the server configuration for the address:port */ |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
282 |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
283 /* AF_INET only */ |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
284 |
641 | 285 hip = c->listening->servers; |
593 | 286 hia = hip->addrs; |
287 | |
288 r->port = hip->port; | |
289 r->port_text = &hip->port_text; | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
290 |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
291 i = 0; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
292 |
593 | 293 if (hip->naddrs > 1) { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
294 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
295 /* |
406
ba0809223309
nginx-0.0.10-2004-08-23-23:09:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
296 * There are several addresses on this port and one of them |
ba0809223309
nginx-0.0.10-2004-08-23-23:09:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
297 * is the "*:port" wildcard so getsockname() is needed to determine |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
298 * the server address. |
406
ba0809223309
nginx-0.0.10-2004-08-23-23:09:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
299 * |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
300 * AcceptEx() already gave this address. |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
301 */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
302 |
461 | 303 #if (NGX_WIN32) |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
304 if (c->local_sockaddr) { |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
305 r->in_addr = |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
306 ((struct sockaddr_in *) c->local_sockaddr)->sin_addr.s_addr; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
307 |
479 | 308 } else |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
309 #endif |
479 | 310 { |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
311 len = sizeof(struct sockaddr_in); |
479 | 312 if (getsockname(c->fd, (struct sockaddr *) &sin, &len) == -1) { |
328
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
313 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
|
314 "getsockname() failed"); |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
315 ngx_http_close_connection(c); |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
316 return; |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
101
diff
changeset
|
317 } |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
287
diff
changeset
|
318 |
479 | 319 r->in_addr = sin.sin_addr.s_addr; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
320 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
321 |
641 | 322 /* the last address is "*" */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
323 |
593 | 324 for ( /* void */ ; i < hip->naddrs - 1; i++) { |
325 if (hia[i].addr == r->in_addr) { | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
326 break; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
327 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
328 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
329 |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
330 } else { |
593 | 331 r->in_addr = hia[0].addr; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
332 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
333 |
593 | 334 r->virtual_names = hia[i].virtual_names; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
335 |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
336 /* the default server configuration for the address:port */ |
593 | 337 cscf = hia[i].core_srv_conf; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
338 |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
339 r->main_conf = cscf->ctx->main_conf; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
340 r->srv_conf = cscf->ctx->srv_conf; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
341 r->loc_conf = cscf->ctx->loc_conf; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
342 |
593 | 343 r->server_name = cscf->server_name; |
344 | |
509 | 345 rev->handler = ngx_http_process_request_line; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
346 |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
347 #if (NGX_HTTP_SSL) |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
348 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
349 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
350 if (sscf->enable) { |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
351 |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
352 if (c->ssl == NULL) { |
547 | 353 if (ngx_ssl_create_connection(&sscf->ssl, c, NGX_SSL_BUFFER) |
507 | 354 == NGX_ERROR) |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
355 { |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
356 ngx_http_close_connection(c); |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
357 return; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
358 } |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
359 |
509 | 360 rev->handler = ngx_http_ssl_handshake; |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
361 } |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
362 |
513 | 363 r->main_filter_need_in_memory = 1; |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
364 } |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
365 |
392
d1222d46b3f9
nginx-0.0.7-2004-07-15-00:07:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
366 #endif |
d1222d46b3f9
nginx-0.0.7-2004-07-15-00:07:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
367 |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
368 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
369 c->log->file = clcf->err_log->file; |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
370 if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
371 c->log->log_level = clcf->err_log->log_level; |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
372 } |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
373 |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
374 if (c->buffer == 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
|
375 c->buffer = ngx_create_temp_buf(c->pool, |
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
|
376 cscf->client_header_buffer_size); |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
377 if (c->buffer == NULL) { |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
378 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
|
379 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
380 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
381 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
382 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
383 if (r->header_in == NULL) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
384 r->header_in = c->buffer; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
385 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
386 |
501 | 387 r->pool = ngx_create_pool(cscf->request_pool_size, c->log); |
388 if (r->pool == NULL) { | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
389 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
|
390 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
391 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
392 |
294
5cfd65b8b0a7
nginx-0.0.3-2004-03-23-09:01:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
293
diff
changeset
|
393 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
394 if (ngx_list_init(&r->headers_out.headers, r->pool, 20, |
581 | 395 sizeof(ngx_table_elt_t)) |
396 == NGX_ERROR) | |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
397 { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
398 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
399 return; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
400 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
401 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
402 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
|
403 if (r->ctx == NULL) { |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
404 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
405 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
406 } |
10
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
407 |
573 | 408 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
409 | |
410 r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts | |
411 * sizeof(ngx_http_variable_value_t)); | |
412 if (r->variables == NULL) { | |
413 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
414 return; | |
415 } | |
416 | |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
377
diff
changeset
|
417 c->single_connection = 1; |
583 | 418 c->destroyed = 0; |
419 | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
420 r->connection = c; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
421 |
553 | 422 r->main = r; |
423 | |
497 | 424 r->start_time = ngx_time(); |
425 | |
631 | 426 r->method = NGX_HTTP_UNKNOWN; |
427 | |
82
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
428 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
|
429 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
|
430 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
|
431 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
|
432 |
675 | 433 r->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1; |
434 r->subrequests = NGX_HTTP_MAX_SUBREQUESTS + 1; | |
435 | |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
436 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
|
437 |
505 | 438 ctx = c->log->data; |
439 ctx->request = r; | |
665 | 440 ctx->current_request = r; |
509 | 441 r->log_handler = ngx_http_log_error_handler; |
505 | 442 |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
443 #if (NGX_STAT_STUB) |
561 | 444 ngx_atomic_fetch_add(ngx_stat_reading, 1); |
477 | 445 r->stat_reading = 1; |
561 | 446 ngx_atomic_fetch_add(ngx_stat_requests, 1); |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
447 #endif |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
448 |
509 | 449 rev->handler(rev); |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
450 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
451 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
452 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
453 #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
|
454 |
501 | 455 static void |
456 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
|
457 { |
461 | 458 u_char buf[1]; |
459 ssize_t n; | |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
460 ngx_int_t rc; |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
461 ngx_connection_t *c; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
462 ngx_http_request_t *r; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
463 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
464 c = rev->data; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
465 r = c->data; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
466 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
467 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
|
468 "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
|
469 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
470 if (rev->timedout) { |
505 | 471 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
472 c->timedout = 1; | |
473 ngx_http_close_request(r, NGX_HTTP_REQUEST_TIME_OUT); | |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
474 return; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
475 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
476 |
583 | 477 n = recv(c->fd, (char *) buf, 1, MSG_PEEK); |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
478 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
479 if (n == -1 && ngx_socket_errno == NGX_EAGAIN) { |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
480 return; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
481 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
482 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
483 if (n == 1) { |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
484 if (buf[0] == 0x80 /* SSLv2 */ || buf[0] == 0x16 /* SSLv3/TLSv1 */) { |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
485 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, rev->log, 0, |
461 | 486 "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
|
487 |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
488 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
|
489 |
547 | 490 if (rc == NGX_AGAIN) { |
491 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
|
492 return; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
493 } |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
494 |
547 | 495 ngx_http_ssl_handshake_handler(c); |
496 | |
497 return; | |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
498 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
499 } else { |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
500 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
|
501 "plain http"); |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
502 |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
503 r->plain_http = 1; |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
504 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
505 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
506 |
509 | 507 rev->handler = ngx_http_process_request_line; |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
508 ngx_http_process_request_line(rev); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
509 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
510 |
547 | 511 |
512 static void | |
513 ngx_http_ssl_handshake_handler(ngx_connection_t *c) | |
514 { | |
515 ngx_http_request_t *r; | |
516 | |
517 if (c->ssl->handshaked) { | |
518 | |
519 /* | |
520 * The majority of browsers do not send the "close notify" alert. | |
521 * Among them are MSIE, old Mozilla, Netscape 4, Konqueror, | |
522 * and Links. And what is more, MSIE ignores the server's alert. | |
523 * | |
524 * Opera and recent Mozilla send the alert. | |
525 */ | |
526 | |
527 c->ssl->no_wait_shutdown = 1; | |
528 | |
529 c->read->handler = ngx_http_process_request_line; | |
530 /* STUB: epoll edge */ c->write->handler = ngx_http_empty_handler; | |
531 | |
532 ngx_http_process_request_line(c->read); | |
533 | |
534 return; | |
535 } | |
536 | |
537 r = c->data; | |
538 | |
539 ngx_http_close_request(r, NGX_HTTP_BAD_REQUEST); | |
540 | |
541 return; | |
542 } | |
543 | |
544 | |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
545 #endif |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
546 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
547 |
501 | 548 static void |
549 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
|
550 { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
551 ssize_t n; |
438
e56ab5ac8c65
nginx-0.0.12-2004-09-24-20:12:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
437
diff
changeset
|
552 ngx_int_t rc, rv; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
553 ngx_connection_t *c; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
554 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
|
555 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
556 c = rev->data; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
557 r = c->data; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
558 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
559 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
|
560 "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
|
561 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
562 if (rev->timedout) { |
505 | 563 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
564 c->timedout = 1; | |
565 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
|
566 return; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
567 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
568 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
569 rc = NGX_AGAIN; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
570 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
571 for ( ;; ) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
572 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
573 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
|
574 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
|
575 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
576 if (n == NGX_AGAIN || n == NGX_ERROR) { |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
577 return; |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
578 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
579 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
580 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
581 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
|
582 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
583 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
|
584 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
585 /* 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
|
586 |
461 | 587 r->request_line.len = r->request_end - r->request_start; |
588 r->request_line.data = r->request_start; | |
589 | |
192
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
191
diff
changeset
|
590 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
591 if (r->args_start) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
592 r->uri.len = r->args_start - 1 - r->uri_start; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
593 } else { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
594 r->uri.len = r->uri_end - r->uri_start; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
595 } |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
596 |
469 | 597 |
452 | 598 if (r->complex_uri || r->quoted_uri) { |
461 | 599 |
501 | 600 r->uri.data = ngx_palloc(r->pool, r->uri.len + 1); |
601 if (r->uri.data == NULL) { | |
461 | 602 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
603 return; | |
604 } | |
605 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
606 rc = ngx_http_parse_complex_uri(r); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
607 |
505 | 608 if (rc == NGX_HTTP_PARSE_INVALID_REQUEST) { |
609 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
610 "client sent invalid request"); | |
611 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
612 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
613 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
614 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
615 } else { |
461 | 616 r->uri.data = r->uri_start; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
617 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
618 |
469 | 619 |
461 | 620 r->unparsed_uri.len = r->uri_end - r->uri_start; |
621 r->unparsed_uri.data = r->uri_start; | |
622 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
623 |
509 | 624 r->method_name.len = r->method_end - r->request_start + 1; |
625 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
|
626 |
461 | 627 |
479 | 628 if (r->http_protocol.data) { |
629 r->http_protocol.len = r->request_end - r->http_protocol.data; | |
630 } | |
631 | |
632 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
633 if (r->uri_ext) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
634 if (r->args_start) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
635 r->exten.len = r->args_start - 1 - r->uri_ext; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
636 } else { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
637 r->exten.len = r->uri_end - r->uri_ext; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
638 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
639 |
461 | 640 r->exten.data = r->uri_ext; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
641 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
642 |
461 | 643 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
644 if (r->args_start && r->uri_end > r->args_start) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
645 r->args.len = r->uri_end - r->args_start; |
461 | 646 r->args.data = r->args_start; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
647 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
648 |
461 | 649 |
650 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
651 "http request line: \"%V\"", &r->request_line); | |
652 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
653 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
461 | 654 "http uri: \"%V\"", &r->uri); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
655 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
656 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
461 | 657 "http args: \"%V\"", &r->args); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
658 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
659 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
461 | 660 "http exten: \"%V\"", &r->exten); |
661 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
662 if (r->http_version < NGX_HTTP_VERSION_10) { |
537 | 663 |
664 if (rev->timer_set) { | |
665 ngx_del_timer(rev); | |
666 } | |
667 | |
668 #if (NGX_STAT_STUB) | |
561 | 669 ngx_atomic_fetch_add(ngx_stat_reading, -1); |
537 | 670 r->stat_reading = 0; |
561 | 671 ngx_atomic_fetch_add(ngx_stat_writing, 1); |
537 | 672 r->stat_writing = 1; |
673 #endif | |
674 | |
675 rev->handler = ngx_http_request_handler; | |
676 c->write->handler = ngx_http_request_handler; | |
509 | 677 r->read_event_handler = ngx_http_block_read; |
537 | 678 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
679 ngx_http_handler(r); |
537 | 680 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
681 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
682 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
683 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
684 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
685 if (ngx_list_init(&r->headers_in.headers, r->pool, 20, |
581 | 686 sizeof(ngx_table_elt_t)) |
687 == NGX_ERROR) | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
688 { |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
689 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
690 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
691 } |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
692 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
693 |
499 | 694 if (ngx_array_init(&r->headers_in.cookies, r->pool, 2, |
581 | 695 sizeof(ngx_table_elt_t *)) |
696 == NGX_ERROR) | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
697 { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
698 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
699 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
700 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
701 |
483 | 702 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
|
703 |
509 | 704 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
|
705 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
|
706 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
707 return; |
505 | 708 } |
709 | |
710 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
|
711 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
712 /* 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
|
713 |
505 | 714 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
715 ngx_http_client_errors[rc - NGX_HTTP_CLIENT_ERROR]); | |
716 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
717 return; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
718 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
406
diff
changeset
|
719 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
720 /* 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
|
721 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
722 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
|
723 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
724 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
|
725 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
726 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
|
727 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
728 return; |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
729 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
730 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
731 if (rv == NGX_DECLINED) { |
505 | 732 r->request_line.len = r->header_in->end - r->request_start; |
733 r->request_line.data = r->request_start; | |
734 | |
735 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
736 "client sent too long URI"); | |
737 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_URI_TOO_LARGE); | |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
738 return; |
66
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
739 } |
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
740 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
741 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
742 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
743 |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
744 |
501 | 745 static void |
746 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
|
747 { |
507 | 748 ssize_t n; |
749 ngx_int_t rc, rv; | |
750 ngx_str_t header; | |
649 | 751 ngx_uint_t i; |
509 | 752 ngx_table_elt_t *h; |
507 | 753 ngx_connection_t *c; |
754 ngx_http_header_t *hh; | |
755 ngx_http_request_t *r; | |
511 | 756 ngx_http_core_srv_conf_t *cscf; |
507 | 757 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
|
758 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
759 c = rev->data; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
760 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
|
761 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
762 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
|
763 "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
|
764 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
765 if (rev->timedout) { |
505 | 766 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
767 c->timedout = 1; | |
768 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
|
769 return; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
770 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
771 |
507 | 772 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
511 | 773 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
507 | 774 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
775 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
|
776 |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
777 for ( ;; ) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
778 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
779 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
|
780 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
781 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
|
782 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
783 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
|
784 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
785 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
|
786 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
787 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
788 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
789 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
790 if (rv == NGX_DECLINED) { |
505 | 791 header.len = r->header_in->end - r->header_name_start; |
792 header.data = r->header_name_start; | |
531 | 793 |
794 if (header.len > NGX_MAX_ERROR_STR - 300) { | |
795 header.len = NGX_MAX_ERROR_STR - 300; | |
796 header.data[header.len++] = '.'; | |
797 header.data[header.len++] = '.'; | |
798 header.data[header.len++] = '.'; | |
799 } | |
800 | |
505 | 801 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
802 "client sent too long header line: \"%V\"", | |
803 &header); | |
804 ngx_http_close_request(r, NGX_HTTP_BAD_REQUEST); | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
805 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
806 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
807 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
808 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
809 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
|
810 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
811 if (n == NGX_AGAIN || n == NGX_ERROR) { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
812 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
813 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
814 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
815 |
137
2a615b036870
nginx-0.0.1-2003-10-03-19:50:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
135
diff
changeset
|
816 rc = ngx_http_parse_header_line(r, r->header_in); |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
817 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
818 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
|
819 |
511 | 820 if (r->invalid_header && cscf->ignore_invalid_headers) { |
503 | 821 |
822 /* there was error while a header line parsing */ | |
823 | |
824 header.len = r->header_end - r->header_name_start; | |
825 header.data = r->header_name_start; | |
826 | |
505 | 827 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
828 "client sent invalid header line: \"%V\"", | |
503 | 829 &header); |
830 continue; | |
831 } | |
832 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
833 /* 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
|
834 |
501 | 835 h = ngx_list_push(&r->headers_in.headers); |
836 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
|
837 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
838 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
839 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
840 |
507 | 841 h->hash = r->header_hash; |
842 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
843 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
|
844 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
|
845 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
|
846 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
847 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
|
848 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
|
849 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
|
850 |
649 | 851 h->lowcase_key = ngx_palloc(r->pool, h->key.len); |
852 if (h->lowcase_key == NULL) { | |
853 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
854 return; | |
855 } | |
856 | |
857 if (h->key.len == r->lowcase_index) { | |
858 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
859 | |
860 } else { | |
861 for (i = 0; i < h->key.len; i++) { | |
667 | 862 h->lowcase_key[i] = ngx_tolower(h->key.data[i]); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
863 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
864 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
865 |
649 | 866 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, |
867 h->lowcase_key, h->key.len); | |
868 | |
869 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | |
870 return; | |
871 } | |
872 | |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
873 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 874 "http header: \"%V: %V\"", |
875 &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
|
876 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
877 continue; |
505 | 878 } |
879 | |
880 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
|
881 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
882 /* 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
|
883 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
884 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
|
885 "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
|
886 |
475 | 887 r->request_length += r->header_in->pos - r->header_in->start; |
888 | |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
367
diff
changeset
|
889 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
|
890 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
891 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
|
892 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
893 if (rc != NGX_OK) { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
894 return; |
82
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
895 } |
fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
77
diff
changeset
|
896 |
161
88abd07d9f62
nginx-0.0.1-2003-10-27-19:16:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
897 if (rev->timer_set) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
898 ngx_del_timer(rev); |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
899 } |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
900 |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
901 #if (NGX_STAT_STUB) |
561 | 902 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
|
903 r->stat_reading = 0; |
561 | 904 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
|
905 r->stat_writing = 1; |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
906 #endif |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
907 |
509 | 908 rev->handler = ngx_http_request_handler; |
909 c->write->handler = ngx_http_request_handler; | |
910 r->read_event_handler = ngx_http_block_read; | |
911 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
912 ngx_http_handler(r); |
537 | 913 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
914 return; |
505 | 915 } |
916 | |
917 if (rc == NGX_AGAIN) { | |
918 | |
919 /* a header line parsing is still not complete */ | |
920 | |
921 continue; | |
66
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
922 } |
4876cd4a36bb
nginx-0.0.1-2003-03-05-20:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
65
diff
changeset
|
923 |
505 | 924 /* rc == NGX_HTTP_PARSE_INVALID_HEADER: "\r" is not followed by "\n" */ |
925 | |
926 header.len = r->header_end - r->header_name_start; | |
927 header.data = r->header_name_start; | |
928 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
929 "client sent invalid header line: \"%V\\r...\"", | |
930 &header); | |
931 ngx_http_close_request(r, NGX_HTTP_BAD_REQUEST); | |
932 return; | |
19
d7908993fdeb
nginx-0.0.1-2002-12-02-19:09:40 import; resume after 2 months stall
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
933 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
934 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
935 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
23
diff
changeset
|
936 |
501 | 937 static ssize_t |
938 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
|
939 { |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
940 ssize_t n; |
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
941 ngx_event_t *rev; |
681 | 942 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
|
943 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
|
944 |
681 | 945 c = r->connection; |
946 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
|
947 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
948 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
|
949 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
950 if (n > 0) { |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
951 return n; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
952 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
953 |
523 | 954 if (rev->ready) { |
681 | 955 n = c->recv(c, r->header_in->last, |
956 r->header_in->end - r->header_in->last); | |
523 | 957 } else { |
958 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
|
959 } |
c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
960 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
961 if (n == NGX_AGAIN) { |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
962 if (!r->header_timeout_set) { |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
963 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
|
964 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
|
965 r->header_timeout_set = 1; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
966 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
967 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
968 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
969 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
|
970 return NGX_ERROR; |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
971 } |
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
972 |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
973 return NGX_AGAIN; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
974 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
975 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
976 if (n == 0) { |
681 | 977 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
978 "client closed prematurely connection"); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
979 } |
86
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
980 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
981 if (n == 0 || n == NGX_ERROR) { |
991 | 982 c->error = 1; |
992 | 983 c->log->action = "reading client request headers"; |
681 | 984 |
991 | 985 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
|
986 return NGX_ERROR; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
987 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
988 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
989 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
|
990 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
991 return n; |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
992 } |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
993 |
3973260705cc
nginx-0.0.1-2003-05-12-19:52:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
82
diff
changeset
|
994 |
501 | 995 static ngx_int_t |
996 ngx_http_alloc_large_header_buffer(ngx_http_request_t *r, | |
997 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
|
998 { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
999 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
|
1000 ngx_buf_t *b; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1001 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
|
1002 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
|
1003 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1004 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
|
1005 "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
|
1006 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1007 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
|
1008 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1009 /* 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
|
1010 |
475 | 1011 r->request_length += r->header_in->end - r->header_in->start; |
1012 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1013 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
|
1014 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
|
1015 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1016 return NGX_OK; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1017 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1018 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1019 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
|
1020 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1021 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
|
1022 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1023 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
|
1024 && (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
|
1025 >= 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
|
1026 { |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1027 return NGX_DECLINED; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1028 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1029 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1030 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
|
1031 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1032 if (hc->nfree) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1033 b = hc->free[--hc->nfree]; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1034 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1035 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 1036 "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
|
1037 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
|
1038 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1039 } 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
|
1040 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1041 if (hc->busy == NULL) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1042 hc->busy = ngx_palloc(r->connection->pool, |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1043 cscf->large_client_header_buffers.num * sizeof(ngx_buf_t *)); |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1044 if (hc->busy == NULL) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1045 return NGX_ERROR; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1046 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1047 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1048 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1049 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
|
1050 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
|
1051 if (b == NULL) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1052 return NGX_ERROR; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1053 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1054 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1055 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
461 | 1056 "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
|
1057 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
|
1058 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1059 } else { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1060 return NGX_DECLINED; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1061 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1062 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1063 hc->busy[hc->nbusy++] = b; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1064 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1065 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
|
1066 /* |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1067 * 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
|
1068 * 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
|
1069 * 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
|
1070 */ |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1071 |
475 | 1072 r->request_length += r->header_in->end - r->header_in->start; |
1073 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1074 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
|
1075 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1076 return NGX_OK; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1077 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1078 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1079 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1080 "http large header copy: %d", r->header_in->pos - old); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1081 |
475 | 1082 r->request_length += old - r->header_in->start; |
1083 | |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1084 new = b->start; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1085 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1086 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
|
1087 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1088 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
|
1089 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
|
1090 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1091 if (request_line) { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1092 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
|
1093 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1094 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
|
1095 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
|
1096 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1097 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1098 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
|
1099 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1100 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
|
1101 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
|
1102 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1103 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
|
1104 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
|
1105 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
|
1106 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1107 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1108 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
|
1109 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
|
1110 if (r->host_end) { |
a6fe6bedb9e3
fix segfault when $host is used and
Igor Sysoev <igor@sysoev.ru>
parents:
895
diff
changeset
|
1111 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
|
1112 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1113 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1114 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1115 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
|
1116 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
|
1117 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
|
1118 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1119 |
435
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1120 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
|
1121 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
|
1122 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1123 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1124 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
|
1125 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
|
1126 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1127 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1128 } else { |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1129 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
|
1130 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
|
1131 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
|
1132 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
|
1133 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1134 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1135 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
|
1136 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1137 return NGX_OK; |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1138 } |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1139 |
5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1140 |
501 | 1141 static ngx_int_t |
509 | 1142 ngx_http_process_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, |
1143 ngx_uint_t offset) | |
1144 { | |
1145 ngx_table_elt_t **ph; | |
1146 | |
1147 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
1148 | |
1149 if (*ph == NULL) { | |
1150 *ph = h; | |
1151 } | |
1152 | |
1153 return NGX_OK; | |
1154 } | |
1155 | |
1156 | |
1157 static ngx_int_t | |
523 | 1158 ngx_http_process_unique_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, |
1159 ngx_uint_t offset) | |
1160 { | |
1161 ngx_table_elt_t **ph; | |
1162 | |
1163 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
1164 | |
1165 if (*ph == NULL) { | |
1166 *ph = h; | |
1167 return NGX_OK; | |
1168 } | |
1169 | |
1170 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
681 | 1171 "client sent duplicate header line: \"%V: %V\", " |
1172 "previous value: \"%V: %V\"", | |
1173 &h->key, &h->value, &(*ph)->key, &(*ph)->value); | |
523 | 1174 |
1175 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
1176 | |
1177 return NGX_ERROR; | |
1178 } | |
1179 | |
1180 | |
1181 static ngx_int_t | |
509 | 1182 ngx_http_process_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, |
1183 ngx_uint_t offset) | |
1184 { | |
1185 ngx_table_elt_t **cookie; | |
1186 | |
1187 cookie = ngx_array_push(&r->headers_in.cookies); | |
523 | 1188 if (cookie) { |
1189 *cookie = h; | |
1190 return NGX_OK; | |
509 | 1191 } |
1192 | |
523 | 1193 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1194 | |
1195 return NGX_ERROR; | |
509 | 1196 } |
1197 | |
1198 | |
1199 static ngx_int_t | |
501 | 1200 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
|
1201 { |
647 | 1202 size_t len; |
1203 u_char *ua, *user_agent, ch; | |
649 | 1204 ngx_uint_t hash; |
647 | 1205 #if (NGX_HTTP_SSL) |
1206 long rc; | |
1207 ngx_http_ssl_srv_conf_t *sscf; | |
1208 #endif | |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1209 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1210 if (r->headers_in.host) { |
649 | 1211 |
1212 hash = 0; | |
1213 | |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1214 for (len = 0; len < r->headers_in.host->value.len; len++) { |
477 | 1215 ch = r->headers_in.host->value.data[len]; |
1216 | |
1217 if (ch == ':') { | |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1218 break; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1219 } |
477 | 1220 |
649 | 1221 ch = ngx_tolower(ch); |
1222 r->headers_in.host->value.data[len] = ch; | |
1223 hash = ngx_hash(hash, ch); | |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1224 } |
505 | 1225 |
649 | 1226 if (len && r->headers_in.host->value.data[len - 1] == '.') { |
509 | 1227 len--; |
649 | 1228 hash = ngx_hash_key(r->headers_in.host->value.data, len); |
509 | 1229 } |
1230 | |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1231 r->headers_in.host_name_len = len; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1232 |
649 | 1233 if (r->virtual_names) { |
1234 ngx_http_find_virtual_server(r, r->virtual_names, hash); | |
1235 } | |
335
d4241d7787fe
nginx-0.0.3-2004-05-14-20:51:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
331
diff
changeset
|
1236 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1237 } else { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1238 if (r->http_version > NGX_HTTP_VERSION_10) { |
505 | 1239 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1240 "client sent HTTP/1.1 request without \"Host\" header"); | |
1241 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
1242 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
|
1243 } |
505 | 1244 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1245 r->headers_in.host_name_len = 0; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1246 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1247 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1248 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
|
1249 r->headers_in.content_length_n = |
663 | 1250 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
|
1251 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
|
1252 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1253 if (r->headers_in.content_length_n == NGX_ERROR) { |
505 | 1254 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1255 "client sent invalid \"Content-Length\" header"); | |
581 | 1256 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED); |
505 | 1257 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
|
1258 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1259 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1260 |
639 | 1261 if (r->method & (NGX_HTTP_POST|NGX_HTTP_PUT) |
1262 && r->headers_in.content_length_n == -1) | |
1263 { | |
505 | 1264 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1265 "client sent POST method without \"Content-Length\" header"); | |
581 | 1266 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED); |
1267 return NGX_ERROR; | |
1268 } | |
1269 | |
1270 if (r->headers_in.transfer_encoding | |
1271 && ngx_strstr(r->headers_in.transfer_encoding->value.data, "chunked")) | |
1272 { | |
1273 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
1274 "client sent \"Transfer-Encoding: chunked\" header"); | |
1275 ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED); | |
505 | 1276 return NGX_ERROR; |
298
4a3f18406832
nginx-0.0.3-2004-03-30-10:27:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
1277 } |
4a3f18406832
nginx-0.0.3-2004-03-30-10:27:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
1278 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1279 if (r->plain_http) { |
505 | 1280 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1281 "client sent plain HTTP request to HTTPS port"); | |
1282 ngx_http_finalize_request(r, NGX_HTTP_TO_HTTPS); | |
1283 return NGX_ERROR; | |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1284 } |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
1285 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1286 if (r->headers_in.connection) { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1287 if (r->headers_in.connection->value.len == 5 |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1087
diff
changeset
|
1288 && ngx_strcasecmp(r->headers_in.connection->value.data, |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1087
diff
changeset
|
1289 (u_char *) "close") |
509 | 1290 == 0) |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1291 { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1292 r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1293 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1294 } else if (r->headers_in.connection->value.len == 10 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1295 && ngx_strcasecmp(r->headers_in.connection->value.data, |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1087
diff
changeset
|
1296 (u_char *) "keep-alive") |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1087
diff
changeset
|
1297 == 0) |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1298 { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1299 r->headers_in.connection_type = NGX_HTTP_CONNECTION_KEEP_ALIVE; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1300 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1301 if (r->headers_in.keep_alive) { |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1302 r->headers_in.keep_alive_n = |
501 | 1303 ngx_atotm(r->headers_in.keep_alive->value.data, |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1304 r->headers_in.keep_alive->value.len); |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1305 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1306 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1307 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1308 |
356
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1309 if (r->headers_in.user_agent) { |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1310 |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1311 /* |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1312 * check some widespread browsers while the headers are still |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1313 * in CPU cache |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1314 */ |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1315 |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1316 user_agent = r->headers_in.user_agent->value.data; |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1317 |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1318 ua = (u_char *) ngx_strstr(user_agent, "MSIE"); |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1319 |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1320 if (ua && ua + 8 < user_agent + r->headers_in.user_agent->value.len) { |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1321 |
356
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1322 r->headers_in.msie = 1; |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1323 |
356
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1324 if (ua[4] == ' ' && ua[5] == '4' && ua[6] == '.') { |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1325 r->headers_in.msie4 = 1; |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1326 } |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
1327 |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
1328 #if 0 |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
1329 /* MSIE ignores the SSL "close notify" alert */ |
473 | 1330 if (c->ssl) { |
547 | 1331 c->ssl->no_send_shutdown = 1; |
473 | 1332 } |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
395
diff
changeset
|
1333 #endif |
356
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1334 } |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
1335 |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1336 if (ngx_strstr(user_agent, "Opera")) { |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
1337 r->headers_in.opera = 1; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
1338 r->headers_in.msie = 0; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
1339 r->headers_in.msie4 = 0; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
1340 } |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1341 |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1342 if (!r->headers_in.msie && !r->headers_in.opera) { |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1343 |
430
1fa5daf7558e
nginx-0.0.11-2004-09-19-22:27:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
1344 if (ngx_strstr(user_agent, "Gecko/")) { |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1345 r->headers_in.gecko = 1; |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1346 |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1347 } else if (ngx_strstr(user_agent, "Konqueror")) { |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1348 r->headers_in.konqueror = 1; |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1349 } |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1350 } |
356
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1351 } |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
1352 |
669 | 1353 #if (NGX_HTTP_SSL) |
1354 | |
1355 if (r->connection->ssl) { | |
1356 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); | |
1357 | |
1358 if (sscf->verify) { | |
1359 rc = SSL_get_verify_result(r->connection->ssl->connection); | |
1360 | |
1361 if (rc != X509_V_OK) { | |
1362 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
671 | 1363 "client SSL certificate verify error: (%l:%s)", |
669 | 1364 rc, X509_verify_cert_error_string(rc)); |
1365 ngx_http_finalize_request(r, NGX_HTTPS_CERT_ERROR); | |
1366 return NGX_ERROR; | |
1367 } | |
1368 | |
1369 if (SSL_get_peer_certificate(r->connection->ssl->connection) | |
1370 == NULL) | |
1371 { | |
1372 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
1373 "client sent no required SSL certificate"); | |
1374 ngx_http_finalize_request(r, NGX_HTTPS_NO_CERT); | |
1375 return NGX_ERROR; | |
1376 } | |
1377 } | |
1378 } | |
1379 | |
1380 #endif | |
1381 | |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1382 return NGX_OK; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1383 } |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1384 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
1385 |
613 | 1386 static void |
649 | 1387 ngx_http_find_virtual_server(ngx_http_request_t *r, |
1388 ngx_http_virtual_names_t *vn, ngx_uint_t hash) | |
477 | 1389 { |
593 | 1390 size_t len; |
1391 u_char *host; | |
1392 ngx_http_core_loc_conf_t *clcf; | |
1393 ngx_http_core_srv_conf_t *cscf; | |
1394 | |
864 | 1395 host = r->host_start; |
1396 | |
1397 if (host == NULL) { | |
1398 host = r->headers_in.host->value.data; | |
1399 len = r->headers_in.host_name_len; | |
1400 | |
1401 } else { | |
1402 len = r->host_end - host; | |
1403 } | |
593 | 1404 |
1405 if (vn->hash.buckets) { | |
649 | 1406 cscf = ngx_hash_find(&vn->hash, hash, host, len); |
593 | 1407 if (cscf) { |
509 | 1408 goto found; |
477 | 1409 } |
1410 } | |
1411 | |
593 | 1412 if (vn->dns_wildcards && vn->dns_wildcards->hash.buckets) { |
1413 cscf = ngx_hash_find_wildcard(vn->dns_wildcards, host, len); | |
1414 | |
1415 if (cscf) { | |
1416 goto found; | |
477 | 1417 } |
1418 } | |
1419 | |
663 | 1420 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
1421 | |
1422 if (cscf->wildcard) { | |
1423 r->server_name.len = len; | |
1424 r->server_name.data = host; | |
1425 } | |
1426 | |
613 | 1427 return; |
509 | 1428 |
1429 found: | |
1430 | |
593 | 1431 r->server_name.len = len; |
1432 r->server_name.data = host; | |
1433 | |
1434 r->srv_conf = cscf->ctx->srv_conf; | |
1435 r->loc_conf = cscf->ctx->loc_conf; | |
509 | 1436 |
1437 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
1438 r->connection->log->file = clcf->err_log->file; | |
1439 | |
1440 if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { | |
1441 r->connection->log->log_level = clcf->err_log->log_level; | |
477 | 1442 } |
1443 | |
613 | 1444 return; |
477 | 1445 } |
1446 | |
1447 | |
509 | 1448 static void |
1449 ngx_http_request_handler(ngx_event_t *ev) | |
1450 { | |
1451 ngx_connection_t *c; | |
1452 ngx_http_request_t *r; | |
665 | 1453 ngx_http_log_ctx_t *ctx; |
509 | 1454 |
1455 c = ev->data; | |
1456 r = c->data; | |
1457 | |
665 | 1458 ctx = c->log->data; |
1459 ctx->current_request = r; | |
1460 | |
509 | 1461 if (ev->write) { |
1462 r->write_event_handler(r); | |
1463 | |
1464 } else { | |
1465 r->read_event_handler(r); | |
1466 } | |
1467 } | |
1468 | |
1469 | |
501 | 1470 void |
509 | 1471 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
|
1472 { |
509 | 1473 ngx_http_request_t *pr; |
665 | 1474 ngx_http_log_ctx_t *ctx; |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
1475 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
|
1476 |
509 | 1477 if (rc == NGX_DONE) { |
569 | 1478 /* the request pool may be already destroyed */ |
509 | 1479 return; |
1480 } | |
1481 | |
583 | 1482 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1483 "http finalize request: %d, \"%V?%V\"", | |
1484 rc, &r->uri, &r->args); | |
1485 | |
681 | 1486 if (rc == NGX_DECLINED) { |
1487 r->content_handler = NULL; | |
1488 r->write_event_handler = ngx_http_core_run_phases; | |
1489 ngx_http_core_run_phases(r); | |
1490 return; | |
1491 } | |
1492 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
716
diff
changeset
|
1493 if (r != r->main && r->post_subrequest) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
716
diff
changeset
|
1494 rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc); |
667 | 1495 } |
1496 | |
613 | 1497 if (rc == NGX_ERROR |
1498 || rc == NGX_HTTP_REQUEST_TIME_OUT | |
1499 || r->connection->error) | |
1500 { | |
1087
9de12c8d8943
log a real response error code instead of "0"
Igor Sysoev <igor@sysoev.ru>
parents:
1061
diff
changeset
|
1501 if (rc > 0 && r->headers_out.status == 0) { |
9de12c8d8943
log a real response error code instead of "0"
Igor Sysoev <igor@sysoev.ru>
parents:
1061
diff
changeset
|
1502 r->headers_out.status = rc; |
641 | 1503 } |
1504 | |
613 | 1505 if (ngx_http_post_action(r) == NGX_OK) { |
1506 return; | |
1507 } | |
1508 | |
569 | 1509 ngx_http_close_request(r, 0); |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
1510 return; |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
1511 } |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
1512 |
637 | 1513 if (rc >= NGX_HTTP_SPECIAL_RESPONSE |
1514 || rc == NGX_HTTP_CREATED | |
1515 || rc == NGX_HTTP_NO_CONTENT) | |
1516 { | |
587 | 1517 if (rc == NGX_HTTP_CLOSE) { |
1518 ngx_http_close_request(r, rc); | |
1519 return; | |
1520 } | |
1521 | |
597 | 1522 if (r == r->main) { |
569 | 1523 if (r->connection->read->timer_set) { |
1524 ngx_del_timer(r->connection->read); | |
1525 } | |
1526 | |
1527 if (r->connection->write->timer_set) { | |
1528 ngx_del_timer(r->connection->write); | |
1529 } | |
1530 } | |
1531 | |
1532 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); | |
1533 return; | |
1534 } | |
1535 | |
597 | 1536 if (r != r->main || rc == NGX_AGAIN) { |
525 | 1537 if (ngx_http_set_write_handler(r) != NGX_OK) { |
1538 return; | |
1539 } | |
509 | 1540 } |
1541 | |
1542 r->done = 1; | |
1543 | |
1544 if (r != r->connection->data) { | |
583 | 1545 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1546 "http finalize non-active request: \"%V?%V\"", | |
1547 &r->uri, &r->args); | |
509 | 1548 return; |
1549 } | |
1550 | |
597 | 1551 if (r != r->main) { |
509 | 1552 |
1553 pr = r->parent; | |
1554 | |
583 | 1555 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1556 "http parent request: \"%V?%V\"", &pr->uri, &pr->args); | |
527 | 1557 |
509 | 1558 if (rc != NGX_AGAIN) { |
597 | 1559 r->connection->data = pr; |
509 | 1560 } |
1561 | |
665 | 1562 ctx = r->connection->log->data; |
1563 ctx->current_request = pr; | |
1564 | |
509 | 1565 if (pr->postponed) { |
1566 | |
583 | 1567 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1568 "http request: \"%V?%V\" has postponed", | |
1569 &pr->uri, &pr->args); | |
527 | 1570 |
509 | 1571 if (rc != NGX_AGAIN && pr->postponed->request == r) { |
1572 pr->postponed = pr->postponed->next; | |
597 | 1573 } |
1574 | |
1575 if (r->fast_subrequest) { | |
645 | 1576 |
1577 if (rc == NGX_AGAIN) { | |
1578 r->fast_subrequest = 0; | |
1579 } | |
1580 | |
597 | 1581 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1582 "http fast subrequest: \"%V?%V\" done", | |
1583 &r->uri, &r->args); | |
1584 return; | |
509 | 1585 } |
1586 | |
645 | 1587 if (rc != NGX_AGAIN) { |
1588 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1589 "http wake parent request: \"%V?%V\"", | |
1590 &pr->uri, &pr->args); | |
1591 | |
1592 pr->write_event_handler(pr); | |
1593 } | |
509 | 1594 } |
1595 | |
1596 return; | |
1597 } | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
1598 |
569 | 1599 if (rc == NGX_AGAIN) { |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
1600 return; |
527 | 1601 } |
1602 | |
597 | 1603 if (r->connection->buffered) { |
525 | 1604 (void) ngx_http_set_write_handler(r); |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
1605 return; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1606 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1607 |
629 | 1608 if (!r->post_action) { |
1609 r->request_complete = 1; | |
1610 } | |
1611 | |
613 | 1612 if (ngx_http_post_action(r) == NGX_OK) { |
577 | 1613 return; |
1614 } | |
1615 | |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
1616 if (r->connection->read->timer_set) { |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
1617 ngx_del_timer(r->connection->read); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1618 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1619 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
1620 if (r->connection->write->timer_set) { |
369
9c2515d70489
nginx-0.0.7-2004-06-25-18:42:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1621 r->connection->write->delayed = 0; |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
1622 ngx_del_timer(r->connection->write); |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1623 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1624 |
589 | 1625 if (r->connection->destroyed) { |
1626 return; | |
1627 } | |
1628 | |
613 | 1629 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
216
diff
changeset
|
1630 |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1631 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
|
1632 && !ngx_exiting |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1633 && r->keepalive != 0 |
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1634 && 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
|
1635 { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1636 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
|
1637 return; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1638 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
1639 } else if (r->lingering_close && clcf->lingering_timeout > 0) { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1640 ngx_http_set_lingering_close(r); |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1641 return; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1642 } |
142
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
1643 |
230
1119faf4635a
nginx-0.0.1-2004-01-16-09:15:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1644 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
|
1645 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1646 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1647 |
525 | 1648 static ngx_int_t |
501 | 1649 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
|
1650 { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1651 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
|
1652 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
|
1653 |
509 | 1654 r->http_state = NGX_HTTP_WRITING_REQUEST_STATE; |
1655 | |
1110
82da2c898923
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
1656 r->read_event_handler = ngx_http_block_read; |
525 | 1657 r->write_event_handler = ngx_http_writer; |
1658 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1659 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
|
1660 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
1661 if (wev->ready && wev->delayed) { |
525 | 1662 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
|
1663 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1664 |
509 | 1665 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
|
1666 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
|
1667 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
|
1668 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1669 |
452 | 1670 if (ngx_handle_write_event(wev, clcf->send_lowat) == NGX_ERROR) { |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
1671 ngx_http_close_request(r, 0); |
525 | 1672 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
|
1673 } |
525 | 1674 |
1675 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
|
1676 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1677 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1678 |
509 | 1679 static void |
1680 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
|
1681 { |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1682 int rc; |
509 | 1683 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
|
1684 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
|
1685 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
|
1686 |
509 | 1687 c = r->connection; |
1688 wev = c->write; | |
1689 | |
583 | 1690 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
1691 "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
|
1692 |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1693 if (wev->timedout) { |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
1694 if (!wev->delayed) { |
505 | 1695 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, |
1696 "client timed out"); | |
1697 c->timedout = 1; | |
567 | 1698 |
613 | 1699 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT); |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1700 return; |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1701 } |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1702 |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1703 wev->timedout = 0; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
1704 wev->delayed = 0; |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1705 |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1706 if (!wev->ready) { |
553 | 1707 clcf = ngx_http_get_module_loc_conf(r->main, ngx_http_core_module); |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1708 ngx_add_timer(wev, clcf->send_timeout); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
1709 |
452 | 1710 if (ngx_handle_write_event(wev, clcf->send_lowat) == NGX_ERROR) { |
569 | 1711 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
|
1712 } |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1713 |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1714 return; |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1715 } |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1716 |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1717 } else { |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
1718 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
|
1719 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1720 "http writer delayed"); |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
1721 |
553 | 1722 clcf = ngx_http_get_module_loc_conf(r->main, ngx_http_core_module); |
452 | 1723 |
1724 if (ngx_handle_write_event(wev, clcf->send_lowat) == NGX_ERROR) { | |
569 | 1725 ngx_http_close_request(r, 0); |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
1726 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
361
diff
changeset
|
1727 |
361
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1728 return; |
446782c909b3
nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
1729 } |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
1730 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
159
diff
changeset
|
1731 |
583 | 1732 rc = ngx_http_output_filter(r, NULL); |
1733 | |
1734 if (c->destroyed) { | |
1735 return; | |
509 | 1736 } |
1737 | |
583 | 1738 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1739 "http writer output filter: %d, \"%V?%V\"", | |
1740 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
|
1741 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1742 if (rc == NGX_AGAIN) { |
553 | 1743 clcf = ngx_http_get_module_loc_conf(r->main, 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
|
1744 if (!wev->ready && !wev->delayed) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
1745 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
|
1746 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1747 |
452 | 1748 if (ngx_handle_write_event(wev, clcf->send_lowat) == NGX_ERROR) { |
569 | 1749 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
|
1750 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1751 |
829
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
777
diff
changeset
|
1752 if (r == r->main || r->buffered) { |
597 | 1753 return; |
1754 } | |
1755 | |
1756 rc = NGX_OK; | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1757 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1758 |
583 | 1759 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, wev->log, 0, |
1760 "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
|
1761 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
1762 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
|
1763 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1764 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1765 |
501 | 1766 static void |
509 | 1767 ngx_http_block_read(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
|
1768 { |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1769 int n; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1770 char buf[1]; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1771 ngx_err_t err; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1772 ngx_event_t *rev; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1773 ngx_connection_t *c; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1774 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1775 c = r->connection; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1776 rev = c->read; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1777 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1778 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http read blocked"); |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1779 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1780 #if (NGX_HAVE_KQUEUE) |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1781 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1782 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
|
1783 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1784 if (!rev->pending_eof) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1785 return; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1786 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1787 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1788 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1789 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1790 err = rev->kq_errno; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1791 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1792 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1793 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1794 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1795 #endif |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1796 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1797 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
|
1798 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1799 if (n == 0) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1800 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1801 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1802 err = 0; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1803 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1804 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1805 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1806 } else if (n == -1) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1807 err = ngx_socket_errno; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1808 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1809 if (err != NGX_EAGAIN) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1810 rev->eof = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1811 c->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1812 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1813 goto closed; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1814 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1815 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
1816 |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
1817 /* 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
|
1818 |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1819 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
|
1820 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1821 if (ngx_del_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) { |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
1822 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
|
1823 } |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
57
diff
changeset
|
1824 } |
1061
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1825 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1826 return; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1827 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1828 closed: |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1829 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1830 if (err) { |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1831 rev->error = 1; |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1832 } |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1833 |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1834 ngx_log_error(NGX_LOG_INFO, c->log, err, |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1835 "client closed prematurely connection"); |
9aca452fe12a
if client closes a connection prematurely, then epoll (at least
Igor Sysoev <igor@sysoev.ru>
parents:
1059
diff
changeset
|
1836 |
1115
f07a5f4017d9
finalize request to allow post_action
Igor Sysoev <igor@sysoev.ru>
parents:
1110
diff
changeset
|
1837 ngx_http_finalize_request(r, 0); |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
1838 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
1839 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
1840 |
501 | 1841 static void |
1842 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
|
1843 { |
452 | 1844 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
|
1845 ngx_int_t i; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1846 ngx_buf_t *b, *f; |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
1847 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
|
1848 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
|
1849 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
|
1850 ngx_http_core_srv_conf_t *cscf; |
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
94
diff
changeset
|
1851 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
|
1852 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
1853 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
|
1854 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
|
1855 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
1856 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
|
1857 |
483 | 1858 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
|
1859 |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
1860 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
|
1861 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
|
1862 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1863 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
|
1864 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1865 /* 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
|
1866 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1867 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
|
1868 |
455 | 1869 /* |
1870 * If the large header buffers were allocated while the previous | |
1871 * request processing then we do not use c->buffer for | |
1872 * the pipelined request (see ngx_http_init_request()). | |
577 | 1873 * |
455 | 1874 * Now we would move the large header buffers to the free list. |
1875 */ | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1876 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1877 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1878 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1879 if (hc->free == NULL) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1880 hc->free = ngx_palloc(c->pool, |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1881 cscf->large_client_header_buffers.num * sizeof(ngx_buf_t *)); |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1882 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1883 if (hc->free == NULL) { |
477 | 1884 ngx_http_close_request(r, 0); |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1885 return; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1886 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1887 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1888 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1889 for (i = 0; i < hc->nbusy - 1; i++) { |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1890 f = hc->busy[i]; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1891 hc->free[hc->nfree++] = f; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1892 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
|
1893 f->last = f->start; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1894 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1895 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1896 hc->busy[0] = b; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1897 hc->nbusy = 1; |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1898 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1899 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1900 |
477 | 1901 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
1902 | |
569 | 1903 ngx_http_request_done(r, 0); |
1904 | |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
1905 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
|
1906 |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
1907 ngx_add_timer(rev, clcf->keepalive_timeout); |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
1908 |
509 | 1909 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
1910 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
|
1911 return; |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
1912 } |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
1913 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
1914 wev = c->write; |
509 | 1915 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
|
1916 |
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
|
1917 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
|
1918 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
1919 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
|
1920 |
567 | 1921 #if (NGX_STAT_STUB) |
1922 ngx_atomic_fetch_add(ngx_stat_reading, 1); | |
1923 #endif | |
1924 | |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
1925 hc->pipeline = 1; |
483 | 1926 c->log->action = "reading client pipelined request line"; |
567 | 1927 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1928 ngx_http_init_request(rev); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
1929 return; |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
1930 } |
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
1931 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
1932 hc->pipeline = 0; |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
1933 |
455 | 1934 /* |
1935 * To keep a memory footprint as small as possible for an idle | |
1936 * keepalive connection we try to free the ngx_http_request_t and | |
1937 * c->buffer's memory if they were allocated outside the c->pool. | |
1938 * The large header buffers are always allocated outside the c->pool and | |
1939 * are freed too. | |
1940 */ | |
1941 | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1942 if (ngx_pfree(c->pool, r) == NGX_OK) { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1943 hc->request = NULL; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1944 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1945 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1946 b = c->buffer; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1947 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1948 if (ngx_pfree(c->pool, b->start) == NGX_OK) { |
455 | 1949 |
1950 /* | |
1951 * the special note for ngx_http_keepalive_handler() that | |
1952 * c->buffer's memory was freed | |
1953 */ | |
1954 | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1955 b->pos = NULL; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1956 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1957 } else { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1958 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
|
1959 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
|
1960 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1961 |
461 | 1962 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc free: %p %d", |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1963 hc->free, hc->nfree); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1964 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1965 if (hc->free) { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1966 for (i = 0; i < hc->nfree; i++) { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1967 ngx_pfree(c->pool, hc->free[i]); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1968 hc->free[i] = NULL; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1969 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1970 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1971 hc->nfree = 0; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1972 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1973 |
461 | 1974 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc busy: %p %d", |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1975 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
|
1976 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1977 if (hc->busy) { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1978 for (i = 0; i < hc->nbusy; i++) { |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1979 ngx_pfree(c->pool, hc->busy[i]); |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1980 hc->busy[i] = NULL; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1981 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1982 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1983 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
|
1984 } |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
1985 |
509 | 1986 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
|
1987 |
583 | 1988 if (wev->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) { |
1989 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) { | |
1990 ngx_http_close_connection(c); | |
1991 return; | |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
1992 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
1993 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
1994 |
483 | 1995 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
|
1996 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
1997 if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) { |
501 | 1998 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
|
1999 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
|
2000 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
|
2001 return; |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
2002 } |
452 | 2003 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
2004 c->tcp_nopush = NGX_TCP_NOPUSH_UNSET; |
473 | 2005 tcp_nodelay = ngx_tcp_nodelay_and_tcp_nopush ? 1 : 0; |
452 | 2006 |
2007 } else { | |
473 | 2008 tcp_nodelay = 1; |
2009 } | |
2010 | |
483 | 2011 if (tcp_nodelay |
2012 && clcf->tcp_nodelay | |
2013 && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) | |
2014 { | |
473 | 2015 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay"); |
2016 | |
2017 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, | |
635 | 2018 (const void *) &tcp_nodelay, sizeof(int)) |
2019 == -1) | |
473 | 2020 { |
2021 ngx_connection_error(c, ngx_socket_errno, | |
2022 "setsockopt(TCP_NODELAY) failed"); | |
2023 ngx_http_close_connection(c); | |
2024 return; | |
452 | 2025 } |
473 | 2026 |
483 | 2027 c->tcp_nodelay = NGX_TCP_NODELAY_SET; |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
2028 } |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
2029 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2030 #if 0 |
455 | 2031 /* 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
|
2032 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
|
2033 #endif |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
2034 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
2035 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
|
2036 ngx_http_keepalive_handler(rev); |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
2037 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2038 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2039 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2040 |
501 | 2041 static void |
2042 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
|
2043 { |
501 | 2044 size_t size; |
2045 ssize_t n; | |
2046 ngx_buf_t *b; | |
2047 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
|
2048 |
394
e7a68e14ccd3
nginx-0.0.7-2004-07-16-10:33:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
2049 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
|
2050 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
2051 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
|
2052 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2053 if (rev->timedout) { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2054 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
|
2055 return; |
68
d549fdc17d7e
nginx-0.0.1-2003-03-12-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
2056 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
2057 |
469 | 2058 #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
|
2059 |
455 | 2060 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { |
587 | 2061 if (rev->pending_eof) { |
483 | 2062 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
|
2063 ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno, |
461 | 2064 "kevent() reported that client %V closed " |
483 | 2065 "keepalive connection", &c->addr_text); |
473 | 2066 #if (NGX_HTTP_SSL) |
2067 if (c->ssl) { | |
547 | 2068 c->ssl->no_send_shutdown = 1; |
473 | 2069 } |
2070 #endif | |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2071 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
|
2072 return; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2073 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2074 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2075 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2076 #endif |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2077 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2078 b = c->buffer; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2079 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
|
2080 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2081 if (b->pos == NULL) { |
455 | 2082 |
2083 /* | |
2084 * The c->buffer's memory was freed by ngx_http_set_keepalive(). | |
2085 * However, the c->buffer->start and c->buffer->end were not changed | |
2086 * to keep the buffer size. | |
2087 */ | |
2088 | |
501 | 2089 b->pos = ngx_palloc(c->pool, size); |
2090 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
|
2091 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
|
2092 return; |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2093 } |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2094 |
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2095 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
|
2096 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
|
2097 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
|
2098 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2099 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2100 /* |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2101 * 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
|
2102 * 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
|
2103 */ |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
2104 |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
2105 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
|
2106 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
|
2107 |
437
470270fa84d2
nginx-0.0.12-2004-09-23-20:39:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
2108 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
|
2109 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
|
2110 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2111 if (n == NGX_AGAIN) { |
509 | 2112 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { |
475 | 2113 ngx_http_close_connection(c); |
2114 } | |
2115 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2116 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2117 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2118 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2119 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
|
2120 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
|
2121 return; |
68
d549fdc17d7e
nginx-0.0.1-2003-03-12-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
2122 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
2123 |
483 | 2124 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
|
2125 |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
2126 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
|
2127 ngx_log_error(NGX_LOG_INFO, c->log, ngx_socket_errno, |
483 | 2128 "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
|
2129 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
|
2130 return; |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
2131 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
2132 |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2133 b->last += n; |
483 | 2134 |
567 | 2135 #if (NGX_STAT_STUB) |
2136 ngx_atomic_fetch_add(ngx_stat_reading, 1); | |
2137 #endif | |
2138 | |
483 | 2139 c->log->handler = ngx_http_log_error; |
2140 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
|
2141 |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2142 ngx_http_init_request(rev); |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
2143 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
2144 |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
2145 |
501 | 2146 static void |
2147 ngx_http_set_lingering_close(ngx_http_request_t *r) | |
577 | 2148 { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2149 ngx_event_t *rev, *wev; |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
2150 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
|
2151 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
|
2152 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2153 c = r->connection; |
53
d1e42f1b8fd4
nginx-0.0.1-2003-01-27-00:08:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
52
diff
changeset
|
2154 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
2155 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
|
2156 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2157 rev = c->read; |
509 | 2158 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
|
2159 |
557 | 2160 r->lingering_time = ngx_time() + (time_t) (clcf->lingering_time / 1000); |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2161 ngx_add_timer(rev, clcf->lingering_timeout); |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2162 |
509 | 2163 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2164 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
|
2165 return; |
53
d1e42f1b8fd4
nginx-0.0.1-2003-01-27-00:08:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
52
diff
changeset
|
2166 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2167 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
2168 wev = c->write; |
509 | 2169 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
|
2170 |
583 | 2171 if (wev->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) { |
2172 if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) { | |
2173 ngx_http_close_request(r, 0); | |
2174 return; | |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
2175 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2176 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2177 |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
2178 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
|
2179 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
|
2180 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
|
2181 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
|
2182 return; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
2183 } |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
66
diff
changeset
|
2184 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
2185 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
|
2186 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
|
2187 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2188 } |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2189 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
2190 |
501 | 2191 static void |
2192 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
|
2193 { |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2194 ssize_t n; |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2195 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
|
2196 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
|
2197 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
|
2198 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
|
2199 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
|
2200 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
2201 c = rev->data; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
2202 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
|
2203 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
2204 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
|
2205 "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
|
2206 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2207 if (rev->timedout) { |
577 | 2208 c->timedout = 1; |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2209 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
|
2210 return; |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
2211 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
2212 |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
369
diff
changeset
|
2213 timer = r->lingering_time - ngx_time(); |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
2214 if (timer <= 0) { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2215 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
|
2216 return; |
38
2ffaa35fba42
nginx-0.0.1-2002-12-24-10:09:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
37
diff
changeset
|
2217 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
2218 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2219 do { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2220 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
|
2221 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
2222 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "lingering read: %d", n); |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
2223 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2224 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
|
2225 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
|
2226 return; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2227 } |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2228 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2229 } 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
|
2230 |
509 | 2231 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { |
477 | 2232 ngx_http_close_request(r, 0); |
475 | 2233 return; |
2234 } | |
2235 | |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2236 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
|
2237 |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
12
diff
changeset
|
2238 timer *= 1000; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
435
diff
changeset
|
2239 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
2240 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
|
2241 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
|
2242 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
2243 |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2244 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
|
2245 } |
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
2246 |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
2247 |
501 | 2248 void |
2249 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
|
2250 { |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
2251 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
|
2252 |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
2253 return; |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
2254 } |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
2255 |
8220378432a8
nginx-0.0.1-2003-05-22-19:23:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
2256 |
509 | 2257 void |
2258 ngx_http_request_empty_handler(ngx_http_request_t *r) | |
2259 { | |
2260 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
583 | 2261 "http request empty handler"); |
509 | 2262 |
2263 return; | |
2264 } | |
2265 | |
2266 | |
501 | 2267 ngx_int_t |
581 | 2268 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
|
2269 { |
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
|
2270 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
|
2271 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
|
2272 |
501 | 2273 b = ngx_calloc_buf(r->pool); |
2274 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
|
2275 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
|
2276 } |
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
|
2277 |
581 | 2278 if (flags & NGX_HTTP_LAST) { |
2279 b->last_buf = 1; | |
2280 } | |
2281 | |
2282 if (flags & NGX_HTTP_FLUSH) { | |
2283 b->flush = 1; | |
2284 } | |
2285 | |
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
|
2286 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
|
2287 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
|
2288 |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
152
diff
changeset
|
2289 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
|
2290 } |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2291 |
cb77c084acdb
nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
137
diff
changeset
|
2292 |
613 | 2293 static ngx_int_t |
2294 ngx_http_post_action(ngx_http_request_t *r) | |
2295 { | |
2296 ngx_http_core_loc_conf_t *clcf; | |
2297 | |
2298 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
2299 | |
2300 if (clcf->post_action.data == NULL) { | |
2301 return NGX_DECLINED; | |
2302 } | |
2303 | |
623 | 2304 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2305 "post action: \"%V\"", &clcf->post_action); | |
2306 | |
613 | 2307 r->http_version = NGX_HTTP_VERSION_9; |
2308 r->header_only = 1; | |
629 | 2309 r->post_action = 1; |
613 | 2310 |
895
49d03c183ad2
fix post_action for disconnected client
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
2311 r->read_event_handler = ngx_http_block_read; |
49d03c183ad2
fix post_action for disconnected client
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
2312 |
613 | 2313 ngx_http_internal_redirect(r, &clcf->post_action, NULL); |
2314 | |
2315 return NGX_OK; | |
2316 } | |
2317 | |
2318 | |
2319 static void | |
509 | 2320 ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error) |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2321 { |
639 | 2322 ngx_connection_t *c; |
569 | 2323 |
2324 c = r->connection; | |
639 | 2325 |
2326 ngx_http_request_done(r->main, error); | |
569 | 2327 ngx_http_close_connection(c); |
2328 } | |
2329 | |
2330 | |
613 | 2331 static void |
569 | 2332 ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error) |
2333 { | |
2334 ngx_log_t *log; | |
581 | 2335 ngx_uint_t i, n; |
569 | 2336 struct linger linger; |
639 | 2337 ngx_http_cleanup_t *cln; |
569 | 2338 ngx_http_log_ctx_t *ctx; |
581 | 2339 ngx_http_handler_pt *log_handler; |
569 | 2340 ngx_http_core_loc_conf_t *clcf; |
2341 ngx_http_core_main_conf_t *cmcf; | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2342 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
2343 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
|
2344 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
2345 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
|
2346 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2347 if (r->pool == NULL) { |
531 | 2348 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
|
2349 return; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2350 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2351 |
639 | 2352 for (cln = r->cleanup; cln; cln = cln->next) { |
2353 if (cln->handler) { | |
2354 cln->handler(cln->data); | |
2355 } | |
2356 } | |
2357 | |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
2358 #if (NGX_STAT_STUB) |
567 | 2359 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
2360 if (r->stat_reading) { |
561 | 2361 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
|
2362 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
2363 |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
2364 if (r->stat_writing) { |
561 | 2365 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
|
2366 } |
567 | 2367 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
2368 #endif |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
426
diff
changeset
|
2369 |
214
e0c502f15852
nginx-0.0.1-2003-12-22-12:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
2370 if (error && r->headers_out.status == 0) { |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2371 r->headers_out.status = error; |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2372 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2373 |
569 | 2374 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
2375 | |
581 | 2376 log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts; |
2377 n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts; | |
2378 for (i = 0; i < n; i++) { | |
2379 log_handler[i](r); | |
569 | 2380 } |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2381 |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
2382 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
|
2383 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
|
2384 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
2385 if (clcf->reset_timedout_connection) { |
509 | 2386 linger.l_onoff = 1; |
2387 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
|
2388 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
2389 if (setsockopt(r->connection->fd, SOL_SOCKET, SO_LINGER, |
509 | 2390 (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
|
2391 { |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
2392 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
|
2393 "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
|
2394 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
2395 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
2396 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
2397 |
509 | 2398 /* 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
|
2399 ctx = log->data; |
461 | 2400 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
|
2401 |
367
ceec87d1c2b3
nginx-0.0.7-2004-06-24-11:53:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
2402 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
|
2403 |
583 | 2404 r->connection->destroyed = 1; |
2405 | |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2406 ngx_destroy_pool(r->pool); |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2407 } |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2408 |
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
2409 |
531 | 2410 static void |
501 | 2411 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
|
2412 { |
479 | 2413 ngx_pool_t *pool; |
2414 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
233
diff
changeset
|
2415 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
|
2416 "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
|
2417 |
539 | 2418 #if (NGX_HTTP_SSL) |
452 | 2419 |
2420 if (c->ssl) { | |
2421 if (ngx_ssl_shutdown(c) == NGX_AGAIN) { | |
577 | 2422 c->ssl->handler = ngx_http_close_connection; |
452 | 2423 return; |
2424 } | |
2425 } | |
2426 | |
2427 #endif | |
2428 | |
426
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
2429 #if (NGX_STAT_STUB) |
561 | 2430 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
|
2431 #endif |
3f88935a02e8
nginx-0.0.10-2004-09-14-23:39:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
2432 |
583 | 2433 c->destroyed = 1; |
2434 | |
479 | 2435 pool = c->pool; |
2436 | |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
416
diff
changeset
|
2437 ngx_close_connection(c); |
479 | 2438 |
501 | 2439 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
|
2440 } |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
2441 |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
2442 |
501 | 2443 static u_char * |
2444 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
|
2445 { |
483 | 2446 u_char *p; |
505 | 2447 ngx_http_request_t *r; |
483 | 2448 ngx_http_log_ctx_t *ctx; |
461 | 2449 |
483 | 2450 if (log->action) { |
509 | 2451 p = ngx_snprintf(buf, len, " while %s", log->action); |
461 | 2452 len -= p - buf; |
505 | 2453 buf = p; |
461 | 2454 } |
2455 | |
509 | 2456 ctx = log->data; |
2457 | |
505 | 2458 p = ngx_snprintf(buf, len, ", client: %V", ctx->client); |
509 | 2459 len -= p - buf; |
505 | 2460 |
2461 r = ctx->request; | |
2462 | |
509 | 2463 if (r) { |
665 | 2464 return r->log_handler(r, ctx->current_request, p, len); |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
68
diff
changeset
|
2465 } |
461 | 2466 |
509 | 2467 return p; |
2468 } | |
2469 | |
2470 | |
2471 static u_char * | |
665 | 2472 ngx_http_log_error_handler(ngx_http_request_t *r, ngx_http_request_t *sr, |
2473 u_char *buf, size_t len) | |
509 | 2474 { |
884 | 2475 char *uri_separator; |
2476 u_char *p; | |
2477 ngx_http_upstream_t *u; | |
505 | 2478 |
2479 if (r->server_name.data) { | |
2480 p = ngx_snprintf(buf, len, ", server: %V", &r->server_name); | |
503 | 2481 len -= p - buf; |
505 | 2482 buf = p; |
503 | 2483 } |
2484 | |
505 | 2485 if (r->unparsed_uri.data) { |
2486 p = ngx_snprintf(buf, len, ", URL: \"%V\"", &r->unparsed_uri); | |
2487 len -= p - buf; | |
2488 buf = p; | |
2489 | |
2490 } else { | |
2491 if (r->request_line.data == NULL && r->request_start) { | |
2492 for (p = r->request_start; p < r->header_in->last; p++) { | |
2493 if (*p == CR || *p == LF) { | |
2494 break; | |
2495 } | |
2496 } | |
2497 | |
2498 r->request_line.len = p - r->request_start; | |
2499 r->request_line.data = r->request_start; | |
2500 } | |
2501 | |
2502 if (r->request_line.len) { | |
2503 p = ngx_snprintf(buf, len, ", request: \"%V\"", &r->request_line); | |
2504 len -= p - buf; | |
2505 buf = p; | |
2506 } | |
461 | 2507 } |
2508 | |
665 | 2509 if (r != sr) { |
2510 p = ngx_snprintf(buf, len, ", subrequest: \"%V\"", &sr->uri); | |
2511 len -= p - buf; | |
2512 buf = p; | |
2513 } | |
2514 | |
2515 u = sr->upstream; | |
2516 | |
884 | 2517 if (u && u->peer.name) { |
2518 | |
2519 uri_separator = ""; | |
2520 | |
2521 #if (NGX_HAVE_UNIX_DOMAIN) | |
2522 if (u->peer.sockaddr && u->peer.sockaddr->sa_family == AF_UNIX) { | |
2523 uri_separator = ":"; | |
2524 } | |
2525 #endif | |
665 | 2526 |
2527 p = ngx_snprintf(buf, len, ", upstream: \"%V%V%s%V\"", | |
884 | 2528 &u->conf->schema, u->peer.name, |
2529 uri_separator, &u->uri); | |
665 | 2530 len -= p - buf; |
2531 buf = p; | |
2532 } | |
2533 | |
505 | 2534 if (r->headers_in.host) { |
2535 p = ngx_snprintf(buf, len, ", host: \"%V\"", | |
2536 &r->headers_in.host->value); | |
2537 len -= p - buf; | |
2538 buf = p; | |
2539 } | |
2540 | |
2541 if (r->headers_in.referer) { | |
2542 p = ngx_snprintf(buf, len, ", referrer: \"%V\"", | |
2543 &r->headers_in.referer->value); | |
2544 buf = p; | |
2545 } | |
2546 | |
2547 return buf; | |
2548 } |