Mercurial > hg > nginx
annotate src/http/modules/ngx_http_fastcgi_module.c @ 2432:ac4780a4f748
release-0.7.30 tag
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 24 Dec 2008 16:21:41 +0000 |
parents | d3454e719bbb |
children | a8697cc12b3a |
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 |
2395
b1a24d3cf4dd
clear fastcgi ctx for internal redirection via named location
Igor Sysoev <igor@sysoev.ru>
parents:
2391
diff
changeset
|
422 ngx_http_set_ctx(r, NULL, ngx_http_fastcgi_module); |
b1a24d3cf4dd
clear fastcgi ctx for internal redirection via named location
Igor Sysoev <igor@sysoev.ru>
parents:
2391
diff
changeset
|
423 |
501 | 424 u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t)); |
425 if (u == NULL) { | |
479 | 426 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
427 } | |
428 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
429 r->upstream = u; |
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 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
|
432 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
433 if (flcf->fastcgi_lengths) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
434 if (ngx_http_fastcgi_eval(r, flcf) != NGX_OK) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
435 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
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 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
438 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
439 u->schema.len = sizeof("fastcgi://") - 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
440 u->schema.data = (u_char *) "fastcgi://"; |
1658 | 441 |
479 | 442 u->peer.log = r->connection->log; |
443 u->peer.log_error = NGX_ERROR_ERR; | |
444 #if (NGX_THREADS) | |
445 u->peer.lock = &r->connection->lock; | |
446 #endif | |
447 | |
448 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module; | |
449 | |
450 u->conf = &flcf->upstream; | |
451 | |
452 u->create_request = ngx_http_fastcgi_create_request; | |
453 u->reinit_request = ngx_http_fastcgi_reinit_request; | |
454 u->process_header = ngx_http_fastcgi_process_header; | |
455 u->abort_request = ngx_http_fastcgi_abort_request; | |
456 u->finalize_request = ngx_http_fastcgi_finalize_request; | |
457 | |
649 | 458 u->buffering = 1; |
459 | |
581 | 460 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); |
461 if (u->pipe == NULL) { | |
462 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
463 } | |
464 | |
465 u->pipe->input_filter = ngx_http_fastcgi_input_filter; | |
466 u->pipe->input_ctx = r; | |
479 | 467 |
468 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init); | |
469 | |
470 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
471 return rc; | |
472 } | |
473 | |
474 return NGX_DONE; | |
475 } | |
476 | |
477 | |
487 | 478 static ngx_int_t |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
479 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
|
480 { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
481 ngx_url_t u; |
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 ngx_memzero(&u, sizeof(ngx_url_t)); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
484 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
485 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
|
486 flcf->fastcgi_values->elts) |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
487 == NULL) |
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 return NGX_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
490 } |
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 u.no_resolve = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
493 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
494 if (ngx_parse_url(r->pool, &u) != NGX_OK) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
495 if (u.err) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
496 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
497 "%s in upstream \"%V\"", u.err, &u.url); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
498 } |
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 return NGX_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
501 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
502 |
2396
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
503 if (u.no_port) { |
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
504 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
505 "no port in upstream \"%V\"", &u.url); |
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
506 return NGX_ERROR; |
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
507 } |
848d944eae81
test port in fastcgi_pass variable
Igor Sysoev <igor@sysoev.ru>
parents:
2395
diff
changeset
|
508 |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
509 r->upstream->resolved = ngx_pcalloc(r->pool, |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
510 sizeof(ngx_http_upstream_resolved_t)); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
511 if (r->upstream->resolved == NULL) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
512 return NGX_ERROR; |
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 |
2430
d3454e719bbb
fix segfault, introduced in r2423
Igor Sysoev <igor@sysoev.ru>
parents:
2422
diff
changeset
|
515 if (u.addrs && u.addrs[0].sockaddr) { |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
516 r->upstream->resolved->sockaddr = u.addrs[0].sockaddr; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
517 r->upstream->resolved->socklen = u.addrs[0].socklen; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
518 r->upstream->resolved->naddrs = 1; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
519 r->upstream->resolved->host = u.addrs[0].name; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
520 |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
521 } else { |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
522 r->upstream->resolved->host = u.host; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
523 r->upstream->resolved->port = u.port; |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
524 } |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
525 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
526 return NGX_OK; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
527 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
528 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
529 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
530 static ngx_int_t |
487 | 531 ngx_http_fastcgi_create_request(ngx_http_request_t *r) |
479 | 532 { |
509 | 533 off_t file_pos; |
534 u_char ch, *pos; | |
535 size_t size, len, key_len, val_len, padding; | |
536 ngx_uint_t i, n, next; | |
537 ngx_buf_t *b; | |
538 ngx_chain_t *cl, *body; | |
539 ngx_list_part_t *part; | |
540 ngx_table_elt_t *header; | |
541 ngx_http_script_code_pt code; | |
542 ngx_http_script_engine_t e, le; | |
543 ngx_http_fastcgi_header_t *h; | |
544 ngx_http_fastcgi_loc_conf_t *flcf; | |
545 ngx_http_script_len_code_pt lcode; | |
479 | 546 |
509 | 547 len = 0; |
485 | 548 |
479 | 549 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
550 | |
509 | 551 if (flcf->params_len) { |
552 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); | |
479 | 553 |
1565 | 554 ngx_http_script_flush_no_cacheable_variables(r, flcf->flushes); |
573 | 555 le.flushed = 1; |
556 | |
509 | 557 le.ip = flcf->params_len->elts; |
558 le.request = r; | |
479 | 559 |
509 | 560 while (*(uintptr_t *) le.ip) { |
487 | 561 |
509 | 562 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
563 key_len = lcode(&le); | |
479 | 564 |
509 | 565 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
566 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
567 } | |
568 le.ip += sizeof(uintptr_t); | |
479 | 569 |
537 | 570 len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len; |
485 | 571 } |
572 } | |
573 | |
509 | 574 if (flcf->upstream.pass_request_headers) { |
485 | 575 |
509 | 576 part = &r->headers_in.headers.part; |
577 header = part->elts; | |
578 | |
579 for (i = 0; /* void */; i++) { | |
479 | 580 |
509 | 581 if (i >= part->nelts) { |
582 if (part->next == NULL) { | |
583 break; | |
584 } | |
479 | 585 |
509 | 586 part = part->next; |
587 header = part->elts; | |
588 i = 0; | |
479 | 589 } |
590 | |
509 | 591 len += ((sizeof("HTTP_") - 1 + header[i].key.len > 127) ? 4 : 1) |
592 + ((header[i].value.len > 127) ? 4 : 1) | |
593 + sizeof("HTTP_") - 1 + header[i].key.len + header[i].value.len; | |
479 | 594 } |
595 } | |
596 | |
597 | |
598 if (len > 65535) { | |
599 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
1678 | 600 "fastcgi request record is too big: %uz", len); |
479 | 601 return NGX_ERROR; |
602 } | |
603 | |
604 | |
605 padding = 8 - len % 8; | |
606 padding = (padding == 8) ? 0 : padding; | |
607 | |
608 | |
609 size = sizeof(ngx_http_fastcgi_header_t) | |
610 + sizeof(ngx_http_fastcgi_begin_request_t) | |
611 | |
612 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
613 + len + padding | |
614 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
615 | |
616 + sizeof(ngx_http_fastcgi_header_t); /* NGX_HTTP_FASTCGI_STDIN */ | |
617 | |
618 | |
501 | 619 b = ngx_create_temp_buf(r->pool, size); |
620 if (b == NULL) { | |
479 | 621 return NGX_ERROR; |
622 } | |
623 | |
501 | 624 cl = ngx_alloc_chain_link(r->pool); |
625 if (cl == NULL) { | |
479 | 626 return NGX_ERROR; |
627 } | |
628 | |
629 cl->buf = b; | |
630 | |
509 | 631 ngx_memcpy(b->pos, &ngx_http_fastcgi_request_start, |
632 sizeof(ngx_http_fastcgi_request_start_t)); | |
479 | 633 |
634 h = (ngx_http_fastcgi_header_t *) | |
635 (b->pos + sizeof(ngx_http_fastcgi_header_t) | |
636 + sizeof(ngx_http_fastcgi_begin_request_t)); | |
637 | |
638 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
639 h->content_length_lo = (u_char) (len & 0xff); | |
640 h->padding_length = (u_char) padding; | |
641 h->reserved = 0; | |
642 | |
643 b->last = b->pos + sizeof(ngx_http_fastcgi_header_t) | |
644 + sizeof(ngx_http_fastcgi_begin_request_t) | |
645 + sizeof(ngx_http_fastcgi_header_t); | |
646 | |
647 | |
509 | 648 if (flcf->params_len) { |
649 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); | |
479 | 650 |
509 | 651 e.ip = flcf->params->elts; |
652 e.pos = b->last; | |
653 e.request = r; | |
573 | 654 e.flushed = 1; |
479 | 655 |
509 | 656 le.ip = flcf->params_len->elts; |
479 | 657 |
509 | 658 while (*(uintptr_t *) le.ip) { |
479 | 659 |
509 | 660 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
661 key_len = (u_char) lcode(&le); | |
479 | 662 |
509 | 663 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
664 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
665 } | |
666 le.ip += sizeof(uintptr_t); | |
479 | 667 |
537 | 668 *e.pos++ = (u_char) key_len; |
479 | 669 |
537 | 670 if (val_len > 127) { |
671 *e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80); | |
672 *e.pos++ = (u_char) ((val_len >> 16) & 0xff); | |
673 *e.pos++ = (u_char) ((val_len >> 8) & 0xff); | |
674 *e.pos++ = (u_char) (val_len & 0xff); | |
479 | 675 |
537 | 676 } else { |
677 *e.pos++ = (u_char) val_len; | |
509 | 678 } |
479 | 679 |
509 | 680 while (*(uintptr_t *) e.ip) { |
681 code = *(ngx_http_script_code_pt *) e.ip; | |
682 code((ngx_http_script_engine_t *) &e); | |
683 } | |
684 e.ip += sizeof(uintptr_t); | |
1945 | 685 |
686 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
687 "fastcgi param: \"%*s: %*s\"", | |
688 key_len, e.pos - (key_len + val_len), | |
689 val_len, e.pos - val_len); | |
479 | 690 } |
691 | |
509 | 692 b->last = e.pos; |
487 | 693 } |
694 | |
695 | |
509 | 696 if (flcf->upstream.pass_request_headers) { |
479 | 697 |
509 | 698 part = &r->headers_in.headers.part; |
699 header = part->elts; | |
479 | 700 |
509 | 701 for (i = 0; /* void */; i++) { |
491 | 702 |
509 | 703 if (i >= part->nelts) { |
704 if (part->next == NULL) { | |
577 | 705 break; |
509 | 706 } |
577 | 707 |
509 | 708 part = part->next; |
709 header = part->elts; | |
710 i = 0; | |
711 } | |
479 | 712 |
509 | 713 len = sizeof("HTTP_") - 1 + header[i].key.len; |
714 if (len > 127) { | |
715 *b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80); | |
716 *b->last++ = (u_char) ((len >> 16) & 0xff); | |
717 *b->last++ = (u_char) ((len >> 8) & 0xff); | |
718 *b->last++ = (u_char) (len & 0xff); | |
577 | 719 |
509 | 720 } else { |
721 *b->last++ = (u_char) len; | |
487 | 722 } |
723 | |
509 | 724 len = header[i].value.len; |
725 if (len > 127) { | |
726 *b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80); | |
727 *b->last++ = (u_char) ((len >> 16) & 0xff); | |
728 *b->last++ = (u_char) ((len >> 8) & 0xff); | |
729 *b->last++ = (u_char) (len & 0xff); | |
487 | 730 |
509 | 731 } else { |
732 *b->last++ = (u_char) len; | |
479 | 733 } |
734 | |
509 | 735 b->last = ngx_cpymem(b->last, "HTTP_", sizeof("HTTP_") - 1); |
479 | 736 |
509 | 737 for (n = 0; n < header[i].key.len; n++) { |
738 ch = header[i].key.data[n]; | |
479 | 739 |
509 | 740 if (ch >= 'a' && ch <= 'z') { |
741 ch &= ~0x20; | |
479 | 742 |
509 | 743 } else if (ch == '-') { |
744 ch = '_'; | |
745 } | |
479 | 746 |
509 | 747 *b->last++ = ch; |
479 | 748 } |
749 | |
573 | 750 b->last = ngx_copy(b->last, header[i].value.data, |
751 header[i].value.len); | |
479 | 752 } |
753 } | |
754 | |
755 | |
756 if (padding) { | |
757 ngx_memzero(b->last, padding); | |
758 b->last += padding; | |
759 } | |
760 | |
761 | |
762 h = (ngx_http_fastcgi_header_t *) b->last; | |
763 b->last += sizeof(ngx_http_fastcgi_header_t); | |
764 | |
765 h->version = 1; | |
766 h->type = NGX_HTTP_FASTCGI_PARAMS; | |
767 h->request_id_hi = 0; | |
768 h->request_id_lo = 1; | |
769 h->content_length_hi = 0; | |
770 h->content_length_lo = 0; | |
771 h->padding_length = 0; | |
772 h->reserved = 0; | |
773 | |
774 h = (ngx_http_fastcgi_header_t *) b->last; | |
775 b->last += sizeof(ngx_http_fastcgi_header_t); | |
776 | |
509 | 777 if (flcf->upstream.pass_request_body) { |
778 body = r->upstream->request_bufs; | |
779 r->upstream->request_bufs = cl; | |
479 | 780 |
781 #if (NGX_SUPPRESS_WARN) | |
509 | 782 file_pos = 0; |
783 pos = NULL; | |
479 | 784 #endif |
785 | |
509 | 786 while (body) { |
479 | 787 |
509 | 788 if (body->buf->in_file) { |
789 file_pos = body->buf->file_pos; | |
479 | 790 |
509 | 791 } else { |
792 pos = body->buf->pos; | |
479 | 793 } |
794 | |
509 | 795 next = 0; |
479 | 796 |
509 | 797 do { |
798 b = ngx_alloc_buf(r->pool); | |
799 if (b == NULL) { | |
800 return NGX_ERROR; | |
479 | 801 } |
802 | |
509 | 803 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); |
804 | |
805 if (body->buf->in_file) { | |
806 b->file_pos = file_pos; | |
807 file_pos += 32 * 1024; | |
479 | 808 |
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
|
809 if (file_pos >= body->buf->file_last) { |
509 | 810 file_pos = body->buf->file_last; |
811 next = 1; | |
812 } | |
813 | |
814 b->file_last = file_pos; | |
815 len = (ngx_uint_t) (file_pos - b->file_pos); | |
816 | |
817 } else { | |
818 b->pos = pos; | |
819 pos += 32 * 1024; | |
479 | 820 |
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
|
821 if (pos >= body->buf->last) { |
509 | 822 pos = body->buf->last; |
823 next = 1; | |
824 } | |
825 | |
826 b->last = pos; | |
827 len = (ngx_uint_t) (pos - b->pos); | |
828 } | |
479 | 829 |
509 | 830 padding = 8 - len % 8; |
831 padding = (padding == 8) ? 0 : padding; | |
479 | 832 |
509 | 833 h->version = 1; |
834 h->type = NGX_HTTP_FASTCGI_STDIN; | |
835 h->request_id_hi = 0; | |
836 h->request_id_lo = 1; | |
837 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
838 h->content_length_lo = (u_char) (len & 0xff); | |
839 h->padding_length = (u_char) padding; | |
840 h->reserved = 0; | |
479 | 841 |
509 | 842 cl->next = ngx_alloc_chain_link(r->pool); |
843 if (cl->next == NULL) { | |
844 return NGX_ERROR; | |
845 } | |
479 | 846 |
509 | 847 cl = cl->next; |
848 cl->buf = b; | |
849 | |
850 b = ngx_create_temp_buf(r->pool, | |
851 sizeof(ngx_http_fastcgi_header_t) | |
852 + padding); | |
853 if (b == NULL) { | |
854 return NGX_ERROR; | |
855 } | |
479 | 856 |
509 | 857 if (padding) { |
858 ngx_memzero(b->last, padding); | |
859 b->last += padding; | |
860 } | |
861 | |
862 h = (ngx_http_fastcgi_header_t *) b->last; | |
863 b->last += sizeof(ngx_http_fastcgi_header_t); | |
479 | 864 |
509 | 865 cl->next = ngx_alloc_chain_link(r->pool); |
866 if (cl->next == NULL) { | |
867 return NGX_ERROR; | |
868 } | |
869 | |
870 cl = cl->next; | |
871 cl->buf = b; | |
479 | 872 |
509 | 873 } while (!next); |
479 | 874 |
509 | 875 body = body->next; |
876 } | |
479 | 877 |
509 | 878 } else { |
879 r->upstream->request_bufs = cl; | |
479 | 880 } |
881 | |
882 h->version = 1; | |
883 h->type = NGX_HTTP_FASTCGI_STDIN; | |
884 h->request_id_hi = 0; | |
885 h->request_id_lo = 1; | |
886 h->content_length_hi = 0; | |
887 h->content_length_lo = 0; | |
888 h->padding_length = 0; | |
889 h->reserved = 0; | |
890 | |
891 cl->next = NULL; | |
892 | |
893 return NGX_OK; | |
894 } | |
895 | |
896 | |
487 | 897 static ngx_int_t |
898 ngx_http_fastcgi_reinit_request(ngx_http_request_t *r) | |
479 | 899 { |
900 ngx_http_fastcgi_ctx_t *f; | |
901 | |
902 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
903 | |
904 if (f == NULL) { | |
905 return NGX_OK; | |
906 } | |
907 | |
908 f->state = ngx_http_fastcgi_st_version; | |
615 | 909 f->fastcgi_stdout = 0; |
479 | 910 |
911 return NGX_OK; | |
912 } | |
913 | |
914 | |
507 | 915 static ngx_int_t |
916 ngx_http_fastcgi_process_header(ngx_http_request_t *r) | |
479 | 917 { |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
918 u_char *p, *start, *last, *part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
919 size_t size; |
1228 | 920 ngx_str_t *status_line, line, *pattern; |
509 | 921 ngx_int_t rc, status; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
922 ngx_buf_t buf; |
649 | 923 ngx_uint_t i; |
509 | 924 ngx_table_elt_t *h; |
925 ngx_http_upstream_t *u; | |
926 ngx_http_fastcgi_ctx_t *f; | |
927 ngx_http_upstream_header_t *hh; | |
1228 | 928 ngx_http_fastcgi_loc_conf_t *flcf; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
929 ngx_http_fastcgi_split_part_t *part; |
509 | 930 ngx_http_upstream_main_conf_t *umcf; |
479 | 931 |
932 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
933 | |
509 | 934 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); |
935 | |
479 | 936 if (f == NULL) { |
501 | 937 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); |
938 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
|
939 return NGX_ERROR; |
479 | 940 } |
941 | |
942 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); | |
943 } | |
944 | |
945 u = r->upstream; | |
946 | |
947 for ( ;; ) { | |
948 | |
949 if (f->state < ngx_http_fastcgi_st_data) { | |
950 | |
581 | 951 f->pos = u->buffer.pos; |
952 f->last = u->buffer.last; | |
479 | 953 |
954 rc = ngx_http_fastcgi_process_record(r, f); | |
955 | |
581 | 956 u->buffer.pos = f->pos; |
957 u->buffer.last = f->last; | |
479 | 958 |
959 if (rc == NGX_AGAIN) { | |
960 return NGX_AGAIN; | |
961 } | |
962 | |
963 if (rc == NGX_ERROR) { | |
964 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
965 } | |
966 | |
491 | 967 if (f->type != NGX_HTTP_FASTCGI_STDOUT |
968 && f->type != NGX_HTTP_FASTCGI_STDERR) | |
969 { | |
479 | 970 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
971 "upstream sent unexpected FastCGI record: %d", | |
972 f->type); | |
973 | |
974 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
975 } | |
976 | |
491 | 977 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { |
479 | 978 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
979 "upstream closed prematurely FastCGI stdout"); | |
980 | |
981 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
982 } | |
983 } | |
984 | |
985 if (f->state == ngx_http_fastcgi_st_padding) { | |
986 | |
581 | 987 if (u->buffer.pos + f->padding < u->buffer.last) { |
479 | 988 f->state = ngx_http_fastcgi_st_version; |
581 | 989 u->buffer.pos += f->padding; |
479 | 990 |
991 continue; | |
992 } | |
993 | |
581 | 994 if (u->buffer.pos + f->padding == u->buffer.last) { |
479 | 995 f->state = ngx_http_fastcgi_st_version; |
581 | 996 u->buffer.pos = u->buffer.last; |
479 | 997 |
998 return NGX_AGAIN; | |
999 } | |
1000 | |
581 | 1001 f->padding -= u->buffer.last - u->buffer.pos; |
1002 u->buffer.pos = u->buffer.last; | |
479 | 1003 |
1004 return NGX_AGAIN; | |
1005 } | |
1006 | |
491 | 1007 |
479 | 1008 /* f->state == ngx_http_fastcgi_st_data */ |
1009 | |
491 | 1010 if (f->type == NGX_HTTP_FASTCGI_STDERR) { |
1011 | |
1012 if (f->length) { | |
581 | 1013 line.data = u->buffer.pos; |
491 | 1014 |
581 | 1015 if (u->buffer.pos + f->length <= u->buffer.last) { |
491 | 1016 line.len = f->length; |
581 | 1017 u->buffer.pos += f->length; |
491 | 1018 f->length = 0; |
1019 f->state = ngx_http_fastcgi_st_padding; | |
1020 | |
577 | 1021 } else { |
581 | 1022 line.len = u->buffer.last - u->buffer.pos; |
1023 f->length -= u->buffer.last - u->buffer.pos; | |
1024 u->buffer.pos = u->buffer.last; | |
491 | 1025 } |
1026 | |
1027 while (line.data[line.len - 1] == LF | |
1028 || line.data[line.len - 1] == CR | |
1029 || line.data[line.len - 1] == '.' | |
1030 || line.data[line.len - 1] == ' ') | |
1031 { | |
1032 line.len--; | |
1033 } | |
1034 | |
1035 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1036 "FastCGI sent in stderr: \"%V\"", &line); | |
1037 | |
1228 | 1038 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
1039 | |
1040 if (flcf->catch_stderr) { | |
1041 pattern = flcf->catch_stderr->elts; | |
1042 | |
1043 line.data[line.len - 1] = '\0'; | |
1044 | |
1045 for (i = 0; i < flcf->catch_stderr->nelts; i++) { | |
1046 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
|
1047 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
1228 | 1048 } |
1049 } | |
1050 } | |
1051 | |
581 | 1052 if (u->buffer.pos == u->buffer.last) { |
615 | 1053 |
1054 if (!f->fastcgi_stdout) { | |
1055 | |
1056 /* | |
1057 * the special handling the large number | |
1058 * of the PHP warnings to not allocate memory | |
1059 */ | |
1060 | |
1061 u->buffer.pos = u->buffer.start; | |
1062 u->buffer.last = u->buffer.start; | |
1063 } | |
1064 | |
491 | 1065 return NGX_AGAIN; |
1066 } | |
1067 | |
1068 } else { | |
1069 f->state = ngx_http_fastcgi_st_version; | |
1070 } | |
1071 | |
1072 continue; | |
1073 } | |
1074 | |
1075 | |
1076 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1077 | |
615 | 1078 f->fastcgi_stdout = 1; |
1079 | |
581 | 1080 start = u->buffer.pos; |
479 | 1081 |
581 | 1082 if (u->buffer.pos + f->length < u->buffer.last) { |
479 | 1083 |
1084 /* | |
581 | 1085 * set u->buffer.last to the end of the FastCGI record data |
479 | 1086 * for ngx_http_parse_header_line() |
1087 */ | |
1088 | |
581 | 1089 last = u->buffer.last; |
1090 u->buffer.last = u->buffer.pos + f->length; | |
479 | 1091 |
1092 } else { | |
1093 last = NULL; | |
1094 } | |
1095 | |
1096 for ( ;; ) { | |
1097 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1098 part_start = u->buffer.pos; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1099 |
2256 | 1100 rc = ngx_http_parse_header_line(r, &u->buffer, 1); |
479 | 1101 |
1102 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1103 "http fastcgi parser: %d", rc); | |
1104 | |
1105 if (rc == NGX_AGAIN) { | |
1106 break; | |
1107 } | |
1108 | |
1109 if (rc == NGX_OK) { | |
1110 | |
1111 /* a header line has been parsed successfully */ | |
1112 | |
509 | 1113 h = ngx_list_push(&u->headers_in.headers); |
501 | 1114 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
|
1115 return NGX_ERROR; |
479 | 1116 } |
1117 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1118 if (f->split_parts && f->split_parts->nelts) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1119 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1120 part = f->split_parts->elts; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1121 size = u->buffer.pos - part_start; |
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 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
|
1124 size += part[i].end - part[i].start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1125 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1126 |
2049 | 1127 p = ngx_pnalloc(r->pool, size); |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1128 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
|
1129 return NGX_ERROR; |
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 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1132 buf.pos = p; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1133 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1134 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
|
1135 p = ngx_cpymem(p, part[i].start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1136 part[i].end - part[i].start); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1137 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1138 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1139 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
|
1140 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1141 buf.last = p; |
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 f->split_parts->nelts = 0; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1144 |
2256 | 1145 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
|
1146 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1147 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
|
1148 h->key.data = r->header_name_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1149 h->key.data[h->key.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1150 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1151 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
|
1152 h->value.data = r->header_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1153 h->value.data[h->value.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1154 |
2049 | 1155 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
|
1156 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
|
1157 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1158 } |
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 } else { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1161 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1162 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
|
1163 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
|
1164 |
2049 | 1165 h->key.data = ngx_pnalloc(r->pool, |
1166 h->key.len + 1 + h->value.len + 1 | |
1167 + h->key.len); | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1168 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
|
1169 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1170 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1171 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1172 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
|
1173 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
|
1174 + h->value.len + 1; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1175 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1176 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
|
1177 h->key.len + 1); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1178 ngx_cpystrn(h->value.data, r->header_start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1179 h->value.len + 1); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1180 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1181 |
509 | 1182 h->hash = r->header_hash; |
1183 | |
649 | 1184 if (h->key.len == r->lowcase_index) { |
1185 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1186 | |
1187 } else { | |
2135 | 1188 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); |
479 | 1189 } |
1190 | |
649 | 1191 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, |
1192 h->lowcase_key, h->key.len); | |
1193 | |
1194 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
|
1195 return NGX_ERROR; |
649 | 1196 } |
1197 | |
479 | 1198 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1199 "http fastcgi header: \"%V: %V\"", | |
1200 &h->key, &h->value); | |
1201 | |
615 | 1202 if (u->buffer.pos < u->buffer.last) { |
1203 continue; | |
1204 } | |
1205 | |
1206 /* the end of the FastCGI record */ | |
1207 | |
1208 break; | |
479 | 1209 } |
1210 | |
1211 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
1212 | |
1213 /* a whole header has been parsed successfully */ | |
1214 | |
1215 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1216 "http fastcgi header done"); | |
1217 | |
509 | 1218 if (u->headers_in.status) { |
1219 status_line = &u->headers_in.status->value; | |
479 | 1220 |
1221 status = ngx_atoi(status_line->data, 3); | |
1222 | |
1223 if (status == NGX_ERROR) { | |
1698
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1224 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
|
1225 "upstream sent invalid status \"%V\"", |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1226 status_line); |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1227 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
479 | 1228 } |
1229 | |
529 | 1230 u->headers_in.status_n = status; |
1231 u->headers_in.status_line = *status_line; | |
479 | 1232 |
2140
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1233 } 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
|
1234 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
|
1235 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
|
1236 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
|
1237 u->headers_in.status_line.data = |
2223
005fc65f7ce7
style fix: remove tabs and trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
2140
diff
changeset
|
1238 (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
|
1239 |
479 | 1240 } else { |
529 | 1241 u->headers_in.status_n = 200; |
1242 u->headers_in.status_line.len = sizeof("200 OK") - 1; | |
1243 u->headers_in.status_line.data = (u_char *) "200 OK"; | |
479 | 1244 } |
1245 | |
529 | 1246 u->state->status = u->headers_in.status_n; |
479 | 1247 #if 0 |
1565 | 1248 if (u->cacheable) { |
1249 u->cacheable = ngx_http_upstream_is_cacheable(r); | |
479 | 1250 } |
1251 #endif | |
1252 | |
1253 break; | |
1254 } | |
1255 | |
1256 /* there was error while a header line parsing */ | |
1257 | |
1258 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
619 | 1259 "upstream sent invalid header"); |
479 | 1260 |
1261 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1262 } | |
1263 | |
1264 if (last) { | |
581 | 1265 u->buffer.last = last; |
479 | 1266 } |
1267 | |
581 | 1268 f->length -= u->buffer.pos - start; |
479 | 1269 |
1270 if (f->length == 0) { | |
1271 if (f->padding) { | |
1272 f->state = ngx_http_fastcgi_st_padding; | |
1273 } else { | |
1274 f->state = ngx_http_fastcgi_st_version; | |
1275 } | |
1276 } | |
1277 | |
615 | 1278 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { |
1279 return NGX_OK; | |
1280 } | |
1281 | |
1274 | 1282 if (rc == NGX_OK) { |
1998
63c60504c0bf
fix error introduced in r1273 and r1275:
Igor Sysoev <igor@sysoev.ru>
parents:
1945
diff
changeset
|
1283 continue; |
615 | 1284 } |
1285 | |
1274 | 1286 /* rc == NGX_AGAIN */ |
1287 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1288 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
|
1289 "upstream split a header line in FastCGI records"); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1290 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1291 if (f->split_parts == NULL) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1292 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
|
1293 sizeof(ngx_http_fastcgi_split_part_t)); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1294 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
|
1295 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1296 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1297 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1298 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1299 part = ngx_array_push(f->split_parts); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1300 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1301 part->start = part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1302 part->end = u->buffer.last; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1303 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1304 return NGX_AGAIN; |
479 | 1305 } |
1306 } | |
1307 | |
1308 | |
487 | 1309 static ngx_int_t |
1310 ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) | |
479 | 1311 { |
1312 ngx_int_t rc; | |
483 | 1313 ngx_buf_t *b, **prev; |
479 | 1314 ngx_str_t line; |
1315 ngx_chain_t *cl; | |
1316 ngx_http_request_t *r; | |
1317 ngx_http_fastcgi_ctx_t *f; | |
1318 | |
1319 if (buf->pos == buf->last) { | |
1320 return NGX_OK; | |
1321 } | |
1322 | |
1323 r = p->input_ctx; | |
1324 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
1325 | |
1326 b = NULL; | |
483 | 1327 prev = &buf->shadow; |
479 | 1328 |
1329 f->pos = buf->pos; | |
1330 f->last = buf->last; | |
1331 | |
1332 for ( ;; ) { | |
1333 if (f->state < ngx_http_fastcgi_st_data) { | |
1334 | |
1335 rc = ngx_http_fastcgi_process_record(r, f); | |
1336 | |
1337 if (rc == NGX_AGAIN) { | |
1338 break; | |
1339 } | |
1340 | |
1341 if (rc == NGX_ERROR) { | |
1342 return NGX_ERROR; | |
1343 } | |
1344 | |
1345 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { | |
1346 f->state = ngx_http_fastcgi_st_version; | |
1347 p->upstream_done = 1; | |
1348 | |
1349 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | |
1350 "http fastcgi closed stdout"); | |
1351 | |
1352 continue; | |
1353 } | |
1354 | |
1355 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { | |
1356 f->state = ngx_http_fastcgi_st_version; | |
1357 p->upstream_done = 1; | |
1358 | |
1359 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | |
1360 "http fastcgi sent end request"); | |
1361 | |
1362 break; | |
1363 } | |
1364 } | |
1365 | |
1366 | |
1367 if (f->state == ngx_http_fastcgi_st_padding) { | |
1368 | |
1369 if (f->pos + f->padding < f->last) { | |
1370 f->state = ngx_http_fastcgi_st_version; | |
1371 f->pos += f->padding; | |
1372 | |
1373 continue; | |
1374 } | |
1375 | |
1376 if (f->pos + f->padding == f->last) { | |
1377 f->state = ngx_http_fastcgi_st_version; | |
1378 | |
1379 break; | |
1380 } | |
1381 | |
1382 f->padding -= f->last - f->pos; | |
1383 | |
1384 break; | |
1385 } | |
1386 | |
1387 | |
1388 /* f->state == ngx_http_fastcgi_st_data */ | |
1389 | |
1390 if (f->type == NGX_HTTP_FASTCGI_STDERR) { | |
1391 | |
1392 if (f->length) { | |
639 | 1393 |
1394 if (f->pos == f->last) { | |
1395 break; | |
1396 } | |
1397 | |
479 | 1398 line.data = f->pos; |
1399 | |
1400 if (f->pos + f->length <= f->last) { | |
1401 line.len = f->length; | |
1402 f->pos += f->length; | |
491 | 1403 f->length = 0; |
1404 f->state = ngx_http_fastcgi_st_padding; | |
479 | 1405 |
577 | 1406 } else { |
479 | 1407 line.len = f->last - f->pos; |
1408 f->length -= f->last - f->pos; | |
1409 f->pos = f->last; | |
1410 } | |
1411 | |
491 | 1412 while (line.data[line.len - 1] == LF |
1413 || line.data[line.len - 1] == CR | |
1414 || line.data[line.len - 1] == '.' | |
1415 || line.data[line.len - 1] == ' ') | |
1416 { | |
1417 line.len--; | |
1418 } | |
479 | 1419 |
1420 ngx_log_error(NGX_LOG_ERR, p->log, 0, | |
491 | 1421 "FastCGI sent in stderr: \"%V\"", &line); |
479 | 1422 |
1423 if (f->pos == f->last) { | |
1424 break; | |
1425 } | |
491 | 1426 |
1427 } else { | |
1428 f->state = ngx_http_fastcgi_st_version; | |
479 | 1429 } |
1430 | |
1431 continue; | |
1432 } | |
1433 | |
1434 | |
1435 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1436 | |
639 | 1437 if (f->pos == f->last) { |
1438 break; | |
1439 } | |
1440 | |
479 | 1441 if (p->free) { |
1442 b = p->free->buf; | |
1443 p->free = p->free->next; | |
1444 | |
1445 } else { | |
501 | 1446 b = ngx_alloc_buf(p->pool); |
1447 if (b == NULL) { | |
479 | 1448 return NGX_ERROR; |
1449 } | |
1450 } | |
1451 | |
1452 ngx_memzero(b, sizeof(ngx_buf_t)); | |
1453 | |
1454 b->pos = f->pos; | |
483 | 1455 b->start = buf->start; |
1456 b->end = buf->end; | |
479 | 1457 b->tag = p->tag; |
1458 b->temporary = 1; | |
1459 b->recycled = 1; | |
483 | 1460 |
1461 *prev = b; | |
1462 prev = &b->shadow; | |
479 | 1463 |
501 | 1464 cl = ngx_alloc_chain_link(p->pool); |
1465 if (cl == NULL) { | |
479 | 1466 return NGX_ERROR; |
1467 } | |
1468 | |
1469 cl->buf = b; | |
1470 cl->next = NULL; | |
1471 | |
501 | 1472 if (p->in) { |
1473 *p->last_in = cl; | |
1474 } else { | |
1475 p->in = cl; | |
1476 } | |
1477 p->last_in = &cl->next; | |
1478 | |
1479 | |
483 | 1480 /* STUB */ b->num = buf->num; |
1481 | |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1482 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1483 "input buf #%d %p", b->num, b->pos); |
479 | 1484 |
1485 if (f->pos + f->length < f->last) { | |
1486 | |
1487 if (f->padding) { | |
1488 f->state = ngx_http_fastcgi_st_padding; | |
1489 } else { | |
1490 f->state = ngx_http_fastcgi_st_version; | |
1491 } | |
1492 | |
1493 f->pos += f->length; | |
1494 b->last = f->pos; | |
1495 | |
1496 continue; | |
1497 } | |
1498 | |
1499 if (f->pos + f->length == f->last) { | |
1500 | |
1501 if (f->padding) { | |
1502 f->state = ngx_http_fastcgi_st_padding; | |
1503 } else { | |
1504 f->state = ngx_http_fastcgi_st_version; | |
1505 } | |
1506 | |
1507 b->last = f->last; | |
1508 | |
1509 break; | |
1510 } | |
1511 | |
1512 f->length -= f->last - f->pos; | |
1513 | |
1514 b->last = f->last; | |
1515 | |
1516 break; | |
1517 | |
1518 } | |
1519 | |
1520 if (b) { | |
483 | 1521 b->shadow = buf; |
479 | 1522 b->last_shadow = 1; |
483 | 1523 |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1524 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1525 "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
|
1526 |
483 | 1527 return NGX_OK; |
1528 } | |
1529 | |
1530 /* there is no data record in the buf, add it to free chain */ | |
1531 | |
1532 if (ngx_event_pipe_add_free_buf(p, buf) != NGX_OK) { | |
1533 return NGX_ERROR; | |
479 | 1534 } |
1535 | |
1536 return NGX_OK; | |
1537 } | |
1538 | |
1539 | |
487 | 1540 static ngx_int_t |
1541 ngx_http_fastcgi_process_record(ngx_http_request_t *r, | |
1542 ngx_http_fastcgi_ctx_t *f) | |
479 | 1543 { |
1544 u_char ch, *p; | |
1545 ngx_http_fastcgi_state_e state; | |
1546 | |
1547 state = f->state; | |
1548 | |
1549 for (p = f->pos; p < f->last; p++) { | |
1550 | |
1551 ch = *p; | |
1552 | |
1553 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1554 "http fastcgi record byte: %02Xd", ch); | |
1555 | |
1556 switch (state) { | |
1557 | |
1558 case ngx_http_fastcgi_st_version: | |
1559 if (ch != 1) { | |
1560 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1561 "upstream sent unsupported FastCGI " | |
1562 "protocol version: %d", ch); | |
1563 return NGX_ERROR; | |
1564 } | |
1565 state = ngx_http_fastcgi_st_type; | |
1566 break; | |
1567 | |
1568 case ngx_http_fastcgi_st_type: | |
1569 switch (ch) { | |
1570 case NGX_HTTP_FASTCGI_STDOUT: | |
1571 case NGX_HTTP_FASTCGI_STDERR: | |
1572 case NGX_HTTP_FASTCGI_END_REQUEST: | |
1573 f->type = (ngx_uint_t) ch; | |
1574 break; | |
1575 default: | |
1576 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1577 "upstream sent invalid FastCGI " | |
1578 "record type: %d", ch); | |
1579 return NGX_ERROR; | |
1580 | |
1581 } | |
1582 state = ngx_http_fastcgi_st_request_id_hi; | |
1583 break; | |
1584 | |
1585 /* we support the single request per connection */ | |
1586 | |
1587 case ngx_http_fastcgi_st_request_id_hi: | |
1588 if (ch != 0) { | |
1589 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1590 "upstream sent unexpected FastCGI " | |
1591 "request id high byte: %d", ch); | |
1592 return NGX_ERROR; | |
1593 } | |
1594 state = ngx_http_fastcgi_st_request_id_lo; | |
1595 break; | |
1596 | |
1597 case ngx_http_fastcgi_st_request_id_lo: | |
1598 if (ch != 1) { | |
1599 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1600 "upstream sent unexpected FastCGI " | |
1601 "request id low byte: %d", ch); | |
1602 return NGX_ERROR; | |
1603 } | |
1604 state = ngx_http_fastcgi_st_content_length_hi; | |
1605 break; | |
1606 | |
1607 case ngx_http_fastcgi_st_content_length_hi: | |
1608 f->length = ch << 8; | |
1609 state = ngx_http_fastcgi_st_content_length_lo; | |
1610 break; | |
1611 | |
1612 case ngx_http_fastcgi_st_content_length_lo: | |
1613 f->length |= (size_t) ch; | |
1614 state = ngx_http_fastcgi_st_padding_length; | |
1615 break; | |
1616 | |
1617 case ngx_http_fastcgi_st_padding_length: | |
1618 f->padding = (size_t) ch; | |
1619 state = ngx_http_fastcgi_st_reserved; | |
1620 break; | |
1621 | |
1622 case ngx_http_fastcgi_st_reserved: | |
1623 state = ngx_http_fastcgi_st_data; | |
1624 | |
1625 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1626 "http fastcgi record length: %z", f->length); | |
1627 | |
1628 f->pos = p + 1; | |
1629 f->state = state; | |
1630 | |
1631 return NGX_OK; | |
1632 | |
1633 /* suppress warning */ | |
1634 case ngx_http_fastcgi_st_data: | |
1635 case ngx_http_fastcgi_st_padding: | |
1636 break; | |
1637 } | |
1638 } | |
1639 | |
1640 f->state = state; | |
1641 | |
1642 return NGX_AGAIN; | |
1643 } | |
1644 | |
1645 | |
487 | 1646 static void |
1647 ngx_http_fastcgi_abort_request(ngx_http_request_t *r) | |
479 | 1648 { |
1649 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1650 "abort http fastcgi request"); | |
1651 | |
1652 return; | |
1653 } | |
1654 | |
1655 | |
487 | 1656 static void |
1657 ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
479 | 1658 { |
1659 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1660 "finalize http fastcgi request"); | |
1661 | |
1662 return; | |
1663 } | |
1664 | |
1665 | |
509 | 1666 static ngx_int_t |
1667 ngx_http_fastcgi_add_variables(ngx_conf_t *cf) | |
479 | 1668 { |
509 | 1669 ngx_http_variable_t *var; |
479 | 1670 |
583 | 1671 var = ngx_http_add_variable(cf, &ngx_http_fastcgi_script_name, |
1565 | 1672 NGX_HTTP_VAR_NOHASH|NGX_HTTP_VAR_NOCACHEABLE); |
509 | 1673 if (var == NULL) { |
1674 return NGX_ERROR; | |
479 | 1675 } |
1676 | |
637 | 1677 var->get_handler = ngx_http_fastcgi_script_name_variable; |
485 | 1678 |
509 | 1679 return NGX_OK; |
479 | 1680 } |
1681 | |
1682 | |
487 | 1683 static void * |
1684 ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf) | |
479 | 1685 { |
1686 ngx_http_fastcgi_loc_conf_t *conf; | |
1687 | |
501 | 1688 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t)); |
1689 if (conf == NULL) { | |
479 | 1690 return NGX_CONF_ERROR; |
1691 } | |
1692 | |
1693 /* | |
1694 * set by ngx_pcalloc(): | |
1695 * | |
1696 * conf->upstream.bufs.num = 0; | |
1697 * conf->upstream.next_upstream = 0; | |
1698 * conf->upstream.temp_path = NULL; | |
649 | 1699 * conf->upstream.hide_headers_hash = { NULL, 0 }; |
509 | 1700 * conf->upstream.uri = { 0, NULL }; |
1701 * conf->upstream.location = NULL; | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1702 * conf->upstream.store_lengths = NULL; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1703 * conf->upstream.store_values = NULL; |
509 | 1704 * |
479 | 1705 * conf->index.len = 0; |
1706 * conf->index.data = NULL; | |
1707 */ | |
1708 | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1709 conf->upstream.store = NGX_CONF_UNSET; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1710 conf->upstream.store_access = NGX_CONF_UNSET_UINT; |
581 | 1711 conf->upstream.buffering = NGX_CONF_UNSET; |
629 | 1712 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; |
581 | 1713 |
479 | 1714 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
1715 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
507 | 1716 conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC; |
1717 | |
479 | 1718 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; |
581 | 1719 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE; |
529 | 1720 |
1721 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
577 | 1722 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; |
529 | 1723 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; |
509 | 1724 |
1725 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
1726 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
1727 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1728 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
|
1729 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
|
1730 |
657 | 1731 conf->upstream.intercept_errors = NGX_CONF_UNSET; |
479 | 1732 |
1733 /* "fastcgi_cyclic_temp_file" is disabled */ | |
1734 conf->upstream.cyclic_temp_file = 0; | |
1735 | |
1452
cd586e963db0
change ngx_conf_merge_ptr_value() and update fastcgi_catch_stderr
Igor Sysoev <igor@sysoev.ru>
parents:
1295
diff
changeset
|
1736 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
|
1737 |
479 | 1738 return conf; |
1739 } | |
1740 | |
1741 | |
487 | 1742 static char * |
1743 ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
479 | 1744 { |
1745 ngx_http_fastcgi_loc_conf_t *prev = parent; | |
1746 ngx_http_fastcgi_loc_conf_t *conf = child; | |
1747 | |
509 | 1748 u_char *p; |
1749 size_t size; | |
1750 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
|
1751 ngx_uint_t i; |
649 | 1752 ngx_keyval_t *src; |
1753 ngx_hash_init_t hash; | |
509 | 1754 ngx_http_script_compile_t sc; |
1755 ngx_http_script_copy_code_t *copy; | |
479 | 1756 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1757 if (conf->upstream.store != 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1758 ngx_conf_merge_value(conf->upstream.store, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1759 prev->upstream.store, 0); |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1760 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1761 if (conf->upstream.store_lengths == NULL) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1762 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
|
1763 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
|
1764 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1765 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1766 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
1767 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
|
1768 prev->upstream.store_access, 0600); |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
1769 |
581 | 1770 ngx_conf_merge_value(conf->upstream.buffering, |
1771 prev->upstream.buffering, 1); | |
1772 | |
629 | 1773 ngx_conf_merge_value(conf->upstream.ignore_client_abort, |
1774 prev->upstream.ignore_client_abort, 0); | |
1775 | |
479 | 1776 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
1777 prev->upstream.connect_timeout, 60000); | |
507 | 1778 |
479 | 1779 ngx_conf_merge_msec_value(conf->upstream.send_timeout, |
1780 prev->upstream.send_timeout, 60000); | |
1781 | |
1782 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
1783 prev->upstream.read_timeout, 60000); | |
1784 | |
507 | 1785 ngx_conf_merge_size_value(conf->upstream.send_lowat, |
1786 prev->upstream.send_lowat, 0); | |
479 | 1787 |
581 | 1788 ngx_conf_merge_size_value(conf->upstream.buffer_size, |
1789 prev->upstream.buffer_size, | |
479 | 1790 (size_t) ngx_pagesize); |
1791 | |
507 | 1792 |
479 | 1793 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, |
1794 8, ngx_pagesize); | |
1795 | |
1796 if (conf->upstream.bufs.num < 2) { | |
1797 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1798 "there must be at least 2 \"fastcgi_buffers\""); | |
1799 return NGX_CONF_ERROR; | |
1800 } | |
1801 | |
1802 | |
581 | 1803 size = conf->upstream.buffer_size; |
479 | 1804 if (size < conf->upstream.bufs.size) { |
1805 size = conf->upstream.bufs.size; | |
1806 } | |
1807 | |
1808 | |
529 | 1809 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, |
1810 prev->upstream.busy_buffers_size_conf, | |
479 | 1811 NGX_CONF_UNSET_SIZE); |
1812 | |
529 | 1813 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 1814 conf->upstream.busy_buffers_size = 2 * size; |
529 | 1815 } else { |
1816 conf->upstream.busy_buffers_size = | |
1817 conf->upstream.busy_buffers_size_conf; | |
1818 } | |
479 | 1819 |
529 | 1820 if (conf->upstream.busy_buffers_size < size) { |
479 | 1821 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1822 "\"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
|
1823 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 1824 "one of the \"fastcgi_buffers\""); |
1825 | |
1826 return NGX_CONF_ERROR; | |
529 | 1827 } |
479 | 1828 |
529 | 1829 if (conf->upstream.busy_buffers_size |
1830 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
479 | 1831 { |
1832 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1833 "\"fastcgi_busy_buffers_size\" must be less than " | |
1834 "the size of all \"fastcgi_buffers\" minus one buffer"); | |
1835 | |
1836 return NGX_CONF_ERROR; | |
1837 } | |
1838 | |
1839 | |
529 | 1840 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, |
1841 prev->upstream.temp_file_write_size_conf, | |
479 | 1842 NGX_CONF_UNSET_SIZE); |
1843 | |
529 | 1844 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 1845 conf->upstream.temp_file_write_size = 2 * size; |
529 | 1846 } else { |
1847 conf->upstream.temp_file_write_size = | |
1848 conf->upstream.temp_file_write_size_conf; | |
1849 } | |
479 | 1850 |
529 | 1851 if (conf->upstream.temp_file_write_size < size) { |
479 | 1852 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1853 "\"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
|
1854 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 1855 "one of the \"fastcgi_buffers\""); |
1856 | |
1857 return NGX_CONF_ERROR; | |
1858 } | |
1859 | |
1860 | |
529 | 1861 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, |
1862 prev->upstream.max_temp_file_size_conf, | |
479 | 1863 NGX_CONF_UNSET_SIZE); |
1864 | |
529 | 1865 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 1866 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; |
529 | 1867 } else { |
1868 conf->upstream.max_temp_file_size = | |
1869 conf->upstream.max_temp_file_size_conf; | |
1870 } | |
479 | 1871 |
529 | 1872 if (conf->upstream.max_temp_file_size != 0 |
1873 && conf->upstream.max_temp_file_size < size) | |
479 | 1874 { |
1875 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1876 "\"fastcgi_max_temp_file_size\" must be equal to zero to disable " | |
1877 "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
|
1878 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 1879 "one of the \"fastcgi_buffers\""); |
1880 | |
1881 return NGX_CONF_ERROR; | |
1882 } | |
1883 | |
1884 | |
1885 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, | |
487 | 1886 prev->upstream.next_upstream, |
1887 (NGX_CONF_BITMASK_SET | |
1888 |NGX_HTTP_UPSTREAM_FT_ERROR | |
1889 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
479 | 1890 |
665 | 1891 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { |
1892 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
1893 |NGX_HTTP_UPSTREAM_FT_OFF; | |
1894 } | |
1895 | |
479 | 1896 ngx_conf_merge_path_value(conf->upstream.temp_path, |
1897 prev->upstream.temp_path, | |
1898 NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0, | |
1899 ngx_garbage_collector_temp_handler, cf); | |
1900 | |
509 | 1901 ngx_conf_merge_value(conf->upstream.pass_request_headers, |
1902 prev->upstream.pass_request_headers, 1); | |
1903 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
1904 prev->upstream.pass_request_body, 1); | |
1905 | |
657 | 1906 ngx_conf_merge_value(conf->upstream.intercept_errors, |
1907 prev->upstream.intercept_errors, 0); | |
509 | 1908 |
1228 | 1909 ngx_conf_merge_ptr_value(conf->catch_stderr, prev->catch_stderr, NULL); |
1910 | |
507 | 1911 |
479 | 1912 ngx_conf_merge_str_value(conf->index, prev->index, ""); |
1913 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1914 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
|
1915 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
|
1916 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
|
1917 |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1918 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
|
1919 &prev->upstream, |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
1920 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
|
1921 &hash) |
649 | 1922 != NGX_OK) |
1923 { | |
1924 return NGX_CONF_ERROR; | |
1925 } | |
1926 | |
884 | 1927 if (conf->upstream.upstream == NULL) { |
1928 conf->upstream.upstream = prev->upstream.upstream; | |
507 | 1929 } |
1930 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
1931 if (conf->fastcgi_lengths == NULL) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
1932 conf->fastcgi_lengths = prev->fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
1933 conf->fastcgi_values = prev->fastcgi_values; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
1934 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
1935 |
509 | 1936 if (conf->params_source == NULL) { |
573 | 1937 conf->flushes = prev->flushes; |
509 | 1938 conf->params_len = prev->params_len; |
1939 conf->params = prev->params; | |
573 | 1940 conf->params_source = prev->params_source; |
509 | 1941 |
1942 if (conf->params_source == NULL) { | |
1943 return NGX_CONF_OK; | |
1944 } | |
1945 } | |
1946 | |
1947 conf->params_len = ngx_array_create(cf->pool, 64, 1); | |
1948 if (conf->params_len == NULL) { | |
1949 return NGX_CONF_ERROR; | |
1950 } | |
573 | 1951 |
509 | 1952 conf->params = ngx_array_create(cf->pool, 512, 1); |
1953 if (conf->params == NULL) { | |
1954 return NGX_CONF_ERROR; | |
1955 } | |
1956 | |
1957 src = conf->params_source->elts; | |
1958 for (i = 0; i < conf->params_source->nelts; i++) { | |
1959 | |
1960 if (ngx_http_script_variables_count(&src[i].value) == 0) { | |
1961 copy = ngx_array_push_n(conf->params_len, | |
1962 sizeof(ngx_http_script_copy_code_t)); | |
1963 if (copy == NULL) { | |
1964 return NGX_CONF_ERROR; | |
1965 } | |
1966 | |
1967 copy->code = (ngx_http_script_code_pt) | |
1968 ngx_http_script_copy_len_code; | |
1969 copy->len = src[i].key.len; | |
1970 | |
1971 | |
1972 copy = ngx_array_push_n(conf->params_len, | |
1973 sizeof(ngx_http_script_copy_code_t)); | |
1974 if (copy == NULL) { | |
1975 return NGX_CONF_ERROR; | |
1976 } | |
1977 | |
1978 copy->code = (ngx_http_script_code_pt) | |
1979 ngx_http_script_copy_len_code; | |
1980 copy->len = src[i].value.len; | |
1981 | |
1982 | |
1983 size = (sizeof(ngx_http_script_copy_code_t) | |
1984 + src[i].key.len + src[i].value.len | |
1985 + sizeof(uintptr_t) - 1) | |
1986 & ~(sizeof(uintptr_t) - 1); | |
1987 | |
1988 copy = ngx_array_push_n(conf->params, size); | |
1989 if (copy == NULL) { | |
1990 return NGX_CONF_ERROR; | |
1991 } | |
577 | 1992 |
509 | 1993 copy->code = ngx_http_script_copy_code; |
1994 copy->len = src[i].key.len + src[i].value.len; | |
1995 | |
1996 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
1997 | |
1998 p = ngx_cpymem(p, src[i].key.data, src[i].key.len); | |
1999 ngx_memcpy(p, src[i].value.data, src[i].value.len); | |
2000 | |
2001 } else { | |
2002 copy = ngx_array_push_n(conf->params_len, | |
2003 sizeof(ngx_http_script_copy_code_t)); | |
2004 if (copy == NULL) { | |
2005 return NGX_CONF_ERROR; | |
2006 } | |
2007 | |
2008 copy->code = (ngx_http_script_code_pt) | |
2009 ngx_http_script_copy_len_code; | |
2010 copy->len = src[i].key.len; | |
2011 | |
2012 | |
2013 size = (sizeof(ngx_http_script_copy_code_t) | |
2014 + src[i].key.len + sizeof(uintptr_t) - 1) | |
2015 & ~(sizeof(uintptr_t) - 1); | |
2016 | |
2017 copy = ngx_array_push_n(conf->params, size); | |
2018 if (copy == NULL) { | |
2019 return NGX_CONF_ERROR; | |
2020 } | |
577 | 2021 |
509 | 2022 copy->code = ngx_http_script_copy_code; |
2023 copy->len = src[i].key.len; | |
2024 | |
2025 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
2026 ngx_memcpy(p, src[i].key.data, src[i].key.len); | |
2027 | |
2028 | |
2029 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
2030 | |
2031 sc.cf = cf; | |
2032 sc.source = &src[i].value; | |
573 | 2033 sc.flushes = &conf->flushes; |
509 | 2034 sc.lengths = &conf->params_len; |
2035 sc.values = &conf->params; | |
2036 | |
2037 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
2038 return NGX_CONF_ERROR; | |
2039 } | |
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 | |
2049 | |
2050 code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); | |
2051 if (code == NULL) { | |
2052 return NGX_CONF_ERROR; | |
2053 } | |
2054 | |
2055 *code = (uintptr_t) NULL; | |
2056 } | |
2057 | |
2058 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
2059 if (code == NULL) { | |
2060 return NGX_CONF_ERROR; | |
2061 } | |
2062 | |
2063 *code = (uintptr_t) NULL; | |
2064 | |
479 | 2065 return NGX_CONF_OK; |
2066 } | |
509 | 2067 |
2068 | |
573 | 2069 static ngx_int_t |
2070 ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, | |
2071 ngx_http_variable_value_t *v, uintptr_t data) | |
509 | 2072 { |
2073 u_char *p; | |
2074 ngx_http_fastcgi_loc_conf_t *flcf; | |
2075 | |
1097
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2076 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
|
2077 v->valid = 1; |
1565 | 2078 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
|
2079 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
|
2080 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2081 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
|
2082 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2083 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
|
2084 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
|
2085 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
|
2086 return NGX_OK; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2087 } |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2088 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2089 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
|
2090 |
2049 | 2091 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
|
2092 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
|
2093 return NGX_ERROR; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2094 } |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2095 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2096 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
|
2097 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
|
2098 |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2099 } else { |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2100 v->len = 0; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2101 v->valid = 1; |
1565 | 2102 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
|
2103 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
|
2104 v->data = NULL; |
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2105 |
573 | 2106 return NGX_OK; |
509 | 2107 } |
2108 | |
573 | 2109 return NGX_OK; |
509 | 2110 } |
2111 | |
2112 | |
2113 static char * | |
2114 ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2115 { | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2116 ngx_http_fastcgi_loc_conf_t *flcf = conf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2117 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2118 ngx_url_t u; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2119 ngx_str_t *value, *url; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2120 ngx_uint_t n; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2121 ngx_http_core_loc_conf_t *clcf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2122 ngx_http_script_compile_t sc; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2123 |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2390
diff
changeset
|
2124 if (flcf->upstream.upstream || flcf->fastcgi_lengths) { |
555 | 2125 return "is duplicate"; |
2126 } | |
2127 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2128 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
|
2129 clcf->handler = ngx_http_fastcgi_handler; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2130 |
509 | 2131 value = cf->args->elts; |
2132 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2133 url = &value[1]; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2134 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2135 n = ngx_http_script_variables_count(url); |
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 if (n) { |
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 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2140 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2141 sc.cf = cf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2142 sc.source = url; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2143 sc.lengths = &flcf->fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2144 sc.values = &flcf->fastcgi_values; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2145 sc.variables = n; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2146 sc.complete_lengths = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2147 sc.complete_values = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2148 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2149 if (ngx_http_script_compile(&sc) != NGX_OK) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2150 return NGX_CONF_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2151 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2152 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2153 return NGX_CONF_OK; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2154 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2155 |
651 | 2156 ngx_memzero(&u, sizeof(ngx_url_t)); |
2157 | |
2158 u.url = value[1]; | |
884 | 2159 u.no_resolve = 1; |
2160 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2161 flcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2162 if (flcf->upstream.upstream == NULL) { |
509 | 2163 return NGX_CONF_ERROR; |
2164 } | |
2165 | |
2166 if (clcf->name.data[clcf->name.len - 1] == '/') { | |
2167 clcf->auto_redirect = 1; | |
2168 } | |
2169 | |
2170 return NGX_CONF_OK; | |
2171 } | |
2172 | |
2173 | |
2174 static char * | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2175 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
|
2176 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2177 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
|
2178 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2179 ngx_str_t *value; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2180 ngx_http_script_compile_t sc; |
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 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
|
2183 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2184 return "is duplicate"; |
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 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2187 value = cf->args->elts; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2188 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2189 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
|
2190 flcf->upstream.store = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2191 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2192 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2193 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2194 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
|
2195 flcf->upstream.store = 0; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2196 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2197 } |
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 /* include the terminating '\0' into script */ |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2200 value[1].len++; |
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 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
|
2203 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2204 sc.cf = cf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2205 sc.source = &value[1]; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2206 sc.lengths = &flcf->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2207 sc.values = &flcf->upstream.store_values; |
1563
022ec9420f80
style fix: remove double semicolons
Igor Sysoev <igor@sysoev.ru>
parents:
1488
diff
changeset
|
2208 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
|
2209 sc.complete_lengths = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2210 sc.complete_values = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2211 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2212 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
|
2213 return NGX_CONF_ERROR; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2214 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2215 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2216 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2217 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2218 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2219 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2220 static char * |
509 | 2221 ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data) |
2222 { | |
2223 #if (NGX_FREEBSD) | |
2224 ssize_t *np = data; | |
2225 | |
673 | 2226 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { |
509 | 2227 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2228 "\"fastcgi_send_lowat\" must be less than %d " | |
2229 "(sysctl net.inet.tcp.sendspace)", | |
2230 ngx_freebsd_net_inet_tcp_sendspace); | |
2231 | |
2232 return NGX_CONF_ERROR; | |
2233 } | |
2234 | |
2235 #elif !(NGX_HAVE_SO_SNDLOWAT) | |
2236 ssize_t *np = data; | |
2237 | |
2238 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
2239 "\"fastcgi_send_lowat\" is not supported, ignored"); | |
2240 | |
2241 *np = 0; | |
2242 | |
2243 #endif | |
2244 | |
2245 return NGX_CONF_OK; | |
2246 } | |
884 | 2247 |
2248 | |
2249 static char * | |
2250 ngx_http_fastcgi_upstream_max_fails_unsupported(ngx_conf_t *cf, | |
2251 ngx_command_t *cmd, void *conf) | |
2252 { | |
2253 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2254 "\"fastcgi_upstream_max_fails\" is not supported, " | |
2255 "use the \"max_fails\" parameter of the \"server\" directive ", | |
2256 "inside the \"upstream\" block"); | |
2257 | |
2258 return NGX_CONF_ERROR; | |
2259 } | |
2260 | |
2261 | |
2262 static char * | |
2263 ngx_http_fastcgi_upstream_fail_timeout_unsupported(ngx_conf_t *cf, | |
2264 ngx_command_t *cmd, void *conf) | |
2265 { | |
2266 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2267 "\"fastcgi_upstream_fail_timeout\" is not supported, " | |
2268 "use the \"fail_timeout\" parameter of the \"server\" directive ", | |
2269 "inside the \"upstream\" block"); | |
2270 | |
2271 return NGX_CONF_ERROR; | |
2272 } |