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