Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_fastcgi_module.c @ 2036:1c009c5a163b
fix error log message
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 26 May 2008 10:54:59 +0000 |
parents | f1cff424caeb |
children | 2a92804f4109 |
rev | line source |
---|---|
479 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 #include <ngx_http.h> | |
10 #include <nginx.h> | |
11 | |
12 | |
13 typedef struct { | |
651 | 14 ngx_http_upstream_conf_t upstream; |
15 | |
16 ngx_str_t index; | |
17 | |
18 ngx_array_t *flushes; | |
19 ngx_array_t *params_len; | |
20 ngx_array_t *params; | |
21 ngx_array_t *params_source; | |
1228 | 22 ngx_array_t *catch_stderr; |
479 | 23 } ngx_http_fastcgi_loc_conf_t; |
24 | |
25 | |
26 typedef enum { | |
27 ngx_http_fastcgi_st_version = 0, | |
28 ngx_http_fastcgi_st_type, | |
29 ngx_http_fastcgi_st_request_id_hi, | |
30 ngx_http_fastcgi_st_request_id_lo, | |
31 ngx_http_fastcgi_st_content_length_hi, | |
32 ngx_http_fastcgi_st_content_length_lo, | |
33 ngx_http_fastcgi_st_padding_length, | |
34 ngx_http_fastcgi_st_reserved, | |
35 ngx_http_fastcgi_st_data, | |
515 | 36 ngx_http_fastcgi_st_padding |
479 | 37 } ngx_http_fastcgi_state_e; |
38 | |
39 | |
40 typedef struct { | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
41 u_char *start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
42 u_char *end; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
43 } ngx_http_fastcgi_split_part_t; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
44 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
45 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
46 typedef struct { |
651 | 47 ngx_http_fastcgi_state_e state; |
48 u_char *pos; | |
49 u_char *last; | |
50 ngx_uint_t type; | |
51 size_t length; | |
52 size_t padding; | |
53 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
54 ngx_uint_t fastcgi_stdout; /* unsigned :1 */ |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
55 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
56 ngx_array_t *split_parts; |
479 | 57 } ngx_http_fastcgi_ctx_t; |
58 | |
59 | |
60 #define NGX_HTTP_FASTCGI_RESPONDER 1 | |
61 | |
62 #define NGX_HTTP_FASTCGI_BEGIN_REQUEST 1 | |
63 #define NGX_HTTP_FASTCGI_ABORT_REQUEST 2 | |
64 #define NGX_HTTP_FASTCGI_END_REQUEST 3 | |
65 #define NGX_HTTP_FASTCGI_PARAMS 4 | |
66 #define NGX_HTTP_FASTCGI_STDIN 5 | |
67 #define NGX_HTTP_FASTCGI_STDOUT 6 | |
68 #define NGX_HTTP_FASTCGI_STDERR 7 | |
69 #define NGX_HTTP_FASTCGI_DATA 8 | |
70 | |
71 | |
72 typedef struct { | |
73 u_char version; | |
74 u_char type; | |
75 u_char request_id_hi; | |
76 u_char request_id_lo; | |
77 u_char content_length_hi; | |
78 u_char content_length_lo; | |
79 u_char padding_length; | |
80 u_char reserved; | |
81 } ngx_http_fastcgi_header_t; | |
82 | |
83 | |
84 typedef struct { | |
85 u_char role_hi; | |
86 u_char role_lo; | |
87 u_char flags; | |
88 u_char reserved[5]; | |
89 } ngx_http_fastcgi_begin_request_t; | |
90 | |
91 | |
509 | 92 typedef struct { |
93 u_char version; | |
94 u_char type; | |
95 u_char request_id_hi; | |
96 u_char request_id_lo; | |
97 } ngx_http_fastcgi_header_small_t; | |
98 | |
99 | |
100 typedef struct { | |
101 ngx_http_fastcgi_header_t h0; | |
102 ngx_http_fastcgi_begin_request_t br; | |
103 ngx_http_fastcgi_header_small_t h1; | |
104 } ngx_http_fastcgi_request_start_t; | |
105 | |
106 | |
479 | 107 static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r); |
108 static ngx_int_t ngx_http_fastcgi_reinit_request(ngx_http_request_t *r); | |
109 static ngx_int_t ngx_http_fastcgi_process_header(ngx_http_request_t *r); | |
110 static ngx_int_t ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, | |
487 | 111 ngx_buf_t *buf); |
479 | 112 static ngx_int_t ngx_http_fastcgi_process_record(ngx_http_request_t *r, |
487 | 113 ngx_http_fastcgi_ctx_t *f); |
479 | 114 static void ngx_http_fastcgi_abort_request(ngx_http_request_t *r); |
115 static void ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, | |
487 | 116 ngx_int_t rc); |
479 | 117 |
509 | 118 static ngx_int_t ngx_http_fastcgi_add_variables(ngx_conf_t *cf); |
119 static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf); | |
120 static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, | |
121 void *parent, void *child); | |
573 | 122 static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, |
123 ngx_http_variable_value_t *v, uintptr_t data); | |
509 | 124 |
479 | 125 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, |
487 | 126 void *conf); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
127 static char *ngx_http_fastcgi_store(ngx_conf_t *cf, ngx_command_t *cmd, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
128 void *conf); |
479 | 129 static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, |
487 | 130 void *data); |
479 | 131 |
884 | 132 static char *ngx_http_fastcgi_upstream_max_fails_unsupported(ngx_conf_t *cf, |
133 ngx_command_t *cmd, void *conf); | |
134 static char *ngx_http_fastcgi_upstream_fail_timeout_unsupported(ngx_conf_t *cf, | |
135 ngx_command_t *cmd, void *conf); | |
136 | |
479 | 137 |
509 | 138 static ngx_conf_post_t ngx_http_fastcgi_lowat_post = |
139 { ngx_http_fastcgi_lowat_check }; | |
479 | 140 |
141 | |
142 static ngx_conf_bitmask_t ngx_http_fastcgi_next_upstream_masks[] = { | |
143 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, | |
144 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, | |
145 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, | |
146 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, | |
623 | 147 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 }, |
479 | 148 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, |
665 | 149 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, |
479 | 150 { ngx_null_string, 0 } |
151 }; | |
152 | |
153 | |
154 static ngx_command_t ngx_http_fastcgi_commands[] = { | |
155 | |
156 { ngx_string("fastcgi_pass"), | |
629 | 157 NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1, |
479 | 158 ngx_http_fastcgi_pass, |
159 NGX_HTTP_LOC_CONF_OFFSET, | |
160 0, | |
161 NULL }, | |
162 | |
163 { ngx_string("fastcgi_index"), | |
164 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
165 ngx_conf_set_str_slot, | |
166 NGX_HTTP_LOC_CONF_OFFSET, | |
167 offsetof(ngx_http_fastcgi_loc_conf_t, index), | |
168 NULL }, | |
169 | |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
170 { ngx_string("fastcgi_store"), |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
171 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
172 ngx_http_fastcgi_store, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
173 NGX_HTTP_LOC_CONF_OFFSET, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
174 0, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
175 NULL }, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
176 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
177 { ngx_string("fastcgi_store_access"), |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
178 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
179 ngx_conf_set_access_slot, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
180 NGX_HTTP_LOC_CONF_OFFSET, |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
181 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.store_access), |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
182 NULL }, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
183 |
629 | 184 { ngx_string("fastcgi_ignore_client_abort"), |
185 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
186 ngx_conf_set_flag_slot, | |
187 NGX_HTTP_LOC_CONF_OFFSET, | |
188 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.ignore_client_abort), | |
189 NULL }, | |
190 | |
479 | 191 { ngx_string("fastcgi_connect_timeout"), |
192 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
193 ngx_conf_set_msec_slot, | |
194 NGX_HTTP_LOC_CONF_OFFSET, | |
195 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.connect_timeout), | |
196 NULL }, | |
197 | |
198 { ngx_string("fastcgi_send_timeout"), | |
199 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
200 ngx_conf_set_msec_slot, | |
201 NGX_HTTP_LOC_CONF_OFFSET, | |
202 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_timeout), | |
203 NULL }, | |
204 | |
205 { ngx_string("fastcgi_send_lowat"), | |
206 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
207 ngx_conf_set_size_slot, | |
208 NGX_HTTP_LOC_CONF_OFFSET, | |
209 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_lowat), | |
210 &ngx_http_fastcgi_lowat_post }, | |
211 | |
581 | 212 { ngx_string("fastcgi_buffer_size"), |
213 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
214 ngx_conf_set_size_slot, | |
215 NGX_HTTP_LOC_CONF_OFFSET, | |
216 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.buffer_size), | |
217 NULL }, | |
218 | |
509 | 219 { ngx_string("fastcgi_pass_request_headers"), |
220 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
221 ngx_conf_set_flag_slot, | |
222 NGX_HTTP_LOC_CONF_OFFSET, | |
223 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_headers), | |
224 NULL }, | |
225 | |
226 { ngx_string("fastcgi_pass_request_body"), | |
227 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
228 ngx_conf_set_flag_slot, | |
229 NGX_HTTP_LOC_CONF_OFFSET, | |
230 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_body), | |
231 NULL }, | |
232 | |
657 | 233 { ngx_string("fastcgi_intercept_errors"), |
234 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
235 ngx_conf_set_flag_slot, | |
236 NGX_HTTP_LOC_CONF_OFFSET, | |
237 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.intercept_errors), | |
238 NULL }, | |
239 | |
479 | 240 { ngx_string("fastcgi_read_timeout"), |
241 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
242 ngx_conf_set_msec_slot, | |
243 NGX_HTTP_LOC_CONF_OFFSET, | |
244 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.read_timeout), | |
245 NULL }, | |
246 | |
247 { ngx_string("fastcgi_buffers"), | |
248 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
249 ngx_conf_set_bufs_slot, | |
250 NGX_HTTP_LOC_CONF_OFFSET, | |
251 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.bufs), | |
252 NULL }, | |
253 | |
254 { ngx_string("fastcgi_busy_buffers_size"), | |
255 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
256 ngx_conf_set_size_slot, | |
257 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 258 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size_conf), |
479 | 259 NULL }, |
260 | |
261 { ngx_string("fastcgi_temp_path"), | |
262 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | |
263 ngx_conf_set_path_slot, | |
264 NGX_HTTP_LOC_CONF_OFFSET, | |
265 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_path), | |
266 (void *) ngx_garbage_collector_temp_handler }, | |
267 | |
268 { ngx_string("fastcgi_max_temp_file_size"), | |
269 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
270 ngx_conf_set_size_slot, | |
271 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 272 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.max_temp_file_size_conf), |
479 | 273 NULL }, |
274 | |
275 { ngx_string("fastcgi_temp_file_write_size"), | |
276 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
277 ngx_conf_set_size_slot, | |
278 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 279 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_file_write_size_conf), |
479 | 280 NULL }, |
281 | |
282 { ngx_string("fastcgi_next_upstream"), | |
547 | 283 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
479 | 284 ngx_conf_set_bitmask_slot, |
285 NGX_HTTP_LOC_CONF_OFFSET, | |
286 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream), | |
287 &ngx_http_fastcgi_next_upstream_masks }, | |
288 | |
561 | 289 { ngx_string("fastcgi_upstream_max_fails"), |
290 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
884 | 291 ngx_http_fastcgi_upstream_max_fails_unsupported, |
292 0, | |
293 0, | |
561 | 294 NULL }, |
295 | |
296 { ngx_string("fastcgi_upstream_fail_timeout"), | |
297 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
884 | 298 ngx_http_fastcgi_upstream_fail_timeout_unsupported, |
299 0, | |
300 0, | |
561 | 301 NULL }, |
302 | |
509 | 303 { ngx_string("fastcgi_param"), |
304 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
649 | 305 ngx_conf_set_keyval_slot, |
485 | 306 NGX_HTTP_LOC_CONF_OFFSET, |
509 | 307 offsetof(ngx_http_fastcgi_loc_conf_t, params_source), |
485 | 308 NULL }, |
309 | |
649 | 310 { ngx_string("fastcgi_pass_header"), |
311 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
312 ngx_conf_set_str_array_slot, | |
313 NGX_HTTP_LOC_CONF_OFFSET, | |
314 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_headers), | |
315 NULL }, | |
316 | |
317 { ngx_string("fastcgi_hide_header"), | |
318 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
319 ngx_conf_set_str_array_slot, | |
320 NGX_HTTP_LOC_CONF_OFFSET, | |
321 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.hide_headers), | |
322 NULL }, | |
323 | |
1228 | 324 { ngx_string("fastcgi_catch_stderr"), |
325 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
326 ngx_conf_set_str_array_slot, | |
327 NGX_HTTP_LOC_CONF_OFFSET, | |
328 offsetof(ngx_http_fastcgi_loc_conf_t, catch_stderr), | |
329 NULL }, | |
330 | |
479 | 331 ngx_null_command |
332 }; | |
333 | |
334 | |
667 | 335 static ngx_http_module_t ngx_http_fastcgi_module_ctx = { |
509 | 336 ngx_http_fastcgi_add_variables, /* preconfiguration */ |
337 NULL, /* postconfiguration */ | |
479 | 338 |
339 NULL, /* create main configuration */ | |
340 NULL, /* init main configuration */ | |
341 | |
342 NULL, /* create server configuration */ | |
343 NULL, /* merge server configuration */ | |
344 | |
345 ngx_http_fastcgi_create_loc_conf, /* create location configuration */ | |
346 ngx_http_fastcgi_merge_loc_conf /* merge location configuration */ | |
347 }; | |
348 | |
349 | |
350 ngx_module_t ngx_http_fastcgi_module = { | |
509 | 351 NGX_MODULE_V1, |
479 | 352 &ngx_http_fastcgi_module_ctx, /* module context */ |
353 ngx_http_fastcgi_commands, /* module directives */ | |
354 NGX_HTTP_MODULE, /* module type */ | |
541 | 355 NULL, /* init master */ |
479 | 356 NULL, /* init module */ |
541 | 357 NULL, /* init process */ |
358 NULL, /* init thread */ | |
359 NULL, /* exit thread */ | |
360 NULL, /* exit process */ | |
361 NULL, /* exit master */ | |
362 NGX_MODULE_V1_PADDING | |
479 | 363 }; |
364 | |
365 | |
1883 | 366 static ngx_http_fastcgi_request_start_t ngx_http_fastcgi_request_start = { |
367 { 1, /* version */ | |
368 NGX_HTTP_FASTCGI_BEGIN_REQUEST, /* type */ | |
369 0, /* request_id_hi */ | |
370 1, /* request_id_lo */ | |
371 0, /* content_length_hi */ | |
372 sizeof(ngx_http_fastcgi_begin_request_t), /* content_length_lo */ | |
373 0, /* padding_length */ | |
374 0 }, /* reserved */ | |
375 | |
376 { 0, /* role_hi */ | |
377 NGX_HTTP_FASTCGI_RESPONDER, /* role_lo */ | |
378 0, /* NGX_HTTP_FASTCGI_KEEP_CONN */ /* flags */ | |
379 { 0, 0, 0, 0, 0 } }, /* reserved[5] */ | |
380 | |
381 { 1, /* version */ | |
382 NGX_HTTP_FASTCGI_PARAMS, /* type */ | |
383 0, /* request_id_hi */ | |
384 1 }, /* request_id_lo */ | |
385 | |
386 }; | |
387 | |
388 | |
1884 | 389 static ngx_str_t ngx_http_fastcgi_script_name = |
390 ngx_string("fastcgi_script_name"); | |
391 | |
392 | |
649 | 393 static ngx_str_t ngx_http_fastcgi_hide_headers[] = { |
394 ngx_string("Status"), | |
395 ngx_string("X-Accel-Expires"), | |
396 ngx_string("X-Accel-Redirect"), | |
397 ngx_string("X-Accel-Limit-Rate"), | |
1886
2819956d1ca0
add X-Accel-Charset to ingored header, fix X-Accel-Buffering
Igor Sysoev <igor@sysoev.ru>
parents:
1884
diff
changeset
|
398 ngx_string("X-Accel-Buffering"), |
2819956d1ca0
add X-Accel-Charset to ingored header, fix X-Accel-Buffering
Igor Sysoev <igor@sysoev.ru>
parents:
1884
diff
changeset
|
399 ngx_string("X-Accel-Charset"), |
649 | 400 ngx_null_string |
401 }; | |
402 | |
403 | |
487 | 404 static ngx_int_t |
405 ngx_http_fastcgi_handler(ngx_http_request_t *r) | |
479 | 406 { |
407 ngx_int_t rc; | |
408 ngx_http_upstream_t *u; | |
409 ngx_http_fastcgi_loc_conf_t *flcf; | |
410 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
411 if (r->subrequest_in_memory) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
412 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
413 "ngx_http_fastcgi_module does not support " |
1635 | 414 "subrequest in memory"); |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
415 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
416 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
417 |
479 | 418 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
419 | |
501 | 420 u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t)); |
421 if (u == NULL) { | |
479 | 422 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
423 } | |
424 | |
1658 | 425 u->schema = flcf->upstream.schema; |
426 | |
479 | 427 u->peer.log = r->connection->log; |
428 u->peer.log_error = NGX_ERROR_ERR; | |
429 #if (NGX_THREADS) | |
430 u->peer.lock = &r->connection->lock; | |
431 #endif | |
432 | |
433 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module; | |
434 | |
435 u->conf = &flcf->upstream; | |
436 | |
437 u->create_request = ngx_http_fastcgi_create_request; | |
438 u->reinit_request = ngx_http_fastcgi_reinit_request; | |
439 u->process_header = ngx_http_fastcgi_process_header; | |
440 u->abort_request = ngx_http_fastcgi_abort_request; | |
441 u->finalize_request = ngx_http_fastcgi_finalize_request; | |
442 | |
649 | 443 u->buffering = 1; |
444 | |
581 | 445 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); |
446 if (u->pipe == NULL) { | |
447 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
448 } | |
449 | |
450 u->pipe->input_filter = ngx_http_fastcgi_input_filter; | |
451 u->pipe->input_ctx = r; | |
479 | 452 |
453 r->upstream = u; | |
454 | |
455 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init); | |
456 | |
457 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
458 return rc; | |
459 } | |
460 | |
461 return NGX_DONE; | |
462 } | |
463 | |
464 | |
487 | 465 static ngx_int_t |
466 ngx_http_fastcgi_create_request(ngx_http_request_t *r) | |
479 | 467 { |
509 | 468 off_t file_pos; |
469 u_char ch, *pos; | |
470 size_t size, len, key_len, val_len, padding; | |
471 ngx_uint_t i, n, next; | |
472 ngx_buf_t *b; | |
473 ngx_chain_t *cl, *body; | |
474 ngx_list_part_t *part; | |
475 ngx_table_elt_t *header; | |
476 ngx_http_script_code_pt code; | |
477 ngx_http_script_engine_t e, le; | |
478 ngx_http_fastcgi_header_t *h; | |
479 ngx_http_fastcgi_loc_conf_t *flcf; | |
480 ngx_http_script_len_code_pt lcode; | |
479 | 481 |
509 | 482 len = 0; |
485 | 483 |
479 | 484 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
485 | |
509 | 486 if (flcf->params_len) { |
487 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); | |
479 | 488 |
1565 | 489 ngx_http_script_flush_no_cacheable_variables(r, flcf->flushes); |
573 | 490 le.flushed = 1; |
491 | |
509 | 492 le.ip = flcf->params_len->elts; |
493 le.request = r; | |
479 | 494 |
509 | 495 while (*(uintptr_t *) le.ip) { |
487 | 496 |
509 | 497 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
498 key_len = lcode(&le); | |
479 | 499 |
509 | 500 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
501 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
502 } | |
503 le.ip += sizeof(uintptr_t); | |
479 | 504 |
537 | 505 len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len; |
485 | 506 } |
507 } | |
508 | |
509 | 509 if (flcf->upstream.pass_request_headers) { |
485 | 510 |
509 | 511 part = &r->headers_in.headers.part; |
512 header = part->elts; | |
513 | |
514 for (i = 0; /* void */; i++) { | |
479 | 515 |
509 | 516 if (i >= part->nelts) { |
517 if (part->next == NULL) { | |
518 break; | |
519 } | |
479 | 520 |
509 | 521 part = part->next; |
522 header = part->elts; | |
523 i = 0; | |
479 | 524 } |
525 | |
509 | 526 len += ((sizeof("HTTP_") - 1 + header[i].key.len > 127) ? 4 : 1) |
527 + ((header[i].value.len > 127) ? 4 : 1) | |
528 + sizeof("HTTP_") - 1 + header[i].key.len + header[i].value.len; | |
479 | 529 } |
530 } | |
531 | |
532 | |
533 if (len > 65535) { | |
534 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
1678 | 535 "fastcgi request record is too big: %uz", len); |
479 | 536 return NGX_ERROR; |
537 } | |
538 | |
539 | |
540 padding = 8 - len % 8; | |
541 padding = (padding == 8) ? 0 : padding; | |
542 | |
543 | |
544 size = sizeof(ngx_http_fastcgi_header_t) | |
545 + sizeof(ngx_http_fastcgi_begin_request_t) | |
546 | |
547 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
548 + len + padding | |
549 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
550 | |
551 + sizeof(ngx_http_fastcgi_header_t); /* NGX_HTTP_FASTCGI_STDIN */ | |
552 | |
553 | |
501 | 554 b = ngx_create_temp_buf(r->pool, size); |
555 if (b == NULL) { | |
479 | 556 return NGX_ERROR; |
557 } | |
558 | |
501 | 559 cl = ngx_alloc_chain_link(r->pool); |
560 if (cl == NULL) { | |
479 | 561 return NGX_ERROR; |
562 } | |
563 | |
564 cl->buf = b; | |
565 | |
509 | 566 ngx_memcpy(b->pos, &ngx_http_fastcgi_request_start, |
567 sizeof(ngx_http_fastcgi_request_start_t)); | |
479 | 568 |
569 h = (ngx_http_fastcgi_header_t *) | |
570 (b->pos + sizeof(ngx_http_fastcgi_header_t) | |
571 + sizeof(ngx_http_fastcgi_begin_request_t)); | |
572 | |
573 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
574 h->content_length_lo = (u_char) (len & 0xff); | |
575 h->padding_length = (u_char) padding; | |
576 h->reserved = 0; | |
577 | |
578 b->last = b->pos + sizeof(ngx_http_fastcgi_header_t) | |
579 + sizeof(ngx_http_fastcgi_begin_request_t) | |
580 + sizeof(ngx_http_fastcgi_header_t); | |
581 | |
582 | |
509 | 583 if (flcf->params_len) { |
584 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); | |
479 | 585 |
509 | 586 e.ip = flcf->params->elts; |
587 e.pos = b->last; | |
588 e.request = r; | |
573 | 589 e.flushed = 1; |
479 | 590 |
509 | 591 le.ip = flcf->params_len->elts; |
479 | 592 |
509 | 593 while (*(uintptr_t *) le.ip) { |
479 | 594 |
509 | 595 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
596 key_len = (u_char) lcode(&le); | |
479 | 597 |
509 | 598 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
599 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
600 } | |
601 le.ip += sizeof(uintptr_t); | |
479 | 602 |
537 | 603 *e.pos++ = (u_char) key_len; |
479 | 604 |
537 | 605 if (val_len > 127) { |
606 *e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80); | |
607 *e.pos++ = (u_char) ((val_len >> 16) & 0xff); | |
608 *e.pos++ = (u_char) ((val_len >> 8) & 0xff); | |
609 *e.pos++ = (u_char) (val_len & 0xff); | |
479 | 610 |
537 | 611 } else { |
612 *e.pos++ = (u_char) val_len; | |
509 | 613 } |
479 | 614 |
509 | 615 while (*(uintptr_t *) e.ip) { |
616 code = *(ngx_http_script_code_pt *) e.ip; | |
617 code((ngx_http_script_engine_t *) &e); | |
618 } | |
619 e.ip += sizeof(uintptr_t); | |
1945 | 620 |
621 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
622 "fastcgi param: \"%*s: %*s\"", | |
623 key_len, e.pos - (key_len + val_len), | |
624 val_len, e.pos - val_len); | |
479 | 625 } |
626 | |
509 | 627 b->last = e.pos; |
487 | 628 } |
629 | |
630 | |
509 | 631 if (flcf->upstream.pass_request_headers) { |
479 | 632 |
509 | 633 part = &r->headers_in.headers.part; |
634 header = part->elts; | |
479 | 635 |
509 | 636 for (i = 0; /* void */; i++) { |
491 | 637 |
509 | 638 if (i >= part->nelts) { |
639 if (part->next == NULL) { | |
577 | 640 break; |
509 | 641 } |
577 | 642 |
509 | 643 part = part->next; |
644 header = part->elts; | |
645 i = 0; | |
646 } | |
479 | 647 |
509 | 648 len = sizeof("HTTP_") - 1 + header[i].key.len; |
649 if (len > 127) { | |
650 *b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80); | |
651 *b->last++ = (u_char) ((len >> 16) & 0xff); | |
652 *b->last++ = (u_char) ((len >> 8) & 0xff); | |
653 *b->last++ = (u_char) (len & 0xff); | |
577 | 654 |
509 | 655 } else { |
656 *b->last++ = (u_char) len; | |
487 | 657 } |
658 | |
509 | 659 len = header[i].value.len; |
660 if (len > 127) { | |
661 *b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80); | |
662 *b->last++ = (u_char) ((len >> 16) & 0xff); | |
663 *b->last++ = (u_char) ((len >> 8) & 0xff); | |
664 *b->last++ = (u_char) (len & 0xff); | |
487 | 665 |
509 | 666 } else { |
667 *b->last++ = (u_char) len; | |
479 | 668 } |
669 | |
509 | 670 b->last = ngx_cpymem(b->last, "HTTP_", sizeof("HTTP_") - 1); |
479 | 671 |
509 | 672 for (n = 0; n < header[i].key.len; n++) { |
673 ch = header[i].key.data[n]; | |
479 | 674 |
509 | 675 if (ch >= 'a' && ch <= 'z') { |
676 ch &= ~0x20; | |
479 | 677 |
509 | 678 } else if (ch == '-') { |
679 ch = '_'; | |
680 } | |
479 | 681 |
509 | 682 *b->last++ = ch; |
479 | 683 } |
684 | |
573 | 685 b->last = ngx_copy(b->last, header[i].value.data, |
686 header[i].value.len); | |
479 | 687 } |
688 } | |
689 | |
690 | |
691 if (padding) { | |
692 ngx_memzero(b->last, padding); | |
693 b->last += padding; | |
694 } | |
695 | |
696 | |
697 h = (ngx_http_fastcgi_header_t *) b->last; | |
698 b->last += sizeof(ngx_http_fastcgi_header_t); | |
699 | |
700 h->version = 1; | |
701 h->type = NGX_HTTP_FASTCGI_PARAMS; | |
702 h->request_id_hi = 0; | |
703 h->request_id_lo = 1; | |
704 h->content_length_hi = 0; | |
705 h->content_length_lo = 0; | |
706 h->padding_length = 0; | |
707 h->reserved = 0; | |
708 | |
709 h = (ngx_http_fastcgi_header_t *) b->last; | |
710 b->last += sizeof(ngx_http_fastcgi_header_t); | |
711 | |
509 | 712 if (flcf->upstream.pass_request_body) { |
713 body = r->upstream->request_bufs; | |
714 r->upstream->request_bufs = cl; | |
479 | 715 |
716 #if (NGX_SUPPRESS_WARN) | |
509 | 717 file_pos = 0; |
718 pos = NULL; | |
479 | 719 #endif |
720 | |
509 | 721 while (body) { |
479 | 722 |
509 | 723 if (body->buf->in_file) { |
724 file_pos = body->buf->file_pos; | |
479 | 725 |
509 | 726 } else { |
727 pos = body->buf->pos; | |
479 | 728 } |
729 | |
509 | 730 next = 0; |
479 | 731 |
509 | 732 do { |
733 b = ngx_alloc_buf(r->pool); | |
734 if (b == NULL) { | |
735 return NGX_ERROR; | |
479 | 736 } |
737 | |
509 | 738 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); |
739 | |
740 if (body->buf->in_file) { | |
741 b->file_pos = file_pos; | |
742 file_pos += 32 * 1024; | |
479 | 743 |
1142
e479e0b02e5a
fix "zero size buf" if request body file is multiple of 32K and FastCGI is used
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
744 if (file_pos >= body->buf->file_last) { |
509 | 745 file_pos = body->buf->file_last; |
746 next = 1; | |
747 } | |
748 | |
749 b->file_last = file_pos; | |
750 len = (ngx_uint_t) (file_pos - b->file_pos); | |
751 | |
752 } else { | |
753 b->pos = pos; | |
754 pos += 32 * 1024; | |
479 | 755 |
1142
e479e0b02e5a
fix "zero size buf" if request body file is multiple of 32K and FastCGI is used
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
756 if (pos >= body->buf->last) { |
509 | 757 pos = body->buf->last; |
758 next = 1; | |
759 } | |
760 | |
761 b->last = pos; | |
762 len = (ngx_uint_t) (pos - b->pos); | |
763 } | |
479 | 764 |
509 | 765 padding = 8 - len % 8; |
766 padding = (padding == 8) ? 0 : padding; | |
479 | 767 |
509 | 768 h->version = 1; |
769 h->type = NGX_HTTP_FASTCGI_STDIN; | |
770 h->request_id_hi = 0; | |
771 h->request_id_lo = 1; | |
772 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
773 h->content_length_lo = (u_char) (len & 0xff); | |
774 h->padding_length = (u_char) padding; | |
775 h->reserved = 0; | |
479 | 776 |
509 | 777 cl->next = ngx_alloc_chain_link(r->pool); |
778 if (cl->next == NULL) { | |
779 return NGX_ERROR; | |
780 } | |
479 | 781 |
509 | 782 cl = cl->next; |
783 cl->buf = b; | |
784 | |
785 b = ngx_create_temp_buf(r->pool, | |
786 sizeof(ngx_http_fastcgi_header_t) | |
787 + padding); | |
788 if (b == NULL) { | |
789 return NGX_ERROR; | |
790 } | |
479 | 791 |
509 | 792 if (padding) { |
793 ngx_memzero(b->last, padding); | |
794 b->last += padding; | |
795 } | |
796 | |
797 h = (ngx_http_fastcgi_header_t *) b->last; | |
798 b->last += sizeof(ngx_http_fastcgi_header_t); | |
479 | 799 |
509 | 800 cl->next = ngx_alloc_chain_link(r->pool); |
801 if (cl->next == NULL) { | |
802 return NGX_ERROR; | |
803 } | |
804 | |
805 cl = cl->next; | |
806 cl->buf = b; | |
479 | 807 |
509 | 808 } while (!next); |
479 | 809 |
509 | 810 body = body->next; |
811 } | |
479 | 812 |
509 | 813 } else { |
814 r->upstream->request_bufs = cl; | |
479 | 815 } |
816 | |
817 h->version = 1; | |
818 h->type = NGX_HTTP_FASTCGI_STDIN; | |
819 h->request_id_hi = 0; | |
820 h->request_id_lo = 1; | |
821 h->content_length_hi = 0; | |
822 h->content_length_lo = 0; | |
823 h->padding_length = 0; | |
824 h->reserved = 0; | |
825 | |
826 cl->next = NULL; | |
827 | |
828 return NGX_OK; | |
829 } | |
830 | |
831 | |
487 | 832 static ngx_int_t |
833 ngx_http_fastcgi_reinit_request(ngx_http_request_t *r) | |
479 | 834 { |
835 ngx_http_fastcgi_ctx_t *f; | |
836 | |
837 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
838 | |
839 if (f == NULL) { | |
840 return NGX_OK; | |
841 } | |
842 | |
843 f->state = ngx_http_fastcgi_st_version; | |
615 | 844 f->fastcgi_stdout = 0; |
479 | 845 |
846 return NGX_OK; | |
847 } | |
848 | |
849 | |
507 | 850 static ngx_int_t |
851 ngx_http_fastcgi_process_header(ngx_http_request_t *r) | |
479 | 852 { |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
853 u_char *p, *start, *last, *part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
854 size_t size; |
1228 | 855 ngx_str_t *status_line, line, *pattern; |
509 | 856 ngx_int_t rc, status; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
857 ngx_buf_t buf; |
649 | 858 ngx_uint_t i; |
509 | 859 ngx_table_elt_t *h; |
860 ngx_http_upstream_t *u; | |
861 ngx_http_fastcgi_ctx_t *f; | |
862 ngx_http_upstream_header_t *hh; | |
1228 | 863 ngx_http_fastcgi_loc_conf_t *flcf; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
864 ngx_http_fastcgi_split_part_t *part; |
509 | 865 ngx_http_upstream_main_conf_t *umcf; |
479 | 866 |
867 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
868 | |
509 | 869 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); |
870 | |
479 | 871 if (f == NULL) { |
501 | 872 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); |
873 if (f == NULL) { | |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
874 return NGX_ERROR; |
479 | 875 } |
876 | |
877 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); | |
878 } | |
879 | |
880 u = r->upstream; | |
881 | |
882 for ( ;; ) { | |
883 | |
884 if (f->state < ngx_http_fastcgi_st_data) { | |
885 | |
581 | 886 f->pos = u->buffer.pos; |
887 f->last = u->buffer.last; | |
479 | 888 |
889 rc = ngx_http_fastcgi_process_record(r, f); | |
890 | |
581 | 891 u->buffer.pos = f->pos; |
892 u->buffer.last = f->last; | |
479 | 893 |
894 if (rc == NGX_AGAIN) { | |
895 return NGX_AGAIN; | |
896 } | |
897 | |
898 if (rc == NGX_ERROR) { | |
899 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
900 } | |
901 | |
491 | 902 if (f->type != NGX_HTTP_FASTCGI_STDOUT |
903 && f->type != NGX_HTTP_FASTCGI_STDERR) | |
904 { | |
479 | 905 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
906 "upstream sent unexpected FastCGI record: %d", | |
907 f->type); | |
908 | |
909 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
910 } | |
911 | |
491 | 912 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { |
479 | 913 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
914 "upstream closed prematurely FastCGI stdout"); | |
915 | |
916 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
917 } | |
918 } | |
919 | |
920 if (f->state == ngx_http_fastcgi_st_padding) { | |
921 | |
581 | 922 if (u->buffer.pos + f->padding < u->buffer.last) { |
479 | 923 f->state = ngx_http_fastcgi_st_version; |
581 | 924 u->buffer.pos += f->padding; |
479 | 925 |
926 continue; | |
927 } | |
928 | |
581 | 929 if (u->buffer.pos + f->padding == u->buffer.last) { |
479 | 930 f->state = ngx_http_fastcgi_st_version; |
581 | 931 u->buffer.pos = u->buffer.last; |
479 | 932 |
933 return NGX_AGAIN; | |
934 } | |
935 | |
581 | 936 f->padding -= u->buffer.last - u->buffer.pos; |
937 u->buffer.pos = u->buffer.last; | |
479 | 938 |
939 return NGX_AGAIN; | |
940 } | |
941 | |
491 | 942 |
479 | 943 /* f->state == ngx_http_fastcgi_st_data */ |
944 | |
491 | 945 if (f->type == NGX_HTTP_FASTCGI_STDERR) { |
946 | |
947 if (f->length) { | |
581 | 948 line.data = u->buffer.pos; |
491 | 949 |
581 | 950 if (u->buffer.pos + f->length <= u->buffer.last) { |
491 | 951 line.len = f->length; |
581 | 952 u->buffer.pos += f->length; |
491 | 953 f->length = 0; |
954 f->state = ngx_http_fastcgi_st_padding; | |
955 | |
577 | 956 } else { |
581 | 957 line.len = u->buffer.last - u->buffer.pos; |
958 f->length -= u->buffer.last - u->buffer.pos; | |
959 u->buffer.pos = u->buffer.last; | |
491 | 960 } |
961 | |
962 while (line.data[line.len - 1] == LF | |
963 || line.data[line.len - 1] == CR | |
964 || line.data[line.len - 1] == '.' | |
965 || line.data[line.len - 1] == ' ') | |
966 { | |
967 line.len--; | |
968 } | |
969 | |
970 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
971 "FastCGI sent in stderr: \"%V\"", &line); | |
972 | |
1228 | 973 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
974 | |
975 if (flcf->catch_stderr) { | |
976 pattern = flcf->catch_stderr->elts; | |
977 | |
978 line.data[line.len - 1] = '\0'; | |
979 | |
980 for (i = 0; i < flcf->catch_stderr->nelts; i++) { | |
981 if (ngx_strstr(line.data, pattern[i].data)) { | |
1700
7f3350b18e75
return NGX_HTTP_UPSTREAM_INVALID_HEADER instead of NGX_HTTP_BAD_GATEWAY
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
982 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
1228 | 983 } |
984 } | |
985 } | |
986 | |
581 | 987 if (u->buffer.pos == u->buffer.last) { |
615 | 988 |
989 if (!f->fastcgi_stdout) { | |
990 | |
991 /* | |
992 * the special handling the large number | |
993 * of the PHP warnings to not allocate memory | |
994 */ | |
995 | |
996 u->buffer.pos = u->buffer.start; | |
997 u->buffer.last = u->buffer.start; | |
998 } | |
999 | |
491 | 1000 return NGX_AGAIN; |
1001 } | |
1002 | |
1003 } else { | |
1004 f->state = ngx_http_fastcgi_st_version; | |
1005 } | |
1006 | |
1007 continue; | |
1008 } | |
1009 | |
1010 | |
1011 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1012 | |
615 | 1013 f->fastcgi_stdout = 1; |
1014 | |
581 | 1015 start = u->buffer.pos; |
479 | 1016 |
581 | 1017 if (u->buffer.pos + f->length < u->buffer.last) { |
479 | 1018 |
1019 /* | |
581 | 1020 * set u->buffer.last to the end of the FastCGI record data |
479 | 1021 * for ngx_http_parse_header_line() |
1022 */ | |
1023 | |
581 | 1024 last = u->buffer.last; |
1025 u->buffer.last = u->buffer.pos + f->length; | |
479 | 1026 |
1027 } else { | |
1028 last = NULL; | |
1029 } | |
1030 | |
1031 for ( ;; ) { | |
1032 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1033 part_start = u->buffer.pos; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1034 |
581 | 1035 rc = ngx_http_parse_header_line(r, &u->buffer); |
479 | 1036 |
1037 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1038 "http fastcgi parser: %d", rc); | |
1039 | |
1040 if (rc == NGX_AGAIN) { | |
1041 break; | |
1042 } | |
1043 | |
1044 if (rc == NGX_OK) { | |
1045 | |
1046 /* a header line has been parsed successfully */ | |
1047 | |
509 | 1048 h = ngx_list_push(&u->headers_in.headers); |
501 | 1049 if (h == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1050 return NGX_ERROR; |
479 | 1051 } |
1052 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1053 if (f->split_parts && f->split_parts->nelts) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1054 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1055 part = f->split_parts->elts; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1056 size = u->buffer.pos - part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1057 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1058 for (i = 0; i < f->split_parts->nelts; i++) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1059 size += part[i].end - part[i].start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1060 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1061 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1062 p = ngx_palloc(r->pool, size); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1063 if (p == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1064 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1065 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1066 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1067 buf.pos = p; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1068 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1069 for (i = 0; i < f->split_parts->nelts; i++) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1070 p = ngx_cpymem(p, part[i].start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1071 part[i].end - part[i].start); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1072 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1073 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1074 p = ngx_cpymem(p, part_start, u->buffer.pos - part_start); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1075 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1076 buf.last = p; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1077 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1078 f->split_parts->nelts = 0; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1079 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1080 rc = ngx_http_parse_header_line(r, &buf); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1081 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1082 h->key.len = r->header_name_end - r->header_name_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1083 h->key.data = r->header_name_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1084 h->key.data[h->key.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1085 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1086 h->value.len = r->header_end - r->header_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1087 h->value.data = r->header_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1088 h->value.data[h->value.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1089 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1090 h->lowcase_key = ngx_palloc(r->pool, h->key.len); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1091 if (h->lowcase_key == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1092 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1093 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1094 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1095 } else { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1096 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1097 h->key.len = r->header_name_end - r->header_name_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1098 h->value.len = r->header_end - r->header_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1099 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1100 h->key.data = ngx_palloc(r->pool, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1101 h->key.len + 1 + h->value.len + 1 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1102 + h->key.len); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1103 if (h->key.data == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1104 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1105 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1106 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1107 h->value.data = h->key.data + h->key.len + 1; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1108 h->lowcase_key = h->key.data + h->key.len + 1 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1109 + h->value.len + 1; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1110 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1111 ngx_cpystrn(h->key.data, r->header_name_start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1112 h->key.len + 1); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1113 ngx_cpystrn(h->value.data, r->header_start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1114 h->value.len + 1); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1115 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1116 |
509 | 1117 h->hash = r->header_hash; |
1118 | |
649 | 1119 if (h->key.len == r->lowcase_index) { |
1120 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1121 | |
1122 } else { | |
1123 for (i = 0; i < h->key.len; i++) { | |
1488
0e66eabd18b5
the "proxy_hide_header" and "fastcgi_hide_header" directives did not
Igor Sysoev <igor@sysoev.ru>
parents:
1452
diff
changeset
|
1124 h->lowcase_key[i] = ngx_tolower(h->key.data[i]); |
479 | 1125 } |
1126 } | |
1127 | |
649 | 1128 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, |
1129 h->lowcase_key, h->key.len); | |
1130 | |
1131 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1132 return NGX_ERROR; |
649 | 1133 } |
1134 | |
479 | 1135 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1136 "http fastcgi header: \"%V: %V\"", | |
1137 &h->key, &h->value); | |
1138 | |
615 | 1139 if (u->buffer.pos < u->buffer.last) { |
1140 continue; | |
1141 } | |
1142 | |
1143 /* the end of the FastCGI record */ | |
1144 | |
1145 break; | |
479 | 1146 } |
1147 | |
1148 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
1149 | |
1150 /* a whole header has been parsed successfully */ | |
1151 | |
1152 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1153 "http fastcgi header done"); | |
1154 | |
509 | 1155 if (u->headers_in.status) { |
1156 status_line = &u->headers_in.status->value; | |
479 | 1157 |
1158 status = ngx_atoi(status_line->data, 3); | |
1159 | |
1160 if (status == NGX_ERROR) { | |
1698
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1161 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1162 "upstream sent invalid status \"%V\"", |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1163 status_line); |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1164 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
479 | 1165 } |
1166 | |
529 | 1167 u->headers_in.status_n = status; |
1168 u->headers_in.status_line = *status_line; | |
479 | 1169 |
1170 } else { | |
529 | 1171 u->headers_in.status_n = 200; |
1172 u->headers_in.status_line.len = sizeof("200 OK") - 1; | |
1173 u->headers_in.status_line.data = (u_char *) "200 OK"; | |
479 | 1174 } |
1175 | |
529 | 1176 u->state->status = u->headers_in.status_n; |
479 | 1177 #if 0 |
1565 | 1178 if (u->cacheable) { |
1179 u->cacheable = ngx_http_upstream_is_cacheable(r); | |
479 | 1180 } |
1181 #endif | |
1182 | |
1183 break; | |
1184 } | |
1185 | |
1186 /* there was error while a header line parsing */ | |
1187 | |
1188 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
619 | 1189 "upstream sent invalid header"); |
479 | 1190 |
1191 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1192 } | |
1193 | |
1194 if (last) { | |
581 | 1195 u->buffer.last = last; |
479 | 1196 } |
1197 | |
581 | 1198 f->length -= u->buffer.pos - start; |
479 | 1199 |
1200 if (f->length == 0) { | |
1201 if (f->padding) { | |
1202 f->state = ngx_http_fastcgi_st_padding; | |
1203 } else { | |
1204 f->state = ngx_http_fastcgi_st_version; | |
1205 } | |
1206 } | |
1207 | |
615 | 1208 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { |
1209 return NGX_OK; | |
1210 } | |
1211 | |
1274 | 1212 if (rc == NGX_OK) { |
1998
63c60504c0bf
fix error introduced in r1273 and r1275:
Igor Sysoev <igor@sysoev.ru>
parents:
1945
diff
changeset
|
1213 continue; |
615 | 1214 } |
1215 | |
1274 | 1216 /* rc == NGX_AGAIN */ |
1217 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1218 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1219 "upstream split a header line in FastCGI records"); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1220 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1221 if (f->split_parts == NULL) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1222 f->split_parts = ngx_array_create(r->pool, 1, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1223 sizeof(ngx_http_fastcgi_split_part_t)); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1224 if (f->split_parts == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1698
diff
changeset
|
1225 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1226 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1227 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1228 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1229 part = ngx_array_push(f->split_parts); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1230 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1231 part->start = part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1232 part->end = u->buffer.last; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1233 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1234 return NGX_AGAIN; |
479 | 1235 } |
1236 } | |
1237 | |
1238 | |
487 | 1239 static ngx_int_t |
1240 ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) | |
479 | 1241 { |
1242 ngx_int_t rc; | |
483 | 1243 ngx_buf_t *b, **prev; |
479 | 1244 ngx_str_t line; |
1245 ngx_chain_t *cl; | |
1246 ngx_http_request_t *r; | |
1247 ngx_http_fastcgi_ctx_t *f; | |
1248 | |
1249 if (buf->pos == buf->last) { | |
1250 return NGX_OK; | |
1251 } | |
1252 | |
1253 r = p->input_ctx; | |
1254 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
1255 | |
1256 b = NULL; | |
483 | 1257 prev = &buf->shadow; |
479 | 1258 |
1259 f->pos = buf->pos; | |
1260 f->last = buf->last; | |
1261 | |
1262 for ( ;; ) { | |
1263 if (f->state < ngx_http_fastcgi_st_data) { | |
1264 | |
1265 rc = ngx_http_fastcgi_process_record(r, f); | |
1266 | |
1267 if (rc == NGX_AGAIN) { | |
1268 break; | |
1269 } | |
1270 | |
1271 if (rc == NGX_ERROR) { | |
1272 return NGX_ERROR; | |
1273 } | |
1274 | |
1275 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { | |
1276 f->state = ngx_http_fastcgi_st_version; | |
1277 p->upstream_done = 1; | |
1278 | |
1279 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | |
1280 "http fastcgi closed stdout"); | |
1281 | |
1282 continue; | |
1283 } | |
1284 | |
1285 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { | |
1286 f->state = ngx_http_fastcgi_st_version; | |
1287 p->upstream_done = 1; | |
1288 | |
1289 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | |
1290 "http fastcgi sent end request"); | |
1291 | |
1292 break; | |
1293 } | |
1294 } | |
1295 | |
1296 | |
1297 if (f->state == ngx_http_fastcgi_st_padding) { | |
1298 | |
1299 if (f->pos + f->padding < f->last) { | |
1300 f->state = ngx_http_fastcgi_st_version; | |
1301 f->pos += f->padding; | |
1302 | |
1303 continue; | |
1304 } | |
1305 | |
1306 if (f->pos + f->padding == f->last) { | |
1307 f->state = ngx_http_fastcgi_st_version; | |
1308 | |
1309 break; | |
1310 } | |
1311 | |
1312 f->padding -= f->last - f->pos; | |
1313 | |
1314 break; | |
1315 } | |
1316 | |
1317 | |
1318 /* f->state == ngx_http_fastcgi_st_data */ | |
1319 | |
1320 if (f->type == NGX_HTTP_FASTCGI_STDERR) { | |
1321 | |
1322 if (f->length) { | |
639 | 1323 |
1324 if (f->pos == f->last) { | |
1325 break; | |
1326 } | |
1327 | |
479 | 1328 line.data = f->pos; |
1329 | |
1330 if (f->pos + f->length <= f->last) { | |
1331 line.len = f->length; | |
1332 f->pos += f->length; | |
491 | 1333 f->length = 0; |
1334 f->state = ngx_http_fastcgi_st_padding; | |
479 | 1335 |
577 | 1336 } else { |
479 | 1337 line.len = f->last - f->pos; |
1338 f->length -= f->last - f->pos; | |
1339 f->pos = f->last; | |
1340 } | |
1341 | |
491 | 1342 while (line.data[line.len - 1] == LF |
1343 || line.data[line.len - 1] == CR | |
1344 || line.data[line.len - 1] == '.' | |
1345 || line.data[line.len - 1] == ' ') | |
1346 { | |
1347 line.len--; | |
1348 } | |
479 | 1349 |
1350 ngx_log_error(NGX_LOG_ERR, p->log, 0, | |
491 | 1351 "FastCGI sent in stderr: \"%V\"", &line); |
479 | 1352 |
1353 if (f->pos == f->last) { | |
1354 break; | |
1355 } | |
491 | 1356 |
1357 } else { | |
1358 f->state = ngx_http_fastcgi_st_version; | |
479 | 1359 } |
1360 | |
1361 continue; | |
1362 } | |
1363 | |
1364 | |
1365 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1366 | |
639 | 1367 if (f->pos == f->last) { |
1368 break; | |
1369 } | |
1370 | |
479 | 1371 if (p->free) { |
1372 b = p->free->buf; | |
1373 p->free = p->free->next; | |
1374 | |
1375 } else { | |
501 | 1376 b = ngx_alloc_buf(p->pool); |
1377 if (b == NULL) { | |
479 | 1378 return NGX_ERROR; |
1379 } | |
1380 } | |
1381 | |
1382 ngx_memzero(b, sizeof(ngx_buf_t)); | |
1383 | |
1384 b->pos = f->pos; | |
483 | 1385 b->start = buf->start; |
1386 b->end = buf->end; | |
479 | 1387 b->tag = p->tag; |
1388 b->temporary = 1; | |
1389 b->recycled = 1; | |
483 | 1390 |
1391 *prev = b; | |
1392 prev = &b->shadow; | |
479 | 1393 |
501 | 1394 cl = ngx_alloc_chain_link(p->pool); |
1395 if (cl == NULL) { | |
479 | 1396 return NGX_ERROR; |
1397 } | |
1398 | |
1399 cl->buf = b; | |
1400 cl->next = NULL; | |
1401 | |
501 | 1402 if (p->in) { |
1403 *p->last_in = cl; | |
1404 } else { | |
1405 p->in = cl; | |
1406 } | |
1407 p->last_in = &cl->next; | |
1408 | |
1409 | |
483 | 1410 /* STUB */ b->num = buf->num; |
1411 | |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1412 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1413 "input buf #%d %p", b->num, b->pos); |
479 | 1414 |
1415 if (f->pos + f->length < f->last) { | |
1416 | |
1417 if (f->padding) { | |
1418 f->state = ngx_http_fastcgi_st_padding; | |
1419 } else { | |
1420 f->state = ngx_http_fastcgi_st_version; | |
1421 } | |
1422 | |
1423 f->pos += f->length; | |
1424 b->last = f->pos; | |
1425 | |
1426 continue; | |
1427 } | |
1428 | |
1429 if (f->pos + f->length == f->last) { | |
1430 | |
1431 if (f->padding) { | |
1432 f->state = ngx_http_fastcgi_st_padding; | |
1433 } else { | |
1434 f->state = ngx_http_fastcgi_st_version; | |
1435 } | |
1436 | |
1437 b->last = f->last; | |
1438 | |
1439 break; | |
1440 } | |
1441 | |
1442 f->length -= f->last - f->pos; | |
1443 | |
1444 b->last = f->last; | |
1445 | |
1446 break; | |
1447 | |
1448 } | |
1449 | |
1450 if (b) { | |
483 | 1451 b->shadow = buf; |
479 | 1452 b->last_shadow = 1; |
483 | 1453 |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1454 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1455 "input buf %p %z", b->pos, b->last - b->pos); |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1456 |
483 | 1457 return NGX_OK; |
1458 } | |
1459 | |
1460 /* there is no data record in the buf, add it to free chain */ | |
1461 | |
1462 if (ngx_event_pipe_add_free_buf(p, buf) != NGX_OK) { | |
1463 return NGX_ERROR; | |
479 | 1464 } |
1465 | |
1466 return NGX_OK; | |
1467 } | |
1468 | |
1469 | |
487 | 1470 static ngx_int_t |
1471 ngx_http_fastcgi_process_record(ngx_http_request_t *r, | |
1472 ngx_http_fastcgi_ctx_t *f) | |
479 | 1473 { |
1474 u_char ch, *p; | |
1475 ngx_http_fastcgi_state_e state; | |
1476 | |
1477 state = f->state; | |
1478 | |
1479 for (p = f->pos; p < f->last; p++) { | |
1480 | |
1481 ch = *p; | |
1482 | |
1483 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1484 "http fastcgi record byte: %02Xd", ch); | |
1485 | |
1486 switch (state) { | |
1487 | |
1488 case ngx_http_fastcgi_st_version: | |
1489 if (ch != 1) { | |
1490 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1491 "upstream sent unsupported FastCGI " | |
1492 "protocol version: %d", ch); | |
1493 return NGX_ERROR; | |
1494 } | |
1495 state = ngx_http_fastcgi_st_type; | |
1496 break; | |
1497 | |
1498 case ngx_http_fastcgi_st_type: | |
1499 switch (ch) { | |
1500 case NGX_HTTP_FASTCGI_STDOUT: | |
1501 case NGX_HTTP_FASTCGI_STDERR: | |
1502 case NGX_HTTP_FASTCGI_END_REQUEST: | |
1503 f->type = (ngx_uint_t) ch; | |
1504 break; | |
1505 default: | |
1506 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1507 "upstream sent invalid FastCGI " | |
1508 "record type: %d", ch); | |
1509 return NGX_ERROR; | |
1510 | |
1511 } | |
1512 state = ngx_http_fastcgi_st_request_id_hi; | |
1513 break; | |
1514 | |
1515 /* we support the single request per connection */ | |
1516 | |
1517 case ngx_http_fastcgi_st_request_id_hi: | |
1518 if (ch != 0) { | |
1519 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1520 "upstream sent unexpected FastCGI " | |
1521 "request id high byte: %d", ch); | |
1522 return NGX_ERROR; | |
1523 } | |
1524 state = ngx_http_fastcgi_st_request_id_lo; | |
1525 break; | |
1526 | |
1527 case ngx_http_fastcgi_st_request_id_lo: | |
1528 if (ch != 1) { | |
1529 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1530 "upstream sent unexpected FastCGI " | |
1531 "request id low byte: %d", ch); | |
1532 return NGX_ERROR; | |
1533 } | |
1534 state = ngx_http_fastcgi_st_content_length_hi; | |
1535 break; | |
1536 | |
1537 case ngx_http_fastcgi_st_content_length_hi: | |
1538 f->length = ch << 8; | |
1539 state = ngx_http_fastcgi_st_content_length_lo; | |
1540 break; | |
1541 | |
1542 case ngx_http_fastcgi_st_content_length_lo: | |
1543 f->length |= (size_t) ch; | |
1544 state = ngx_http_fastcgi_st_padding_length; | |
1545 break; | |
1546 | |
1547 case ngx_http_fastcgi_st_padding_length: | |
1548 f->padding = (size_t) ch; | |
1549 state = ngx_http_fastcgi_st_reserved; | |
1550 break; | |
1551 | |
1552 case ngx_http_fastcgi_st_reserved: | |
1553 state = ngx_http_fastcgi_st_data; | |
1554 | |
1555 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1556 "http fastcgi record length: %z", f->length); | |
1557 | |
1558 f->pos = p + 1; | |
1559 f->state = state; | |
1560 | |
1561 return NGX_OK; | |
1562 | |
1563 /* suppress warning */ | |
1564 case ngx_http_fastcgi_st_data: | |
1565 case ngx_http_fastcgi_st_padding: | |
1566 break; | |
1567 } | |
1568 } | |
1569 | |
1570 f->state = state; | |
1571 | |
1572 return NGX_AGAIN; | |
1573 } | |
1574 | |
1575 | |
487 | 1576 static void |
1577 ngx_http_fastcgi_abort_request(ngx_http_request_t *r) | |
479 | 1578 { |
1579 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1580 "abort http fastcgi request"); | |
1581 | |
1582 return; | |
1583 } | |
1584 | |
1585 | |
487 | 1586 static void |
1587 ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
479 | 1588 { |
1589 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1590 "finalize http fastcgi request"); | |
1591 | |
1592 return; | |
1593 } | |
1594 | |
1595 | |
509 | 1596 static ngx_int_t |
1597 ngx_http_fastcgi_add_variables(ngx_conf_t *cf) | |
479 | 1598 { |
509 | 1599 ngx_http_variable_t *var; |
479 | 1600 |
583 | 1601 var = ngx_http_add_variable(cf, &ngx_http_fastcgi_script_name, |
1565 | 1602 NGX_HTTP_VAR_NOHASH|NGX_HTTP_VAR_NOCACHEABLE); |
509 | 1603 if (var == NULL) { |
1604 return NGX_ERROR; | |
479 | 1605 } |
1606 | |
637 | 1607 var->get_handler = ngx_http_fastcgi_script_name_variable; |
485 | 1608 |
509 | 1609 return NGX_OK; |
479 | 1610 } |
1611 | |
1612 | |
487 | 1613 static void * |
1614 ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf) | |
479 | 1615 { |
1616 ngx_http_fastcgi_loc_conf_t *conf; | |
1617 | |
501 | 1618 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t)); |
1619 if (conf == NULL) { | |
479 | 1620 return NGX_CONF_ERROR; |
1621 } | |
1622 | |
1623 /* | |
1624 * set by ngx_pcalloc(): | |
1625 * | |
1626 * conf->upstream.bufs.num = 0; | |
1627 * conf->upstream.next_upstream = 0; | |
1628 * conf->upstream.temp_path = NULL; | |
649 | 1629 * conf->upstream.hide_headers_hash = { NULL, 0 }; |
509 | 1630 * conf->upstream.schema = { 0, NULL }; |
1631 * conf->upstream.uri = { 0, NULL }; | |
1632 * conf->upstream.location = NULL; | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1633 * conf->upstream.store_lengths = NULL; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1634 * conf->upstream.store_values = NULL; |
509 | 1635 * |
479 | 1636 * conf->index.len = 0; |
1637 * conf->index.data = NULL; | |
1638 */ | |
1639 | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1640 conf->upstream.store = NGX_CONF_UNSET; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1641 conf->upstream.store_access = NGX_CONF_UNSET_UINT; |
581 | 1642 conf->upstream.buffering = NGX_CONF_UNSET; |
629 | 1643 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; |
581 | 1644 |
479 | 1645 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
1646 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
507 | 1647 conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC; |
1648 | |
479 | 1649 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; |
581 | 1650 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE; |
529 | 1651 |
1652 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
577 | 1653 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; |
529 | 1654 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; |
509 | 1655 |
1656 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
1657 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
1658 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1659 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1660 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1661 |
657 | 1662 conf->upstream.intercept_errors = NGX_CONF_UNSET; |
479 | 1663 |
1664 /* "fastcgi_cyclic_temp_file" is disabled */ | |
1665 conf->upstream.cyclic_temp_file = 0; | |
1666 | |
1452
cd586e963db0
change ngx_conf_merge_ptr_value() and update fastcgi_catch_stderr
Igor Sysoev <igor@sysoev.ru>
parents:
1295
diff
changeset
|
1667 conf->catch_stderr = NGX_CONF_UNSET_PTR; |
cd586e963db0
change ngx_conf_merge_ptr_value() and update fastcgi_catch_stderr
Igor Sysoev <igor@sysoev.ru>
parents:
1295
diff
changeset
|
1668 |
479 | 1669 return conf; |
1670 } | |
1671 | |
1672 | |
487 | 1673 static char * |
1674 ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
479 | 1675 { |
1676 ngx_http_fastcgi_loc_conf_t *prev = parent; | |
1677 ngx_http_fastcgi_loc_conf_t *conf = child; | |
1678 | |
509 | 1679 u_char *p; |
1680 size_t size; | |
1681 uintptr_t *code; | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1682 ngx_uint_t i; |
649 | 1683 ngx_keyval_t *src; |
1684 ngx_hash_init_t hash; | |
509 | 1685 ngx_http_script_compile_t sc; |
1686 ngx_http_script_copy_code_t *copy; | |
479 | 1687 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1688 if (conf->upstream.store != 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1689 ngx_conf_merge_value(conf->upstream.store, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1690 prev->upstream.store, 0); |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1691 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1692 if (conf->upstream.store_lengths == NULL) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1693 conf->upstream.store_lengths = prev->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1694 conf->upstream.store_values = prev->upstream.store_values; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1695 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1696 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1697 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1698 ngx_conf_merge_uint_value(conf->upstream.store_access, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1699 prev->upstream.store_access, 0600); |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
1700 |
581 | 1701 ngx_conf_merge_value(conf->upstream.buffering, |
1702 prev->upstream.buffering, 1); | |
1703 | |
629 | 1704 ngx_conf_merge_value(conf->upstream.ignore_client_abort, |
1705 prev->upstream.ignore_client_abort, 0); | |
1706 | |
479 | 1707 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
1708 prev->upstream.connect_timeout, 60000); | |
507 | 1709 |
479 | 1710 ngx_conf_merge_msec_value(conf->upstream.send_timeout, |
1711 prev->upstream.send_timeout, 60000); | |
1712 | |
1713 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
1714 prev->upstream.read_timeout, 60000); | |
1715 | |
507 | 1716 ngx_conf_merge_size_value(conf->upstream.send_lowat, |
1717 prev->upstream.send_lowat, 0); | |
479 | 1718 |
581 | 1719 ngx_conf_merge_size_value(conf->upstream.buffer_size, |
1720 prev->upstream.buffer_size, | |
479 | 1721 (size_t) ngx_pagesize); |
1722 | |
507 | 1723 |
479 | 1724 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, |
1725 8, ngx_pagesize); | |
1726 | |
1727 if (conf->upstream.bufs.num < 2) { | |
1728 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1729 "there must be at least 2 \"fastcgi_buffers\""); | |
1730 return NGX_CONF_ERROR; | |
1731 } | |
1732 | |
1733 | |
581 | 1734 size = conf->upstream.buffer_size; |
479 | 1735 if (size < conf->upstream.bufs.size) { |
1736 size = conf->upstream.bufs.size; | |
1737 } | |
1738 | |
1739 | |
529 | 1740 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, |
1741 prev->upstream.busy_buffers_size_conf, | |
479 | 1742 NGX_CONF_UNSET_SIZE); |
1743 | |
529 | 1744 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 1745 conf->upstream.busy_buffers_size = 2 * size; |
529 | 1746 } else { |
1747 conf->upstream.busy_buffers_size = | |
1748 conf->upstream.busy_buffers_size_conf; | |
1749 } | |
479 | 1750 |
529 | 1751 if (conf->upstream.busy_buffers_size < size) { |
479 | 1752 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1753 "\"fastcgi_busy_buffers_size\" must be equal or bigger than " | |
1125
2d978e1443ed
use the contemporary directives
Igor Sysoev <igor@sysoev.ru>
parents:
1097
diff
changeset
|
1754 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 1755 "one of the \"fastcgi_buffers\""); |
1756 | |
1757 return NGX_CONF_ERROR; | |
529 | 1758 } |
479 | 1759 |
529 | 1760 if (conf->upstream.busy_buffers_size |
1761 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
479 | 1762 { |
1763 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1764 "\"fastcgi_busy_buffers_size\" must be less than " | |
1765 "the size of all \"fastcgi_buffers\" minus one buffer"); | |
1766 | |
1767 return NGX_CONF_ERROR; | |
1768 } | |
1769 | |
1770 | |
529 | 1771 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, |
1772 prev->upstream.temp_file_write_size_conf, | |
479 | 1773 NGX_CONF_UNSET_SIZE); |
1774 | |
529 | 1775 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 1776 conf->upstream.temp_file_write_size = 2 * size; |
529 | 1777 } else { |
1778 conf->upstream.temp_file_write_size = | |
1779 conf->upstream.temp_file_write_size_conf; | |
1780 } | |
479 | 1781 |
529 | 1782 if (conf->upstream.temp_file_write_size < size) { |
479 | 1783 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1784 "\"fastcgi_temp_file_write_size\" must be equal or bigger than " | |
1125
2d978e1443ed
use the contemporary directives
Igor Sysoev <igor@sysoev.ru>
parents:
1097
diff
changeset
|
1785 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 1786 "one of the \"fastcgi_buffers\""); |
1787 | |
1788 return NGX_CONF_ERROR; | |
1789 } | |
1790 | |
1791 | |
529 | 1792 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, |
1793 prev->upstream.max_temp_file_size_conf, | |
479 | 1794 NGX_CONF_UNSET_SIZE); |
1795 | |
529 | 1796 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 1797 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; |
529 | 1798 } else { |
1799 conf->upstream.max_temp_file_size = | |
1800 conf->upstream.max_temp_file_size_conf; | |
1801 } | |
479 | 1802 |
529 | 1803 if (conf->upstream.max_temp_file_size != 0 |
1804 && conf->upstream.max_temp_file_size < size) | |
479 | 1805 { |
1806 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1807 "\"fastcgi_max_temp_file_size\" must be equal to zero to disable " | |
1808 "the temporary files usage or must be equal or bigger than " | |
1125
2d978e1443ed
use the contemporary directives
Igor Sysoev <igor@sysoev.ru>
parents:
1097
diff
changeset
|
1809 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 1810 "one of the \"fastcgi_buffers\""); |
1811 | |
1812 return NGX_CONF_ERROR; | |
1813 } | |
1814 | |
1815 | |
1816 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, | |
487 | 1817 prev->upstream.next_upstream, |
1818 (NGX_CONF_BITMASK_SET | |
1819 |NGX_HTTP_UPSTREAM_FT_ERROR | |
1820 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
479 | 1821 |
665 | 1822 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { |
1823 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
1824 |NGX_HTTP_UPSTREAM_FT_OFF; | |
1825 } | |
1826 | |
479 | 1827 ngx_conf_merge_path_value(conf->upstream.temp_path, |
1828 prev->upstream.temp_path, | |
1829 NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0, | |
1830 ngx_garbage_collector_temp_handler, cf); | |
1831 | |
509 | 1832 ngx_conf_merge_value(conf->upstream.pass_request_headers, |
1833 prev->upstream.pass_request_headers, 1); | |
1834 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
1835 prev->upstream.pass_request_body, 1); | |
1836 | |
657 | 1837 ngx_conf_merge_value(conf->upstream.intercept_errors, |
1838 prev->upstream.intercept_errors, 0); | |
509 | 1839 |
1228 | 1840 ngx_conf_merge_ptr_value(conf->catch_stderr, prev->catch_stderr, NULL); |
1841 | |
507 | 1842 |
479 | 1843 ngx_conf_merge_str_value(conf->index, prev->index, ""); |
1844 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1845 hash.max_size = 512; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1846 hash.bucket_size = ngx_align(64, ngx_cacheline_size); |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1847 hash.name = "fastcgi_hide_headers_hash"; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1848 |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1849 if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream, |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1850 &prev->upstream, |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1851 ngx_http_fastcgi_hide_headers, |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1852 &hash) |
649 | 1853 != NGX_OK) |
1854 { | |
1855 return NGX_CONF_ERROR; | |
1856 } | |
1857 | |
884 | 1858 if (conf->upstream.upstream == NULL) { |
1859 conf->upstream.upstream = prev->upstream.upstream; | |
629 | 1860 conf->upstream.schema = prev->upstream.schema; |
507 | 1861 } |
1862 | |
509 | 1863 if (conf->params_source == NULL) { |
573 | 1864 conf->flushes = prev->flushes; |
509 | 1865 conf->params_len = prev->params_len; |
1866 conf->params = prev->params; | |
573 | 1867 conf->params_source = prev->params_source; |
509 | 1868 |
1869 if (conf->params_source == NULL) { | |
1870 return NGX_CONF_OK; | |
1871 } | |
1872 } | |
1873 | |
1874 conf->params_len = ngx_array_create(cf->pool, 64, 1); | |
1875 if (conf->params_len == NULL) { | |
1876 return NGX_CONF_ERROR; | |
1877 } | |
573 | 1878 |
509 | 1879 conf->params = ngx_array_create(cf->pool, 512, 1); |
1880 if (conf->params == NULL) { | |
1881 return NGX_CONF_ERROR; | |
1882 } | |
1883 | |
1884 src = conf->params_source->elts; | |
1885 for (i = 0; i < conf->params_source->nelts; i++) { | |
1886 | |
1887 if (ngx_http_script_variables_count(&src[i].value) == 0) { | |
1888 copy = ngx_array_push_n(conf->params_len, | |
1889 sizeof(ngx_http_script_copy_code_t)); | |
1890 if (copy == NULL) { | |
1891 return NGX_CONF_ERROR; | |
1892 } | |
1893 | |
1894 copy->code = (ngx_http_script_code_pt) | |
1895 ngx_http_script_copy_len_code; | |
1896 copy->len = src[i].key.len; | |
1897 | |
1898 | |
1899 copy = ngx_array_push_n(conf->params_len, | |
1900 sizeof(ngx_http_script_copy_code_t)); | |
1901 if (copy == NULL) { | |
1902 return NGX_CONF_ERROR; | |
1903 } | |
1904 | |
1905 copy->code = (ngx_http_script_code_pt) | |
1906 ngx_http_script_copy_len_code; | |
1907 copy->len = src[i].value.len; | |
1908 | |
1909 | |
1910 size = (sizeof(ngx_http_script_copy_code_t) | |
1911 + src[i].key.len + src[i].value.len | |
1912 + sizeof(uintptr_t) - 1) | |
1913 & ~(sizeof(uintptr_t) - 1); | |
1914 | |
1915 copy = ngx_array_push_n(conf->params, size); | |
1916 if (copy == NULL) { | |
1917 return NGX_CONF_ERROR; | |
1918 } | |
577 | 1919 |
509 | 1920 copy->code = ngx_http_script_copy_code; |
1921 copy->len = src[i].key.len + src[i].value.len; | |
1922 | |
1923 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
1924 | |
1925 p = ngx_cpymem(p, src[i].key.data, src[i].key.len); | |
1926 ngx_memcpy(p, src[i].value.data, src[i].value.len); | |
1927 | |
1928 } else { | |
1929 copy = ngx_array_push_n(conf->params_len, | |
1930 sizeof(ngx_http_script_copy_code_t)); | |
1931 if (copy == NULL) { | |
1932 return NGX_CONF_ERROR; | |
1933 } | |
1934 | |
1935 copy->code = (ngx_http_script_code_pt) | |
1936 ngx_http_script_copy_len_code; | |
1937 copy->len = src[i].key.len; | |
1938 | |
1939 | |
1940 size = (sizeof(ngx_http_script_copy_code_t) | |
1941 + src[i].key.len + sizeof(uintptr_t) - 1) | |
1942 & ~(sizeof(uintptr_t) - 1); | |
1943 | |
1944 copy = ngx_array_push_n(conf->params, size); | |
1945 if (copy == NULL) { | |
1946 return NGX_CONF_ERROR; | |
1947 } | |
577 | 1948 |
509 | 1949 copy->code = ngx_http_script_copy_code; |
1950 copy->len = src[i].key.len; | |
1951 | |
1952 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
1953 ngx_memcpy(p, src[i].key.data, src[i].key.len); | |
1954 | |
1955 | |
1956 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
1957 | |
1958 sc.cf = cf; | |
1959 sc.source = &src[i].value; | |
573 | 1960 sc.flushes = &conf->flushes; |
509 | 1961 sc.lengths = &conf->params_len; |
1962 sc.values = &conf->params; | |
1963 | |
1964 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
1965 return NGX_CONF_ERROR; | |
1966 } | |
1967 } | |
1968 | |
1969 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
1970 if (code == NULL) { | |
1971 return NGX_CONF_ERROR; | |
1972 } | |
1973 | |
1974 *code = (uintptr_t) NULL; | |
1975 | |
1976 | |
1977 code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); | |
1978 if (code == NULL) { | |
1979 return NGX_CONF_ERROR; | |
1980 } | |
1981 | |
1982 *code = (uintptr_t) NULL; | |
1983 } | |
1984 | |
1985 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
1986 if (code == NULL) { | |
1987 return NGX_CONF_ERROR; | |
1988 } | |
1989 | |
1990 *code = (uintptr_t) NULL; | |
1991 | |
479 | 1992 return NGX_CONF_OK; |
1993 } | |
509 | 1994 |
1995 | |
573 | 1996 static ngx_int_t |
1997 ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, | |
1998 ngx_http_variable_value_t *v, uintptr_t data) | |
509 | 1999 { |
2000 u_char *p; | |
2001 ngx_http_fastcgi_loc_conf_t *flcf; | |
2002 | |
1097
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2003 if (r->uri.len) { |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2004 v->valid = 1; |
1565 | 2005 v->no_cacheable = 0; |
1097
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2006 v->not_found = 0; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2007 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2008 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2009 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2010 if (r->uri.data[r->uri.len - 1] != '/') { |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2011 v->len = r->uri.len; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2012 v->data = r->uri.data; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2013 return NGX_OK; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2014 } |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2015 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2016 v->len = r->uri.len + flcf->index.len; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2017 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2018 v->data = ngx_palloc(r->pool, v->len); |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2019 if (v->data == NULL) { |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2020 return NGX_ERROR; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2021 } |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2022 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2023 p = ngx_copy(v->data, r->uri.data, r->uri.len); |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2024 ngx_memcpy(p, flcf->index.data, flcf->index.len); |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2025 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2026 } else { |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2027 v->len = 0; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2028 v->valid = 1; |
1565 | 2029 v->no_cacheable = 0; |
1097
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2030 v->not_found = 0; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2031 v->data = NULL; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2032 |
573 | 2033 return NGX_OK; |
509 | 2034 } |
2035 | |
573 | 2036 return NGX_OK; |
509 | 2037 } |
2038 | |
2039 | |
2040 static char * | |
2041 ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2042 { | |
2043 ngx_http_fastcgi_loc_conf_t *lcf = conf; | |
2044 | |
651 | 2045 ngx_url_t u; |
509 | 2046 ngx_str_t *value; |
2047 ngx_http_core_loc_conf_t *clcf; | |
2048 | |
555 | 2049 if (lcf->upstream.schema.len) { |
2050 return "is duplicate"; | |
2051 } | |
2052 | |
509 | 2053 value = cf->args->elts; |
2054 | |
651 | 2055 ngx_memzero(&u, sizeof(ngx_url_t)); |
2056 | |
2057 u.url = value[1]; | |
884 | 2058 u.no_resolve = 1; |
2059 | |
2060 lcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); | |
2061 if (lcf->upstream.upstream == NULL) { | |
509 | 2062 return NGX_CONF_ERROR; |
2063 } | |
2064 | |
2065 lcf->upstream.schema.len = sizeof("fastcgi://") - 1; | |
2066 lcf->upstream.schema.data = (u_char *) "fastcgi://"; | |
2067 | |
2068 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); | |
2069 | |
2070 clcf->handler = ngx_http_fastcgi_handler; | |
2071 | |
2072 if (clcf->name.data[clcf->name.len - 1] == '/') { | |
2073 clcf->auto_redirect = 1; | |
2074 } | |
2075 | |
2076 return NGX_CONF_OK; | |
2077 } | |
2078 | |
2079 | |
2080 static char * | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2081 ngx_http_fastcgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2082 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2083 ngx_http_fastcgi_loc_conf_t *flcf = conf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2084 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2085 ngx_str_t *value; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2086 ngx_http_script_compile_t sc; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2087 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2088 if (flcf->upstream.store != NGX_CONF_UNSET || flcf->upstream.store_lengths) |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2089 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2090 return "is duplicate"; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2091 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2092 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2093 value = cf->args->elts; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2094 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2095 if (ngx_strcmp(value[1].data, "on") == 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2096 flcf->upstream.store = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2097 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2098 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2099 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2100 if (ngx_strcmp(value[1].data, "off") == 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2101 flcf->upstream.store = 0; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2102 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2103 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2104 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2105 /* include the terminating '\0' into script */ |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2106 value[1].len++; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2107 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2108 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2109 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2110 sc.cf = cf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2111 sc.source = &value[1]; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2112 sc.lengths = &flcf->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2113 sc.values = &flcf->upstream.store_values; |
1563
022ec9420f80
style fix: remove double semicolons
Igor Sysoev <igor@sysoev.ru>
parents:
1488
diff
changeset
|
2114 sc.variables = ngx_http_script_variables_count(&value[1]); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2115 sc.complete_lengths = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2116 sc.complete_values = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2117 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2118 if (ngx_http_script_compile(&sc) != NGX_OK) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2119 return NGX_CONF_ERROR; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2120 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2121 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2122 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2123 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2124 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2125 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2126 static char * |
509 | 2127 ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data) |
2128 { | |
2129 #if (NGX_FREEBSD) | |
2130 ssize_t *np = data; | |
2131 | |
673 | 2132 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { |
509 | 2133 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2134 "\"fastcgi_send_lowat\" must be less than %d " | |
2135 "(sysctl net.inet.tcp.sendspace)", | |
2136 ngx_freebsd_net_inet_tcp_sendspace); | |
2137 | |
2138 return NGX_CONF_ERROR; | |
2139 } | |
2140 | |
2141 #elif !(NGX_HAVE_SO_SNDLOWAT) | |
2142 ssize_t *np = data; | |
2143 | |
2144 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
2145 "\"fastcgi_send_lowat\" is not supported, ignored"); | |
2146 | |
2147 *np = 0; | |
2148 | |
2149 #endif | |
2150 | |
2151 return NGX_CONF_OK; | |
2152 } | |
884 | 2153 |
2154 | |
2155 static char * | |
2156 ngx_http_fastcgi_upstream_max_fails_unsupported(ngx_conf_t *cf, | |
2157 ngx_command_t *cmd, void *conf) | |
2158 { | |
2159 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2160 "\"fastcgi_upstream_max_fails\" is not supported, " | |
2161 "use the \"max_fails\" parameter of the \"server\" directive ", | |
2162 "inside the \"upstream\" block"); | |
2163 | |
2164 return NGX_CONF_ERROR; | |
2165 } | |
2166 | |
2167 | |
2168 static char * | |
2169 ngx_http_fastcgi_upstream_fail_timeout_unsupported(ngx_conf_t *cf, | |
2170 ngx_command_t *cmd, void *conf) | |
2171 { | |
2172 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2173 "\"fastcgi_upstream_fail_timeout\" is not supported, " | |
2174 "use the \"fail_timeout\" parameter of the \"server\" directive ", | |
2175 "inside the \"upstream\" block"); | |
2176 | |
2177 return NGX_CONF_ERROR; | |
2178 } |