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