Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_fastcgi_module.c @ 4858:5e789d8b009d stable-1.2
Merge of r4833: limit req: fix of rbtree node insertion.
Limit req: fix of rbtree node insertion on hash collisions.
The rbtree used in ngx_http_limit_req_module has two level of keys, the top is
hash, and the next is the value string itself. However, when inserting a new
node, only hash has been set, while the value string has been left empty.
The bug was introduced in r4419 (1.1.14).
Found by Charles Chen.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 24 Sep 2012 19:11:45 +0000 |
parents | 9be0b6b749ae |
children | 4251e72b8bb4 |
rev | line source |
---|---|
479 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
479 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_http.h> | |
11 | |
12 | |
13 typedef struct { | |
651 | 14 ngx_http_upstream_conf_t upstream; |
15 | |
16 ngx_str_t index; | |
17 | |
18 ngx_array_t *flushes; | |
19 ngx_array_t *params_len; | |
20 ngx_array_t *params; | |
21 ngx_array_t *params_source; | |
1228 | 22 ngx_array_t *catch_stderr; |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
23 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
24 ngx_array_t *fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
25 ngx_array_t *fastcgi_values; |
2443 | 26 |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
27 ngx_hash_t headers_hash; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
28 ngx_uint_t header_params; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
29 |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
30 ngx_flag_t keep_conn; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
31 |
2602 | 32 #if (NGX_HTTP_CACHE) |
33 ngx_http_complex_value_t cache_key; | |
34 #endif | |
35 | |
2443 | 36 #if (NGX_PCRE) |
37 ngx_regex_t *split_regex; | |
38 ngx_str_t split_name; | |
39 #endif | |
479 | 40 } ngx_http_fastcgi_loc_conf_t; |
41 | |
42 | |
43 typedef enum { | |
44 ngx_http_fastcgi_st_version = 0, | |
45 ngx_http_fastcgi_st_type, | |
46 ngx_http_fastcgi_st_request_id_hi, | |
47 ngx_http_fastcgi_st_request_id_lo, | |
48 ngx_http_fastcgi_st_content_length_hi, | |
49 ngx_http_fastcgi_st_content_length_lo, | |
50 ngx_http_fastcgi_st_padding_length, | |
51 ngx_http_fastcgi_st_reserved, | |
52 ngx_http_fastcgi_st_data, | |
515 | 53 ngx_http_fastcgi_st_padding |
479 | 54 } ngx_http_fastcgi_state_e; |
55 | |
56 | |
57 typedef struct { | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
58 u_char *start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
59 u_char *end; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
60 } ngx_http_fastcgi_split_part_t; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
61 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
62 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
63 typedef struct { |
651 | 64 ngx_http_fastcgi_state_e state; |
65 u_char *pos; | |
66 u_char *last; | |
67 ngx_uint_t type; | |
68 size_t length; | |
69 size_t padding; | |
70 | |
3460
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
71 unsigned fastcgi_stdout:1; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
72 unsigned large_stderr:1; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
73 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
74 ngx_array_t *split_parts; |
2443 | 75 |
76 ngx_str_t script_name; | |
77 ngx_str_t path_info; | |
479 | 78 } ngx_http_fastcgi_ctx_t; |
79 | |
80 | |
81 #define NGX_HTTP_FASTCGI_RESPONDER 1 | |
82 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
83 #define NGX_HTTP_FASTCGI_KEEP_CONN 1 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
84 |
479 | 85 #define NGX_HTTP_FASTCGI_BEGIN_REQUEST 1 |
86 #define NGX_HTTP_FASTCGI_ABORT_REQUEST 2 | |
87 #define NGX_HTTP_FASTCGI_END_REQUEST 3 | |
88 #define NGX_HTTP_FASTCGI_PARAMS 4 | |
89 #define NGX_HTTP_FASTCGI_STDIN 5 | |
90 #define NGX_HTTP_FASTCGI_STDOUT 6 | |
91 #define NGX_HTTP_FASTCGI_STDERR 7 | |
92 #define NGX_HTTP_FASTCGI_DATA 8 | |
93 | |
94 | |
95 typedef struct { | |
96 u_char version; | |
97 u_char type; | |
98 u_char request_id_hi; | |
99 u_char request_id_lo; | |
100 u_char content_length_hi; | |
101 u_char content_length_lo; | |
102 u_char padding_length; | |
103 u_char reserved; | |
104 } ngx_http_fastcgi_header_t; | |
105 | |
106 | |
107 typedef struct { | |
108 u_char role_hi; | |
109 u_char role_lo; | |
110 u_char flags; | |
111 u_char reserved[5]; | |
112 } ngx_http_fastcgi_begin_request_t; | |
113 | |
114 | |
509 | 115 typedef struct { |
116 u_char version; | |
117 u_char type; | |
118 u_char request_id_hi; | |
119 u_char request_id_lo; | |
120 } ngx_http_fastcgi_header_small_t; | |
121 | |
122 | |
123 typedef struct { | |
124 ngx_http_fastcgi_header_t h0; | |
125 ngx_http_fastcgi_begin_request_t br; | |
126 ngx_http_fastcgi_header_small_t h1; | |
127 } ngx_http_fastcgi_request_start_t; | |
128 | |
129 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
130 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
|
131 ngx_http_fastcgi_loc_conf_t *flcf); |
2602 | 132 #if (NGX_HTTP_CACHE) |
133 static ngx_int_t ngx_http_fastcgi_create_key(ngx_http_request_t *r); | |
134 #endif | |
479 | 135 static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r); |
136 static ngx_int_t ngx_http_fastcgi_reinit_request(ngx_http_request_t *r); | |
137 static ngx_int_t ngx_http_fastcgi_process_header(ngx_http_request_t *r); | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
138 static ngx_int_t ngx_http_fastcgi_input_filter_init(void *data); |
479 | 139 static ngx_int_t ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, |
487 | 140 ngx_buf_t *buf); |
479 | 141 static ngx_int_t ngx_http_fastcgi_process_record(ngx_http_request_t *r, |
487 | 142 ngx_http_fastcgi_ctx_t *f); |
479 | 143 static void ngx_http_fastcgi_abort_request(ngx_http_request_t *r); |
144 static void ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, | |
487 | 145 ngx_int_t rc); |
479 | 146 |
509 | 147 static ngx_int_t ngx_http_fastcgi_add_variables(ngx_conf_t *cf); |
148 static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf); | |
149 static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, | |
150 void *parent, void *child); | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
151 static ngx_int_t ngx_http_fastcgi_merge_params(ngx_conf_t *cf, |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
152 ngx_http_fastcgi_loc_conf_t *conf, ngx_http_fastcgi_loc_conf_t *prev); |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
153 |
573 | 154 static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, |
155 ngx_http_variable_value_t *v, uintptr_t data); | |
2443 | 156 static ngx_int_t ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r, |
157 ngx_http_variable_value_t *v, uintptr_t data); | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
158 static ngx_http_fastcgi_ctx_t *ngx_http_fastcgi_split(ngx_http_request_t *r, |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
159 ngx_http_fastcgi_loc_conf_t *flcf); |
509 | 160 |
479 | 161 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, |
487 | 162 void *conf); |
2443 | 163 static char *ngx_http_fastcgi_split_path_info(ngx_conf_t *cf, |
164 ngx_command_t *cmd, void *conf); | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
165 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
|
166 void *conf); |
2602 | 167 #if (NGX_HTTP_CACHE) |
168 static char *ngx_http_fastcgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, | |
169 void *conf); | |
170 static char *ngx_http_fastcgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, | |
171 void *conf); | |
172 #endif | |
173 | |
479 | 174 static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, |
487 | 175 void *data); |
479 | 176 |
177 | |
509 | 178 static ngx_conf_post_t ngx_http_fastcgi_lowat_post = |
179 { ngx_http_fastcgi_lowat_check }; | |
479 | 180 |
181 | |
182 static ngx_conf_bitmask_t ngx_http_fastcgi_next_upstream_masks[] = { | |
183 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, | |
184 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, | |
185 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, | |
186 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, | |
623 | 187 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 }, |
479 | 188 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, |
2927
55ceaef03d34
proxy_cache_use_stale/fastcgi_cache_use_stale updating
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
189 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING }, |
665 | 190 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, |
479 | 191 { ngx_null_string, 0 } |
192 }; | |
193 | |
194 | |
2602 | 195 ngx_module_t ngx_http_fastcgi_module; |
196 | |
197 | |
479 | 198 static ngx_command_t ngx_http_fastcgi_commands[] = { |
199 | |
200 { ngx_string("fastcgi_pass"), | |
629 | 201 NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1, |
479 | 202 ngx_http_fastcgi_pass, |
203 NGX_HTTP_LOC_CONF_OFFSET, | |
204 0, | |
205 NULL }, | |
206 | |
207 { ngx_string("fastcgi_index"), | |
208 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
209 ngx_conf_set_str_slot, | |
210 NGX_HTTP_LOC_CONF_OFFSET, | |
211 offsetof(ngx_http_fastcgi_loc_conf_t, index), | |
212 NULL }, | |
213 | |
2443 | 214 { ngx_string("fastcgi_split_path_info"), |
215 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
216 ngx_http_fastcgi_split_path_info, | |
217 NGX_HTTP_LOC_CONF_OFFSET, | |
218 0, | |
219 NULL }, | |
220 | |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
221 { ngx_string("fastcgi_store"), |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
222 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
|
223 ngx_http_fastcgi_store, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
224 NGX_HTTP_LOC_CONF_OFFSET, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
225 0, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
226 NULL }, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
227 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
228 { ngx_string("fastcgi_store_access"), |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
229 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
|
230 ngx_conf_set_access_slot, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
231 NGX_HTTP_LOC_CONF_OFFSET, |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
232 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
|
233 NULL }, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
234 |
629 | 235 { ngx_string("fastcgi_ignore_client_abort"), |
236 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
237 ngx_conf_set_flag_slot, | |
238 NGX_HTTP_LOC_CONF_OFFSET, | |
239 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.ignore_client_abort), | |
240 NULL }, | |
241 | |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3197
diff
changeset
|
242 { ngx_string("fastcgi_bind"), |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3197
diff
changeset
|
243 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3399 | 244 ngx_http_upstream_bind_set_slot, |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3197
diff
changeset
|
245 NGX_HTTP_LOC_CONF_OFFSET, |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3197
diff
changeset
|
246 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.local), |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3197
diff
changeset
|
247 NULL }, |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3197
diff
changeset
|
248 |
479 | 249 { ngx_string("fastcgi_connect_timeout"), |
250 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
251 ngx_conf_set_msec_slot, | |
252 NGX_HTTP_LOC_CONF_OFFSET, | |
253 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.connect_timeout), | |
254 NULL }, | |
255 | |
256 { ngx_string("fastcgi_send_timeout"), | |
257 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
258 ngx_conf_set_msec_slot, | |
259 NGX_HTTP_LOC_CONF_OFFSET, | |
260 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_timeout), | |
261 NULL }, | |
262 | |
263 { ngx_string("fastcgi_send_lowat"), | |
264 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
265 ngx_conf_set_size_slot, | |
266 NGX_HTTP_LOC_CONF_OFFSET, | |
267 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_lowat), | |
268 &ngx_http_fastcgi_lowat_post }, | |
269 | |
581 | 270 { ngx_string("fastcgi_buffer_size"), |
271 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
272 ngx_conf_set_size_slot, | |
273 NGX_HTTP_LOC_CONF_OFFSET, | |
274 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.buffer_size), | |
275 NULL }, | |
276 | |
509 | 277 { ngx_string("fastcgi_pass_request_headers"), |
278 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
279 ngx_conf_set_flag_slot, | |
280 NGX_HTTP_LOC_CONF_OFFSET, | |
281 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_headers), | |
282 NULL }, | |
283 | |
284 { ngx_string("fastcgi_pass_request_body"), | |
285 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
286 ngx_conf_set_flag_slot, | |
287 NGX_HTTP_LOC_CONF_OFFSET, | |
288 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_body), | |
289 NULL }, | |
290 | |
657 | 291 { ngx_string("fastcgi_intercept_errors"), |
292 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
293 ngx_conf_set_flag_slot, | |
294 NGX_HTTP_LOC_CONF_OFFSET, | |
295 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.intercept_errors), | |
296 NULL }, | |
297 | |
479 | 298 { ngx_string("fastcgi_read_timeout"), |
299 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
300 ngx_conf_set_msec_slot, | |
301 NGX_HTTP_LOC_CONF_OFFSET, | |
302 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.read_timeout), | |
303 NULL }, | |
304 | |
305 { ngx_string("fastcgi_buffers"), | |
306 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
307 ngx_conf_set_bufs_slot, | |
308 NGX_HTTP_LOC_CONF_OFFSET, | |
309 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.bufs), | |
310 NULL }, | |
311 | |
312 { ngx_string("fastcgi_busy_buffers_size"), | |
313 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
314 ngx_conf_set_size_slot, | |
315 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 316 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size_conf), |
479 | 317 NULL }, |
318 | |
2602 | 319 #if (NGX_HTTP_CACHE) |
320 | |
321 { ngx_string("fastcgi_cache"), | |
3729 | 322 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
2602 | 323 ngx_http_fastcgi_cache, |
324 NGX_HTTP_LOC_CONF_OFFSET, | |
325 0, | |
326 NULL }, | |
327 | |
328 { ngx_string("fastcgi_cache_key"), | |
3729 | 329 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
2602 | 330 ngx_http_fastcgi_cache_key, |
331 NGX_HTTP_LOC_CONF_OFFSET, | |
332 0, | |
333 NULL }, | |
334 | |
335 { ngx_string("fastcgi_cache_path"), | |
336 NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE, | |
337 ngx_http_file_cache_set_slot, | |
338 0, | |
339 0, | |
340 &ngx_http_fastcgi_module }, | |
341 | |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
342 { ngx_string("fastcgi_cache_bypass"), |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
343 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
344 ngx_http_set_predicate_slot, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
345 NGX_HTTP_LOC_CONF_OFFSET, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
346 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_bypass), |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
347 NULL }, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
348 |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
349 { ngx_string("fastcgi_no_cache"), |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
350 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
3692
045ea40cbfe8
use ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3670
diff
changeset
|
351 ngx_http_set_predicate_slot, |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
352 NGX_HTTP_LOC_CONF_OFFSET, |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
353 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.no_cache), |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
354 NULL }, |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
355 |
2602 | 356 { ngx_string("fastcgi_cache_valid"), |
357 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
358 ngx_http_file_cache_valid_set_slot, | |
359 NGX_HTTP_LOC_CONF_OFFSET, | |
360 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_valid), | |
361 NULL }, | |
362 | |
2729 | 363 { ngx_string("fastcgi_cache_min_uses"), |
2602 | 364 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
365 ngx_conf_set_num_slot, | |
366 NGX_HTTP_LOC_CONF_OFFSET, | |
367 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_min_uses), | |
368 NULL }, | |
369 | |
370 { ngx_string("fastcgi_cache_use_stale"), | |
371 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
372 ngx_conf_set_bitmask_slot, | |
373 NGX_HTTP_LOC_CONF_OFFSET, | |
374 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_use_stale), | |
375 &ngx_http_fastcgi_next_upstream_masks }, | |
376 | |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
377 { ngx_string("fastcgi_cache_methods"), |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
378 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
379 ngx_conf_set_bitmask_slot, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
380 NGX_HTTP_LOC_CONF_OFFSET, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
381 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_methods), |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
382 &ngx_http_upstream_cache_method_mask }, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
383 |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
384 { ngx_string("fastcgi_cache_lock"), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
385 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
386 ngx_conf_set_flag_slot, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
387 NGX_HTTP_LOC_CONF_OFFSET, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
388 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_lock), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
389 NULL }, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
390 |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
391 { ngx_string("fastcgi_cache_lock_timeout"), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
392 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
393 ngx_conf_set_msec_slot, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
394 NGX_HTTP_LOC_CONF_OFFSET, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
395 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_lock_timeout), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
396 NULL }, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
397 |
2602 | 398 #endif |
399 | |
479 | 400 { ngx_string("fastcgi_temp_path"), |
401 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | |
402 ngx_conf_set_path_slot, | |
403 NGX_HTTP_LOC_CONF_OFFSET, | |
404 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_path), | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
405 NULL }, |
479 | 406 |
407 { ngx_string("fastcgi_max_temp_file_size"), | |
408 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
409 ngx_conf_set_size_slot, | |
410 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 411 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.max_temp_file_size_conf), |
479 | 412 NULL }, |
413 | |
414 { ngx_string("fastcgi_temp_file_write_size"), | |
415 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
416 ngx_conf_set_size_slot, | |
417 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 418 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.temp_file_write_size_conf), |
479 | 419 NULL }, |
420 | |
421 { ngx_string("fastcgi_next_upstream"), | |
547 | 422 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
479 | 423 ngx_conf_set_bitmask_slot, |
424 NGX_HTTP_LOC_CONF_OFFSET, | |
425 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream), | |
426 &ngx_http_fastcgi_next_upstream_masks }, | |
427 | |
509 | 428 { ngx_string("fastcgi_param"), |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
429 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23, |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
430 ngx_http_upstream_param_set_slot, |
485 | 431 NGX_HTTP_LOC_CONF_OFFSET, |
509 | 432 offsetof(ngx_http_fastcgi_loc_conf_t, params_source), |
485 | 433 NULL }, |
434 | |
649 | 435 { ngx_string("fastcgi_pass_header"), |
3729 | 436 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
649 | 437 ngx_conf_set_str_array_slot, |
438 NGX_HTTP_LOC_CONF_OFFSET, | |
439 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_headers), | |
440 NULL }, | |
441 | |
442 { ngx_string("fastcgi_hide_header"), | |
3729 | 443 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
649 | 444 ngx_conf_set_str_array_slot, |
445 NGX_HTTP_LOC_CONF_OFFSET, | |
446 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.hide_headers), | |
447 NULL }, | |
448 | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
449 { ngx_string("fastcgi_ignore_headers"), |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
450 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
451 ngx_conf_set_bitmask_slot, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
452 NGX_HTTP_LOC_CONF_OFFSET, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
453 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.ignore_headers), |
3667
12bd9e26fadb
use shared ngx_http_upstream_ignore_headers_masks[]
Igor Sysoev <igor@sysoev.ru>
parents:
3610
diff
changeset
|
454 &ngx_http_upstream_ignore_headers_masks }, |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
455 |
1228 | 456 { ngx_string("fastcgi_catch_stderr"), |
4273
e444e8f6538b
Fixed NGX_CONF_TAKE1/NGX_CONF_FLAG misuse.
Sergey Budnevitch <sb@waeme.net>
parents:
4136
diff
changeset
|
457 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
1228 | 458 ngx_conf_set_str_array_slot, |
459 NGX_HTTP_LOC_CONF_OFFSET, | |
460 offsetof(ngx_http_fastcgi_loc_conf_t, catch_stderr), | |
461 NULL }, | |
462 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
463 { ngx_string("fastcgi_keep_conn"), |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
464 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
465 ngx_conf_set_flag_slot, |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
466 NGX_HTTP_LOC_CONF_OFFSET, |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
467 offsetof(ngx_http_fastcgi_loc_conf_t, keep_conn), |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
468 NULL }, |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
469 |
479 | 470 ngx_null_command |
471 }; | |
472 | |
473 | |
667 | 474 static ngx_http_module_t ngx_http_fastcgi_module_ctx = { |
509 | 475 ngx_http_fastcgi_add_variables, /* preconfiguration */ |
476 NULL, /* postconfiguration */ | |
479 | 477 |
478 NULL, /* create main configuration */ | |
479 NULL, /* init main configuration */ | |
480 | |
481 NULL, /* create server configuration */ | |
482 NULL, /* merge server configuration */ | |
483 | |
484 ngx_http_fastcgi_create_loc_conf, /* create location configuration */ | |
485 ngx_http_fastcgi_merge_loc_conf /* merge location configuration */ | |
486 }; | |
487 | |
488 | |
489 ngx_module_t ngx_http_fastcgi_module = { | |
509 | 490 NGX_MODULE_V1, |
479 | 491 &ngx_http_fastcgi_module_ctx, /* module context */ |
492 ngx_http_fastcgi_commands, /* module directives */ | |
493 NGX_HTTP_MODULE, /* module type */ | |
541 | 494 NULL, /* init master */ |
479 | 495 NULL, /* init module */ |
541 | 496 NULL, /* init process */ |
497 NULL, /* init thread */ | |
498 NULL, /* exit thread */ | |
499 NULL, /* exit process */ | |
500 NULL, /* exit master */ | |
501 NGX_MODULE_V1_PADDING | |
479 | 502 }; |
503 | |
504 | |
1883 | 505 static ngx_http_fastcgi_request_start_t ngx_http_fastcgi_request_start = { |
506 { 1, /* version */ | |
507 NGX_HTTP_FASTCGI_BEGIN_REQUEST, /* type */ | |
508 0, /* request_id_hi */ | |
509 1, /* request_id_lo */ | |
510 0, /* content_length_hi */ | |
511 sizeof(ngx_http_fastcgi_begin_request_t), /* content_length_lo */ | |
512 0, /* padding_length */ | |
513 0 }, /* reserved */ | |
514 | |
515 { 0, /* role_hi */ | |
516 NGX_HTTP_FASTCGI_RESPONDER, /* role_lo */ | |
517 0, /* NGX_HTTP_FASTCGI_KEEP_CONN */ /* flags */ | |
518 { 0, 0, 0, 0, 0 } }, /* reserved[5] */ | |
519 | |
520 { 1, /* version */ | |
521 NGX_HTTP_FASTCGI_PARAMS, /* type */ | |
522 0, /* request_id_hi */ | |
523 1 }, /* request_id_lo */ | |
524 | |
525 }; | |
526 | |
527 | |
2443 | 528 static ngx_http_variable_t ngx_http_fastcgi_vars[] = { |
529 | |
530 { ngx_string("fastcgi_script_name"), NULL, | |
531 ngx_http_fastcgi_script_name_variable, 0, | |
532 NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, | |
533 | |
534 { ngx_string("fastcgi_path_info"), NULL, | |
535 ngx_http_fastcgi_path_info_variable, 0, | |
536 NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, | |
537 | |
538 { ngx_null_string, NULL, NULL, 0, 0, 0 } | |
539 }; | |
1884 | 540 |
541 | |
649 | 542 static ngx_str_t ngx_http_fastcgi_hide_headers[] = { |
543 ngx_string("Status"), | |
544 ngx_string("X-Accel-Expires"), | |
545 ngx_string("X-Accel-Redirect"), | |
546 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
|
547 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
|
548 ngx_string("X-Accel-Charset"), |
649 | 549 ngx_null_string |
550 }; | |
551 | |
552 | |
3197
d5d1ad05d3a6
hide cacheable Set-Cookie and P3P FastCGI response headers
Igor Sysoev <igor@sysoev.ru>
parents:
3025
diff
changeset
|
553 #if (NGX_HTTP_CACHE) |
d5d1ad05d3a6
hide cacheable Set-Cookie and P3P FastCGI response headers
Igor Sysoev <igor@sysoev.ru>
parents:
3025
diff
changeset
|
554 |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
555 static ngx_keyval_t ngx_http_fastcgi_cache_headers[] = { |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
556 { ngx_string("HTTP_IF_MODIFIED_SINCE"), ngx_string("") }, |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
557 { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") }, |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
558 { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("") }, |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
559 { ngx_string("HTTP_IF_MATCH"), ngx_string("") }, |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
560 { ngx_string("HTTP_RANGE"), ngx_string("") }, |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
561 { ngx_string("HTTP_IF_RANGE"), ngx_string("") }, |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
562 { ngx_null_string, ngx_null_string } |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
563 }; |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
564 |
3197
d5d1ad05d3a6
hide cacheable Set-Cookie and P3P FastCGI response headers
Igor Sysoev <igor@sysoev.ru>
parents:
3025
diff
changeset
|
565 #endif |
d5d1ad05d3a6
hide cacheable Set-Cookie and P3P FastCGI response headers
Igor Sysoev <igor@sysoev.ru>
parents:
3025
diff
changeset
|
566 |
d5d1ad05d3a6
hide cacheable Set-Cookie and P3P FastCGI response headers
Igor Sysoev <igor@sysoev.ru>
parents:
3025
diff
changeset
|
567 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
568 static ngx_path_init_t ngx_http_fastcgi_temp_path = { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
569 ngx_string(NGX_HTTP_FASTCGI_TEMP_PATH), { 1, 2, 0 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
570 }; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
571 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
572 |
487 | 573 static ngx_int_t |
574 ngx_http_fastcgi_handler(ngx_http_request_t *r) | |
479 | 575 { |
576 ngx_int_t rc; | |
577 ngx_http_upstream_t *u; | |
2443 | 578 ngx_http_fastcgi_ctx_t *f; |
479 | 579 ngx_http_fastcgi_loc_conf_t *flcf; |
580 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
581 if (r->subrequest_in_memory) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
582 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
583 "ngx_http_fastcgi_module does not support " |
1635 | 584 "subrequest in memory"); |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
585 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
586 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
587 |
3006
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
588 if (ngx_http_upstream_create(r) != NGX_OK) { |
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
589 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
590 } |
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
591 |
2443 | 592 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); |
593 if (f == NULL) { | |
3006
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
594 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
2443 | 595 } |
596 | |
597 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); | |
2395
b1a24d3cf4dd
clear fastcgi ctx for internal redirection via named location
Igor Sysoev <igor@sysoev.ru>
parents:
2391
diff
changeset
|
598 |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
599 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
|
600 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
601 if (flcf->fastcgi_lengths) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
602 if (ngx_http_fastcgi_eval(r, flcf) != NGX_OK) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
603 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
604 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
605 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
606 |
3006
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
607 u = r->upstream; |
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
608 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3494
diff
changeset
|
609 ngx_str_set(&u->schema, "fastcgi://"); |
479 | 610 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module; |
611 | |
612 u->conf = &flcf->upstream; | |
613 | |
2602 | 614 #if (NGX_HTTP_CACHE) |
615 u->create_key = ngx_http_fastcgi_create_key; | |
616 #endif | |
479 | 617 u->create_request = ngx_http_fastcgi_create_request; |
618 u->reinit_request = ngx_http_fastcgi_reinit_request; | |
619 u->process_header = ngx_http_fastcgi_process_header; | |
620 u->abort_request = ngx_http_fastcgi_abort_request; | |
621 u->finalize_request = ngx_http_fastcgi_finalize_request; | |
4662
979e0f5b196d
Merge of r4616: r->state fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
622 r->state = 0; |
479 | 623 |
649 | 624 u->buffering = 1; |
625 | |
581 | 626 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); |
627 if (u->pipe == NULL) { | |
628 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
629 } | |
630 | |
631 u->pipe->input_filter = ngx_http_fastcgi_input_filter; | |
632 u->pipe->input_ctx = r; | |
479 | 633 |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
634 u->input_filter_init = ngx_http_fastcgi_input_filter_init; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
635 |
479 | 636 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init); |
637 | |
638 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
639 return rc; | |
640 } | |
641 | |
642 return NGX_DONE; | |
643 } | |
644 | |
645 | |
487 | 646 static ngx_int_t |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
647 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
|
648 { |
3610 | 649 ngx_url_t url; |
650 ngx_http_upstream_t *u; | |
651 | |
652 ngx_memzero(&url, sizeof(ngx_url_t)); | |
653 | |
654 if (ngx_http_script_run(r, &url.url, flcf->fastcgi_lengths->elts, 0, | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
655 flcf->fastcgi_values->elts) |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
656 == NULL) |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
657 { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
658 return NGX_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
659 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
660 |
3610 | 661 url.no_resolve = 1; |
662 | |
663 if (ngx_parse_url(r->pool, &url) != NGX_OK) { | |
664 if (url.err) { | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
665 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
3610 | 666 "%s in upstream \"%V\"", url.err, &url.url); |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
667 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
668 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
669 return NGX_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
670 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
671 |
3610 | 672 u = r->upstream; |
673 | |
674 u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t)); | |
675 if (u->resolved == NULL) { | |
676 return NGX_ERROR; | |
677 } | |
678 | |
679 if (url.addrs && url.addrs[0].sockaddr) { | |
680 u->resolved->sockaddr = url.addrs[0].sockaddr; | |
681 u->resolved->socklen = url.addrs[0].socklen; | |
682 u->resolved->naddrs = 1; | |
683 u->resolved->host = url.addrs[0].name; | |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
684 |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
685 } else { |
3610 | 686 u->resolved->host = url.host; |
687 u->resolved->port = url.port; | |
3879
502a6b0acf3f
fix case when a host in fastcgi_pass, scgi_pass, and uwsgi_pass
Igor Sysoev <igor@sysoev.ru>
parents:
3850
diff
changeset
|
688 u->resolved->no_port = url.no_port; |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
689 } |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
690 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
691 return NGX_OK; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
692 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
693 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
694 |
2602 | 695 #if (NGX_HTTP_CACHE) |
696 | |
697 static ngx_int_t | |
698 ngx_http_fastcgi_create_key(ngx_http_request_t *r) | |
699 { | |
700 ngx_str_t *key; | |
701 ngx_http_fastcgi_loc_conf_t *flcf; | |
702 | |
703 key = ngx_array_push(&r->cache->keys); | |
704 if (key == NULL) { | |
705 return NGX_ERROR; | |
706 } | |
707 | |
708 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); | |
709 | |
710 if (ngx_http_complex_value(r, &flcf->cache_key, key) != NGX_OK) { | |
711 return NGX_ERROR; | |
712 } | |
713 | |
714 return NGX_OK; | |
715 } | |
716 | |
717 #endif | |
718 | |
719 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
720 static ngx_int_t |
487 | 721 ngx_http_fastcgi_create_request(ngx_http_request_t *r) |
479 | 722 { |
509 | 723 off_t file_pos; |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
724 u_char ch, *pos, *lowcase_key; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
725 size_t size, len, key_len, val_len, padding, |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
726 allocated; |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
727 ngx_uint_t i, n, next, hash, skip_empty, header_params; |
509 | 728 ngx_buf_t *b; |
729 ngx_chain_t *cl, *body; | |
730 ngx_list_part_t *part; | |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
731 ngx_table_elt_t *header, **ignored; |
509 | 732 ngx_http_script_code_pt code; |
733 ngx_http_script_engine_t e, le; | |
734 ngx_http_fastcgi_header_t *h; | |
735 ngx_http_fastcgi_loc_conf_t *flcf; | |
736 ngx_http_script_len_code_pt lcode; | |
479 | 737 |
509 | 738 len = 0; |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
739 header_params = 0; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
740 ignored = NULL; |
485 | 741 |
479 | 742 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
743 | |
509 | 744 if (flcf->params_len) { |
745 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); | |
479 | 746 |
1565 | 747 ngx_http_script_flush_no_cacheable_variables(r, flcf->flushes); |
573 | 748 le.flushed = 1; |
749 | |
509 | 750 le.ip = flcf->params_len->elts; |
751 le.request = r; | |
479 | 752 |
509 | 753 while (*(uintptr_t *) le.ip) { |
487 | 754 |
509 | 755 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
756 key_len = lcode(&le); | |
479 | 757 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
758 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
759 skip_empty = lcode(&le); |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
760 |
509 | 761 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
762 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
763 } | |
764 le.ip += sizeof(uintptr_t); | |
479 | 765 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
766 if (skip_empty && val_len == 0) { |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
767 continue; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
768 } |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
769 |
537 | 770 len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len; |
485 | 771 } |
772 } | |
773 | |
509 | 774 if (flcf->upstream.pass_request_headers) { |
485 | 775 |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
776 allocated = 0; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
777 lowcase_key = NULL; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
778 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
779 if (flcf->header_params) { |
4015
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
780 n = 0; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
781 part = &r->headers_in.headers.part; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
782 |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
783 while (part) { |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
784 n += part->nelts; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
785 part = part->next; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
786 } |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
787 |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
788 ignored = ngx_palloc(r->pool, n * sizeof(void *)); |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
789 if (ignored == NULL) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
790 return NGX_ERROR; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
791 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
792 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
793 |
509 | 794 part = &r->headers_in.headers.part; |
795 header = part->elts; | |
796 | |
797 for (i = 0; /* void */; i++) { | |
479 | 798 |
509 | 799 if (i >= part->nelts) { |
800 if (part->next == NULL) { | |
801 break; | |
802 } | |
479 | 803 |
509 | 804 part = part->next; |
805 header = part->elts; | |
806 i = 0; | |
479 | 807 } |
808 | |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
809 if (flcf->header_params) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
810 if (allocated < header[i].key.len) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
811 allocated = header[i].key.len + 16; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
812 lowcase_key = ngx_pnalloc(r->pool, allocated); |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
813 if (lowcase_key == NULL) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
814 return NGX_ERROR; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
815 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
816 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
817 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
818 hash = 0; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
819 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
820 for (n = 0; n < header[i].key.len; n++) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
821 ch = header[i].key.data[n]; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
822 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
823 if (ch >= 'A' && ch <= 'Z') { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
824 ch |= 0x20; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
825 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
826 } else if (ch == '-') { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
827 ch = '_'; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
828 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
829 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
830 hash = ngx_hash(hash, ch); |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
831 lowcase_key[n] = ch; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
832 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
833 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
834 if (ngx_hash_find(&flcf->headers_hash, hash, lowcase_key, n)) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
835 ignored[header_params++] = &header[i]; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
836 continue; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
837 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
838 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
839 n += sizeof("HTTP_") - 1; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
840 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
841 } else { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
842 n = sizeof("HTTP_") - 1 + header[i].key.len; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
843 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
844 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
845 len += ((n > 127) ? 4 : 1) + ((header[i].value.len > 127) ? 4 : 1) |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
846 + n + header[i].value.len; |
479 | 847 } |
848 } | |
849 | |
850 | |
851 if (len > 65535) { | |
852 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
1678 | 853 "fastcgi request record is too big: %uz", len); |
479 | 854 return NGX_ERROR; |
855 } | |
856 | |
857 | |
858 padding = 8 - len % 8; | |
859 padding = (padding == 8) ? 0 : padding; | |
860 | |
861 | |
862 size = sizeof(ngx_http_fastcgi_header_t) | |
863 + sizeof(ngx_http_fastcgi_begin_request_t) | |
864 | |
865 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
866 + len + padding | |
867 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
868 | |
869 + sizeof(ngx_http_fastcgi_header_t); /* NGX_HTTP_FASTCGI_STDIN */ | |
870 | |
871 | |
501 | 872 b = ngx_create_temp_buf(r->pool, size); |
873 if (b == NULL) { | |
479 | 874 return NGX_ERROR; |
875 } | |
876 | |
501 | 877 cl = ngx_alloc_chain_link(r->pool); |
878 if (cl == NULL) { | |
479 | 879 return NGX_ERROR; |
880 } | |
881 | |
882 cl->buf = b; | |
883 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
884 ngx_http_fastcgi_request_start.br.flags = |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
885 flcf->keep_conn ? NGX_HTTP_FASTCGI_KEEP_CONN : 0; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
886 |
509 | 887 ngx_memcpy(b->pos, &ngx_http_fastcgi_request_start, |
888 sizeof(ngx_http_fastcgi_request_start_t)); | |
479 | 889 |
890 h = (ngx_http_fastcgi_header_t *) | |
891 (b->pos + sizeof(ngx_http_fastcgi_header_t) | |
892 + sizeof(ngx_http_fastcgi_begin_request_t)); | |
893 | |
894 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
895 h->content_length_lo = (u_char) (len & 0xff); | |
896 h->padding_length = (u_char) padding; | |
897 h->reserved = 0; | |
898 | |
899 b->last = b->pos + sizeof(ngx_http_fastcgi_header_t) | |
900 + sizeof(ngx_http_fastcgi_begin_request_t) | |
901 + sizeof(ngx_http_fastcgi_header_t); | |
902 | |
903 | |
509 | 904 if (flcf->params_len) { |
905 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); | |
479 | 906 |
509 | 907 e.ip = flcf->params->elts; |
908 e.pos = b->last; | |
909 e.request = r; | |
573 | 910 e.flushed = 1; |
479 | 911 |
509 | 912 le.ip = flcf->params_len->elts; |
479 | 913 |
509 | 914 while (*(uintptr_t *) le.ip) { |
479 | 915 |
509 | 916 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
917 key_len = (u_char) lcode(&le); | |
479 | 918 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
919 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
920 skip_empty = lcode(&le); |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
921 |
509 | 922 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
923 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
924 } | |
925 le.ip += sizeof(uintptr_t); | |
479 | 926 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
927 if (skip_empty && val_len == 0) { |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
928 e.skip = 1; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
929 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
930 while (*(uintptr_t *) e.ip) { |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
931 code = *(ngx_http_script_code_pt *) e.ip; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
932 code((ngx_http_script_engine_t *) &e); |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
933 } |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
934 e.ip += sizeof(uintptr_t); |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
935 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
936 e.skip = 0; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
937 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
938 continue; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
939 } |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
940 |
537 | 941 *e.pos++ = (u_char) key_len; |
479 | 942 |
537 | 943 if (val_len > 127) { |
944 *e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80); | |
945 *e.pos++ = (u_char) ((val_len >> 16) & 0xff); | |
946 *e.pos++ = (u_char) ((val_len >> 8) & 0xff); | |
947 *e.pos++ = (u_char) (val_len & 0xff); | |
479 | 948 |
537 | 949 } else { |
950 *e.pos++ = (u_char) val_len; | |
509 | 951 } |
479 | 952 |
509 | 953 while (*(uintptr_t *) e.ip) { |
954 code = *(ngx_http_script_code_pt *) e.ip; | |
955 code((ngx_http_script_engine_t *) &e); | |
956 } | |
957 e.ip += sizeof(uintptr_t); | |
1945 | 958 |
959 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
960 "fastcgi param: \"%*s: %*s\"", | |
961 key_len, e.pos - (key_len + val_len), | |
962 val_len, e.pos - val_len); | |
479 | 963 } |
964 | |
509 | 965 b->last = e.pos; |
487 | 966 } |
967 | |
968 | |
509 | 969 if (flcf->upstream.pass_request_headers) { |
479 | 970 |
509 | 971 part = &r->headers_in.headers.part; |
972 header = part->elts; | |
479 | 973 |
509 | 974 for (i = 0; /* void */; i++) { |
491 | 975 |
509 | 976 if (i >= part->nelts) { |
977 if (part->next == NULL) { | |
577 | 978 break; |
509 | 979 } |
577 | 980 |
509 | 981 part = part->next; |
982 header = part->elts; | |
983 i = 0; | |
984 } | |
479 | 985 |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
986 for (n = 0; n < header_params; n++) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
987 if (&header[i] == ignored[n]) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
988 goto next; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
989 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
990 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
991 |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
992 key_len = sizeof("HTTP_") - 1 + header[i].key.len; |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
993 if (key_len > 127) { |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
994 *b->last++ = (u_char) (((key_len >> 24) & 0x7f) | 0x80); |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
995 *b->last++ = (u_char) ((key_len >> 16) & 0xff); |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
996 *b->last++ = (u_char) ((key_len >> 8) & 0xff); |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
997 *b->last++ = (u_char) (key_len & 0xff); |
577 | 998 |
509 | 999 } else { |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1000 *b->last++ = (u_char) key_len; |
487 | 1001 } |
1002 | |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1003 val_len = header[i].value.len; |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1004 if (val_len > 127) { |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1005 *b->last++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80); |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1006 *b->last++ = (u_char) ((val_len >> 16) & 0xff); |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1007 *b->last++ = (u_char) ((val_len >> 8) & 0xff); |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1008 *b->last++ = (u_char) (val_len & 0xff); |
487 | 1009 |
509 | 1010 } else { |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1011 *b->last++ = (u_char) val_len; |
479 | 1012 } |
1013 | |
509 | 1014 b->last = ngx_cpymem(b->last, "HTTP_", sizeof("HTTP_") - 1); |
479 | 1015 |
509 | 1016 for (n = 0; n < header[i].key.len; n++) { |
1017 ch = header[i].key.data[n]; | |
479 | 1018 |
509 | 1019 if (ch >= 'a' && ch <= 'z') { |
1020 ch &= ~0x20; | |
479 | 1021 |
509 | 1022 } else if (ch == '-') { |
1023 ch = '_'; | |
1024 } | |
479 | 1025 |
509 | 1026 *b->last++ = ch; |
479 | 1027 } |
1028 | |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1029 b->last = ngx_copy(b->last, header[i].value.data, val_len); |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1030 |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1031 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1032 "fastcgi param: \"%*s: %*s\"", |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1033 key_len, b->last - (key_len + val_len), |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1034 val_len, b->last - val_len); |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
1035 next: |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
1036 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
1037 continue; |
479 | 1038 } |
1039 } | |
1040 | |
1041 | |
1042 if (padding) { | |
1043 ngx_memzero(b->last, padding); | |
1044 b->last += padding; | |
1045 } | |
1046 | |
1047 | |
1048 h = (ngx_http_fastcgi_header_t *) b->last; | |
1049 b->last += sizeof(ngx_http_fastcgi_header_t); | |
1050 | |
1051 h->version = 1; | |
1052 h->type = NGX_HTTP_FASTCGI_PARAMS; | |
1053 h->request_id_hi = 0; | |
1054 h->request_id_lo = 1; | |
1055 h->content_length_hi = 0; | |
1056 h->content_length_lo = 0; | |
1057 h->padding_length = 0; | |
1058 h->reserved = 0; | |
1059 | |
1060 h = (ngx_http_fastcgi_header_t *) b->last; | |
1061 b->last += sizeof(ngx_http_fastcgi_header_t); | |
1062 | |
509 | 1063 if (flcf->upstream.pass_request_body) { |
1064 body = r->upstream->request_bufs; | |
1065 r->upstream->request_bufs = cl; | |
479 | 1066 |
1067 #if (NGX_SUPPRESS_WARN) | |
509 | 1068 file_pos = 0; |
1069 pos = NULL; | |
479 | 1070 #endif |
1071 | |
509 | 1072 while (body) { |
479 | 1073 |
509 | 1074 if (body->buf->in_file) { |
1075 file_pos = body->buf->file_pos; | |
479 | 1076 |
509 | 1077 } else { |
1078 pos = body->buf->pos; | |
479 | 1079 } |
1080 | |
509 | 1081 next = 0; |
479 | 1082 |
509 | 1083 do { |
1084 b = ngx_alloc_buf(r->pool); | |
1085 if (b == NULL) { | |
1086 return NGX_ERROR; | |
479 | 1087 } |
1088 | |
509 | 1089 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); |
1090 | |
1091 if (body->buf->in_file) { | |
1092 b->file_pos = file_pos; | |
1093 file_pos += 32 * 1024; | |
479 | 1094 |
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
|
1095 if (file_pos >= body->buf->file_last) { |
509 | 1096 file_pos = body->buf->file_last; |
1097 next = 1; | |
1098 } | |
1099 | |
1100 b->file_last = file_pos; | |
1101 len = (ngx_uint_t) (file_pos - b->file_pos); | |
1102 | |
1103 } else { | |
1104 b->pos = pos; | |
1105 pos += 32 * 1024; | |
479 | 1106 |
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
|
1107 if (pos >= body->buf->last) { |
509 | 1108 pos = body->buf->last; |
1109 next = 1; | |
1110 } | |
1111 | |
1112 b->last = pos; | |
1113 len = (ngx_uint_t) (pos - b->pos); | |
1114 } | |
479 | 1115 |
509 | 1116 padding = 8 - len % 8; |
1117 padding = (padding == 8) ? 0 : padding; | |
479 | 1118 |
509 | 1119 h->version = 1; |
1120 h->type = NGX_HTTP_FASTCGI_STDIN; | |
1121 h->request_id_hi = 0; | |
1122 h->request_id_lo = 1; | |
1123 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
1124 h->content_length_lo = (u_char) (len & 0xff); | |
1125 h->padding_length = (u_char) padding; | |
1126 h->reserved = 0; | |
479 | 1127 |
509 | 1128 cl->next = ngx_alloc_chain_link(r->pool); |
1129 if (cl->next == NULL) { | |
1130 return NGX_ERROR; | |
1131 } | |
479 | 1132 |
509 | 1133 cl = cl->next; |
1134 cl->buf = b; | |
1135 | |
1136 b = ngx_create_temp_buf(r->pool, | |
1137 sizeof(ngx_http_fastcgi_header_t) | |
1138 + padding); | |
1139 if (b == NULL) { | |
1140 return NGX_ERROR; | |
1141 } | |
479 | 1142 |
509 | 1143 if (padding) { |
1144 ngx_memzero(b->last, padding); | |
1145 b->last += padding; | |
1146 } | |
1147 | |
1148 h = (ngx_http_fastcgi_header_t *) b->last; | |
1149 b->last += sizeof(ngx_http_fastcgi_header_t); | |
479 | 1150 |
509 | 1151 cl->next = ngx_alloc_chain_link(r->pool); |
1152 if (cl->next == NULL) { | |
1153 return NGX_ERROR; | |
1154 } | |
1155 | |
1156 cl = cl->next; | |
1157 cl->buf = b; | |
479 | 1158 |
509 | 1159 } while (!next); |
479 | 1160 |
509 | 1161 body = body->next; |
1162 } | |
479 | 1163 |
509 | 1164 } else { |
1165 r->upstream->request_bufs = cl; | |
479 | 1166 } |
1167 | |
1168 h->version = 1; | |
1169 h->type = NGX_HTTP_FASTCGI_STDIN; | |
1170 h->request_id_hi = 0; | |
1171 h->request_id_lo = 1; | |
1172 h->content_length_hi = 0; | |
1173 h->content_length_lo = 0; | |
1174 h->padding_length = 0; | |
1175 h->reserved = 0; | |
1176 | |
1177 cl->next = NULL; | |
1178 | |
1179 return NGX_OK; | |
1180 } | |
1181 | |
1182 | |
487 | 1183 static ngx_int_t |
1184 ngx_http_fastcgi_reinit_request(ngx_http_request_t *r) | |
479 | 1185 { |
1186 ngx_http_fastcgi_ctx_t *f; | |
1187 | |
1188 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
1189 | |
1190 if (f == NULL) { | |
1191 return NGX_OK; | |
1192 } | |
1193 | |
1194 f->state = ngx_http_fastcgi_st_version; | |
615 | 1195 f->fastcgi_stdout = 0; |
3460
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1196 f->large_stderr = 0; |
479 | 1197 |
4662
979e0f5b196d
Merge of r4616: r->state fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1198 r->state = 0; |
979e0f5b196d
Merge of r4616: r->state fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1199 |
479 | 1200 return NGX_OK; |
1201 } | |
1202 | |
1203 | |
507 | 1204 static ngx_int_t |
1205 ngx_http_fastcgi_process_header(ngx_http_request_t *r) | |
479 | 1206 { |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1207 u_char *p, *msg, *start, *last, |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1208 *part_start, *part_end; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1209 size_t size; |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1210 ngx_str_t *status_line, *pattern; |
509 | 1211 ngx_int_t rc, status; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1212 ngx_buf_t buf; |
649 | 1213 ngx_uint_t i; |
509 | 1214 ngx_table_elt_t *h; |
1215 ngx_http_upstream_t *u; | |
1216 ngx_http_fastcgi_ctx_t *f; | |
1217 ngx_http_upstream_header_t *hh; | |
1228 | 1218 ngx_http_fastcgi_loc_conf_t *flcf; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1219 ngx_http_fastcgi_split_part_t *part; |
509 | 1220 ngx_http_upstream_main_conf_t *umcf; |
479 | 1221 |
1222 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
1223 | |
509 | 1224 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); |
1225 | |
479 | 1226 u = r->upstream; |
1227 | |
1228 for ( ;; ) { | |
1229 | |
1230 if (f->state < ngx_http_fastcgi_st_data) { | |
1231 | |
581 | 1232 f->pos = u->buffer.pos; |
1233 f->last = u->buffer.last; | |
479 | 1234 |
1235 rc = ngx_http_fastcgi_process_record(r, f); | |
1236 | |
581 | 1237 u->buffer.pos = f->pos; |
1238 u->buffer.last = f->last; | |
479 | 1239 |
1240 if (rc == NGX_AGAIN) { | |
1241 return NGX_AGAIN; | |
1242 } | |
1243 | |
1244 if (rc == NGX_ERROR) { | |
1245 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1246 } | |
1247 | |
491 | 1248 if (f->type != NGX_HTTP_FASTCGI_STDOUT |
1249 && f->type != NGX_HTTP_FASTCGI_STDERR) | |
1250 { | |
479 | 1251 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1252 "upstream sent unexpected FastCGI record: %d", | |
1253 f->type); | |
1254 | |
1255 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1256 } | |
1257 | |
491 | 1258 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { |
479 | 1259 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
1260 "upstream prematurely closed FastCGI stdout"); |
479 | 1261 |
1262 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1263 } | |
1264 } | |
1265 | |
1266 if (f->state == ngx_http_fastcgi_st_padding) { | |
1267 | |
581 | 1268 if (u->buffer.pos + f->padding < u->buffer.last) { |
479 | 1269 f->state = ngx_http_fastcgi_st_version; |
581 | 1270 u->buffer.pos += f->padding; |
479 | 1271 |
1272 continue; | |
1273 } | |
1274 | |
581 | 1275 if (u->buffer.pos + f->padding == u->buffer.last) { |
479 | 1276 f->state = ngx_http_fastcgi_st_version; |
581 | 1277 u->buffer.pos = u->buffer.last; |
479 | 1278 |
1279 return NGX_AGAIN; | |
1280 } | |
1281 | |
581 | 1282 f->padding -= u->buffer.last - u->buffer.pos; |
1283 u->buffer.pos = u->buffer.last; | |
479 | 1284 |
1285 return NGX_AGAIN; | |
1286 } | |
1287 | |
491 | 1288 |
479 | 1289 /* f->state == ngx_http_fastcgi_st_data */ |
1290 | |
491 | 1291 if (f->type == NGX_HTTP_FASTCGI_STDERR) { |
1292 | |
1293 if (f->length) { | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1294 msg = u->buffer.pos; |
491 | 1295 |
581 | 1296 if (u->buffer.pos + f->length <= u->buffer.last) { |
1297 u->buffer.pos += f->length; | |
491 | 1298 f->length = 0; |
1299 f->state = ngx_http_fastcgi_st_padding; | |
1300 | |
577 | 1301 } else { |
581 | 1302 f->length -= u->buffer.last - u->buffer.pos; |
1303 u->buffer.pos = u->buffer.last; | |
491 | 1304 } |
1305 | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1306 for (p = u->buffer.pos - 1; msg < p; p--) { |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1307 if (*p != LF && *p != CR && *p != '.' && *p != ' ') { |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1308 break; |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1309 } |
491 | 1310 } |
1311 | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1312 p++; |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1313 |
491 | 1314 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1315 "FastCGI sent in stderr: \"%*s\"", p - msg, msg); |
491 | 1316 |
1228 | 1317 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
1318 | |
1319 if (flcf->catch_stderr) { | |
1320 pattern = flcf->catch_stderr->elts; | |
1321 | |
1322 for (i = 0; i < flcf->catch_stderr->nelts; i++) { | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1323 if (ngx_strnstr(msg, (char *) pattern[i].data, |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1324 p - msg) |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1325 != NULL) |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1326 { |
1700
7f3350b18e75
return NGX_HTTP_UPSTREAM_INVALID_HEADER instead of NGX_HTTP_BAD_GATEWAY
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
1327 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
1228 | 1328 } |
1329 } | |
1330 } | |
1331 | |
581 | 1332 if (u->buffer.pos == u->buffer.last) { |
615 | 1333 |
1334 if (!f->fastcgi_stdout) { | |
1335 | |
1336 /* | |
1337 * the special handling the large number | |
1338 * of the PHP warnings to not allocate memory | |
1339 */ | |
1340 | |
3460
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1341 #if (NGX_HTTP_CACHE) |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1342 if (r->cache) { |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1343 u->buffer.pos = u->buffer.start |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1344 + r->cache->header_start; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1345 } else { |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1346 u->buffer.pos = u->buffer.start; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1347 } |
3850
ca7b9caa20e5
fix large stderr handling without http cache
Igor Sysoev <igor@sysoev.ru>
parents:
3735
diff
changeset
|
1348 #else |
ca7b9caa20e5
fix large stderr handling without http cache
Igor Sysoev <igor@sysoev.ru>
parents:
3735
diff
changeset
|
1349 u->buffer.pos = u->buffer.start; |
3460
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1350 #endif |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1351 u->buffer.last = u->buffer.pos; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1352 f->large_stderr = 1; |
615 | 1353 } |
1354 | |
491 | 1355 return NGX_AGAIN; |
1356 } | |
1357 | |
1358 } else { | |
4663
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1359 if (f->padding) { |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1360 f->state = ngx_http_fastcgi_st_padding; |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1361 } else { |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1362 f->state = ngx_http_fastcgi_st_version; |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1363 } |
491 | 1364 } |
1365 | |
1366 continue; | |
1367 } | |
1368 | |
1369 | |
1370 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1371 | |
3460
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1372 #if (NGX_HTTP_CACHE) |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1373 |
3469
08a66ba99191
fix segfault if there was non cached large FastCGI stderr output before header,
Igor Sysoev <igor@sysoev.ru>
parents:
3460
diff
changeset
|
1374 if (f->large_stderr && r->cache) { |
3494
67b8a4e0d7e1
fix building without HTTP cache, the bug had been introduced in r3461
Igor Sysoev <igor@sysoev.ru>
parents:
3469
diff
changeset
|
1375 u_char *start; |
67b8a4e0d7e1
fix building without HTTP cache, the bug had been introduced in r3461
Igor Sysoev <igor@sysoev.ru>
parents:
3469
diff
changeset
|
1376 ssize_t len; |
67b8a4e0d7e1
fix building without HTTP cache, the bug had been introduced in r3461
Igor Sysoev <igor@sysoev.ru>
parents:
3469
diff
changeset
|
1377 ngx_http_fastcgi_header_t *fh; |
3460
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1378 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1379 start = u->buffer.start + r->cache->header_start; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1380 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1381 len = u->buffer.pos - start - 2 * sizeof(ngx_http_fastcgi_header_t); |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1382 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1383 /* |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1384 * A tail of large stderr output before HTTP header is placed |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1385 * in a cache file without a FastCGI record header. |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1386 * To workaround it we put a dummy FastCGI record header at the |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1387 * start of the stderr output or update r->cache_header_start, |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1388 * if there is no enough place for the record header. |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1389 */ |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1390 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1391 if (len >= 0) { |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1392 fh = (ngx_http_fastcgi_header_t *) start; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1393 fh->version = 1; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1394 fh->type = NGX_HTTP_FASTCGI_STDERR; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1395 fh->request_id_hi = 0; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1396 fh->request_id_lo = 1; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1397 fh->content_length_hi = (u_char) ((len >> 8) & 0xff); |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1398 fh->content_length_lo = (u_char) (len & 0xff); |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1399 fh->padding_length = 0; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1400 fh->reserved = 0; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1401 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1402 } else { |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1403 r->cache->header_start += u->buffer.pos - start |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1404 - sizeof(ngx_http_fastcgi_header_t); |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1405 } |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1406 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1407 f->large_stderr = 0; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1408 } |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1409 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1410 #endif |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1411 |
615 | 1412 f->fastcgi_stdout = 1; |
1413 | |
581 | 1414 start = u->buffer.pos; |
479 | 1415 |
581 | 1416 if (u->buffer.pos + f->length < u->buffer.last) { |
479 | 1417 |
1418 /* | |
581 | 1419 * set u->buffer.last to the end of the FastCGI record data |
479 | 1420 * for ngx_http_parse_header_line() |
1421 */ | |
1422 | |
581 | 1423 last = u->buffer.last; |
1424 u->buffer.last = u->buffer.pos + f->length; | |
479 | 1425 |
1426 } else { | |
1427 last = NULL; | |
1428 } | |
1429 | |
1430 for ( ;; ) { | |
1431 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1432 part_start = u->buffer.pos; |
3011
5957e869f04d
fix a garbage in a split fastcgi header
Igor Sysoev <igor@sysoev.ru>
parents:
3010
diff
changeset
|
1433 part_end = u->buffer.last; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1434 |
2256 | 1435 rc = ngx_http_parse_header_line(r, &u->buffer, 1); |
479 | 1436 |
1437 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1438 "http fastcgi parser: %d", rc); | |
1439 | |
1440 if (rc == NGX_AGAIN) { | |
1441 break; | |
1442 } | |
1443 | |
1444 if (rc == NGX_OK) { | |
1445 | |
1446 /* a header line has been parsed successfully */ | |
1447 | |
509 | 1448 h = ngx_list_push(&u->headers_in.headers); |
501 | 1449 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
|
1450 return NGX_ERROR; |
479 | 1451 } |
1452 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1453 if (f->split_parts && f->split_parts->nelts) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1454 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1455 part = f->split_parts->elts; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1456 size = u->buffer.pos - part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1457 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1458 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
|
1459 size += part[i].end - part[i].start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1460 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1461 |
2049 | 1462 p = ngx_pnalloc(r->pool, size); |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1463 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
|
1464 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1465 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1466 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1467 buf.pos = p; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1468 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1469 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
|
1470 p = ngx_cpymem(p, part[i].start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1471 part[i].end - part[i].start); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1472 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1473 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1474 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
|
1475 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1476 buf.last = p; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1477 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1478 f->split_parts->nelts = 0; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1479 |
2256 | 1480 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
|
1481 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1482 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
|
1483 h->key.data = r->header_name_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1484 h->key.data[h->key.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1485 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1486 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
|
1487 h->value.data = r->header_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1488 h->value.data[h->value.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1489 |
2049 | 1490 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
|
1491 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
|
1492 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1493 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1494 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1495 } else { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1496 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1497 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
|
1498 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
|
1499 |
2049 | 1500 h->key.data = ngx_pnalloc(r->pool, |
1501 h->key.len + 1 + h->value.len + 1 | |
1502 + h->key.len); | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1503 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
|
1504 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1505 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1506 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1507 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
|
1508 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
|
1509 + h->value.len + 1; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1510 |
4529
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
1511 ngx_memcpy(h->key.data, r->header_name_start, h->key.len); |
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
1512 h->key.data[h->key.len] = '\0'; |
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
1513 ngx_memcpy(h->value.data, r->header_start, h->value.len); |
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
1514 h->value.data[h->value.len] = '\0'; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1515 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1516 |
509 | 1517 h->hash = r->header_hash; |
1518 | |
649 | 1519 if (h->key.len == r->lowcase_index) { |
1520 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1521 | |
1522 } else { | |
2135 | 1523 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); |
479 | 1524 } |
1525 | |
649 | 1526 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, |
1527 h->lowcase_key, h->key.len); | |
1528 | |
1529 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
|
1530 return NGX_ERROR; |
649 | 1531 } |
1532 | |
479 | 1533 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1534 "http fastcgi header: \"%V: %V\"", | |
1535 &h->key, &h->value); | |
1536 | |
615 | 1537 if (u->buffer.pos < u->buffer.last) { |
1538 continue; | |
1539 } | |
1540 | |
1541 /* the end of the FastCGI record */ | |
1542 | |
1543 break; | |
479 | 1544 } |
1545 | |
1546 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
1547 | |
1548 /* a whole header has been parsed successfully */ | |
1549 | |
1550 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1551 "http fastcgi header done"); | |
1552 | |
509 | 1553 if (u->headers_in.status) { |
1554 status_line = &u->headers_in.status->value; | |
479 | 1555 |
1556 status = ngx_atoi(status_line->data, 3); | |
1557 | |
1558 if (status == NGX_ERROR) { | |
1698
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1559 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
|
1560 "upstream sent invalid status \"%V\"", |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1561 status_line); |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1562 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
479 | 1563 } |
1564 | |
529 | 1565 u->headers_in.status_n = status; |
1566 u->headers_in.status_line = *status_line; | |
479 | 1567 |
2140
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1568 } 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
|
1569 u->headers_in.status_n = 302; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3494
diff
changeset
|
1570 ngx_str_set(&u->headers_in.status_line, |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3494
diff
changeset
|
1571 "302 Moved Temporarily"); |
2140
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1572 |
479 | 1573 } else { |
529 | 1574 u->headers_in.status_n = 200; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3494
diff
changeset
|
1575 ngx_str_set(&u->headers_in.status_line, "200 OK"); |
479 | 1576 } |
1577 | |
2602 | 1578 if (u->state) { |
1579 u->state->status = u->headers_in.status_n; | |
479 | 1580 } |
1581 | |
1582 break; | |
1583 } | |
1584 | |
1585 /* there was error while a header line parsing */ | |
1586 | |
1587 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
619 | 1588 "upstream sent invalid header"); |
479 | 1589 |
1590 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1591 } | |
1592 | |
1593 if (last) { | |
581 | 1594 u->buffer.last = last; |
479 | 1595 } |
1596 | |
581 | 1597 f->length -= u->buffer.pos - start; |
479 | 1598 |
1599 if (f->length == 0) { | |
1600 if (f->padding) { | |
1601 f->state = ngx_http_fastcgi_st_padding; | |
1602 } else { | |
1603 f->state = ngx_http_fastcgi_st_version; | |
1604 } | |
1605 } | |
1606 | |
615 | 1607 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { |
1608 return NGX_OK; | |
1609 } | |
1610 | |
1274 | 1611 if (rc == NGX_OK) { |
1998
63c60504c0bf
fix error introduced in r1273 and r1275:
Igor Sysoev <igor@sysoev.ru>
parents:
1945
diff
changeset
|
1612 continue; |
615 | 1613 } |
1614 | |
1274 | 1615 /* rc == NGX_AGAIN */ |
1616 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1617 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
|
1618 "upstream split a header line in FastCGI records"); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1619 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1620 if (f->split_parts == NULL) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1621 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
|
1622 sizeof(ngx_http_fastcgi_split_part_t)); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1623 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
|
1624 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1625 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1626 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1627 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1628 part = ngx_array_push(f->split_parts); |
4852
9be0b6b749ae
Merge of r4785, r4795, r4811, r4812, r4816, r4822: coverity.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4663
diff
changeset
|
1629 if (part == NULL) { |
9be0b6b749ae
Merge of r4785, r4795, r4811, r4812, r4816, r4822: coverity.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4663
diff
changeset
|
1630 return NGX_ERROR; |
9be0b6b749ae
Merge of r4785, r4795, r4811, r4812, r4816, r4822: coverity.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4663
diff
changeset
|
1631 } |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1632 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1633 part->start = part_start; |
3011
5957e869f04d
fix a garbage in a split fastcgi header
Igor Sysoev <igor@sysoev.ru>
parents:
3010
diff
changeset
|
1634 part->end = part_end; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1635 |
3010
37400c84396e
continue to parse available fastcgi record after a split header,
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
1636 if (u->buffer.pos < u->buffer.last) { |
37400c84396e
continue to parse available fastcgi record after a split header,
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
1637 continue; |
37400c84396e
continue to parse available fastcgi record after a split header,
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
1638 } |
37400c84396e
continue to parse available fastcgi record after a split header,
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
1639 |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1640 return NGX_AGAIN; |
479 | 1641 } |
1642 } | |
1643 | |
1644 | |
487 | 1645 static ngx_int_t |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1646 ngx_http_fastcgi_input_filter_init(void *data) |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1647 { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1648 ngx_http_request_t *r = data; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1649 ngx_http_fastcgi_loc_conf_t *flcf; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1650 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1651 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1652 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1653 r->upstream->pipe->length = flcf->keep_conn ? |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1654 (off_t) sizeof(ngx_http_fastcgi_header_t) : -1; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1655 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1656 return NGX_OK; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1657 } |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1658 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1659 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1660 static ngx_int_t |
487 | 1661 ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) |
479 | 1662 { |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1663 u_char *m, *msg; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1664 ngx_int_t rc; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1665 ngx_buf_t *b, **prev; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1666 ngx_chain_t *cl; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1667 ngx_http_request_t *r; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1668 ngx_http_fastcgi_ctx_t *f; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1669 ngx_http_fastcgi_loc_conf_t *flcf; |
479 | 1670 |
1671 if (buf->pos == buf->last) { | |
1672 return NGX_OK; | |
1673 } | |
1674 | |
1675 r = p->input_ctx; | |
1676 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1677 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
479 | 1678 |
1679 b = NULL; | |
483 | 1680 prev = &buf->shadow; |
479 | 1681 |
1682 f->pos = buf->pos; | |
1683 f->last = buf->last; | |
1684 | |
1685 for ( ;; ) { | |
1686 if (f->state < ngx_http_fastcgi_st_data) { | |
1687 | |
1688 rc = ngx_http_fastcgi_process_record(r, f); | |
1689 | |
1690 if (rc == NGX_AGAIN) { | |
1691 break; | |
1692 } | |
1693 | |
1694 if (rc == NGX_ERROR) { | |
1695 return NGX_ERROR; | |
1696 } | |
1697 | |
1698 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { | |
4663
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1699 |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1700 if (f->padding) { |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1701 f->state = ngx_http_fastcgi_st_padding; |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1702 } else { |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1703 f->state = ngx_http_fastcgi_st_version; |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1704 } |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1705 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1706 if (!flcf->keep_conn) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1707 p->upstream_done = 1; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1708 } |
479 | 1709 |
1710 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | |
1711 "http fastcgi closed stdout"); | |
1712 | |
1713 continue; | |
1714 } | |
1715 | |
1716 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { | |
4663
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1717 |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1718 if (f->padding) { |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1719 f->state = ngx_http_fastcgi_st_padding; |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1720 } else { |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1721 f->state = ngx_http_fastcgi_st_version; |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1722 } |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1723 |
479 | 1724 p->upstream_done = 1; |
1725 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1726 if (flcf->keep_conn) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1727 r->upstream->keepalive = 1; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1728 } |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1729 |
479 | 1730 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, |
1731 "http fastcgi sent end request"); | |
1732 | |
1733 break; | |
1734 } | |
1735 } | |
1736 | |
1737 | |
1738 if (f->state == ngx_http_fastcgi_st_padding) { | |
1739 | |
1740 if (f->pos + f->padding < f->last) { | |
1741 f->state = ngx_http_fastcgi_st_version; | |
1742 f->pos += f->padding; | |
1743 | |
1744 continue; | |
1745 } | |
1746 | |
1747 if (f->pos + f->padding == f->last) { | |
1748 f->state = ngx_http_fastcgi_st_version; | |
1749 | |
1750 break; | |
1751 } | |
1752 | |
1753 f->padding -= f->last - f->pos; | |
1754 | |
1755 break; | |
1756 } | |
1757 | |
1758 | |
1759 /* f->state == ngx_http_fastcgi_st_data */ | |
1760 | |
1761 if (f->type == NGX_HTTP_FASTCGI_STDERR) { | |
1762 | |
1763 if (f->length) { | |
639 | 1764 |
1765 if (f->pos == f->last) { | |
1766 break; | |
1767 } | |
1768 | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1769 msg = f->pos; |
479 | 1770 |
1771 if (f->pos + f->length <= f->last) { | |
1772 f->pos += f->length; | |
491 | 1773 f->length = 0; |
1774 f->state = ngx_http_fastcgi_st_padding; | |
479 | 1775 |
577 | 1776 } else { |
479 | 1777 f->length -= f->last - f->pos; |
1778 f->pos = f->last; | |
1779 } | |
1780 | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1781 for (m = f->pos - 1; msg < m; m--) { |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1782 if (*m != LF && *m != CR && *m != '.' && *m != ' ') { |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1783 break; |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1784 } |
491 | 1785 } |
479 | 1786 |
1787 ngx_log_error(NGX_LOG_ERR, p->log, 0, | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1788 "FastCGI sent in stderr: \"%*s\"", |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1789 m + 1 - msg, msg); |
479 | 1790 |
1791 if (f->pos == f->last) { | |
1792 break; | |
1793 } | |
491 | 1794 |
1795 } else { | |
4663
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1796 if (f->padding) { |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1797 f->state = ngx_http_fastcgi_st_padding; |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1798 } else { |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1799 f->state = ngx_http_fastcgi_st_version; |
b9ea486e543f
Merge of r4617: fastcgi padding fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4662
diff
changeset
|
1800 } |
479 | 1801 } |
1802 | |
1803 continue; | |
1804 } | |
1805 | |
1806 | |
1807 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1808 | |
639 | 1809 if (f->pos == f->last) { |
1810 break; | |
1811 } | |
1812 | |
479 | 1813 if (p->free) { |
4136
7898857ff34b
Fixed loss of chain links in fastcgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4122
diff
changeset
|
1814 cl = p->free; |
7898857ff34b
Fixed loss of chain links in fastcgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4122
diff
changeset
|
1815 b = cl->buf; |
7898857ff34b
Fixed loss of chain links in fastcgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4122
diff
changeset
|
1816 p->free = cl->next; |
7898857ff34b
Fixed loss of chain links in fastcgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4122
diff
changeset
|
1817 ngx_free_chain(p->pool, cl); |
479 | 1818 |
1819 } else { | |
501 | 1820 b = ngx_alloc_buf(p->pool); |
1821 if (b == NULL) { | |
479 | 1822 return NGX_ERROR; |
1823 } | |
1824 } | |
1825 | |
1826 ngx_memzero(b, sizeof(ngx_buf_t)); | |
1827 | |
1828 b->pos = f->pos; | |
483 | 1829 b->start = buf->start; |
1830 b->end = buf->end; | |
479 | 1831 b->tag = p->tag; |
1832 b->temporary = 1; | |
1833 b->recycled = 1; | |
483 | 1834 |
1835 *prev = b; | |
1836 prev = &b->shadow; | |
479 | 1837 |
501 | 1838 cl = ngx_alloc_chain_link(p->pool); |
1839 if (cl == NULL) { | |
479 | 1840 return NGX_ERROR; |
1841 } | |
1842 | |
1843 cl->buf = b; | |
1844 cl->next = NULL; | |
1845 | |
501 | 1846 if (p->in) { |
1847 *p->last_in = cl; | |
1848 } else { | |
1849 p->in = cl; | |
1850 } | |
1851 p->last_in = &cl->next; | |
1852 | |
1853 | |
483 | 1854 /* STUB */ b->num = buf->num; |
1855 | |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1856 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1857 "input buf #%d %p", b->num, b->pos); |
479 | 1858 |
1859 if (f->pos + f->length < f->last) { | |
1860 | |
1861 if (f->padding) { | |
1862 f->state = ngx_http_fastcgi_st_padding; | |
1863 } else { | |
1864 f->state = ngx_http_fastcgi_st_version; | |
1865 } | |
1866 | |
1867 f->pos += f->length; | |
1868 b->last = f->pos; | |
1869 | |
1870 continue; | |
1871 } | |
1872 | |
1873 if (f->pos + f->length == f->last) { | |
1874 | |
1875 if (f->padding) { | |
1876 f->state = ngx_http_fastcgi_st_padding; | |
1877 } else { | |
1878 f->state = ngx_http_fastcgi_st_version; | |
1879 } | |
1880 | |
1881 b->last = f->last; | |
1882 | |
1883 break; | |
1884 } | |
1885 | |
1886 f->length -= f->last - f->pos; | |
1887 | |
1888 b->last = f->last; | |
1889 | |
1890 break; | |
1891 | |
1892 } | |
1893 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1894 if (flcf->keep_conn) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1895 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1896 /* set p->length, minimal amount of data we want to see */ |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1897 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1898 if (f->state < ngx_http_fastcgi_st_data) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1899 p->length = 1; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1900 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1901 } else if (f->state == ngx_http_fastcgi_st_padding) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1902 p->length = f->padding; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1903 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1904 } else { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1905 /* ngx_http_fastcgi_st_data */ |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1906 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1907 p->length = f->length; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1908 } |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1909 } |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1910 |
479 | 1911 if (b) { |
483 | 1912 b->shadow = buf; |
479 | 1913 b->last_shadow = 1; |
483 | 1914 |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1915 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1916 "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
|
1917 |
483 | 1918 return NGX_OK; |
1919 } | |
1920 | |
1921 /* there is no data record in the buf, add it to free chain */ | |
1922 | |
1923 if (ngx_event_pipe_add_free_buf(p, buf) != NGX_OK) { | |
1924 return NGX_ERROR; | |
479 | 1925 } |
1926 | |
1927 return NGX_OK; | |
1928 } | |
1929 | |
1930 | |
487 | 1931 static ngx_int_t |
1932 ngx_http_fastcgi_process_record(ngx_http_request_t *r, | |
1933 ngx_http_fastcgi_ctx_t *f) | |
479 | 1934 { |
1935 u_char ch, *p; | |
1936 ngx_http_fastcgi_state_e state; | |
1937 | |
1938 state = f->state; | |
1939 | |
1940 for (p = f->pos; p < f->last; p++) { | |
1941 | |
1942 ch = *p; | |
1943 | |
1944 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1945 "http fastcgi record byte: %02Xd", ch); | |
1946 | |
1947 switch (state) { | |
1948 | |
1949 case ngx_http_fastcgi_st_version: | |
1950 if (ch != 1) { | |
1951 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1952 "upstream sent unsupported FastCGI " | |
1953 "protocol version: %d", ch); | |
1954 return NGX_ERROR; | |
1955 } | |
1956 state = ngx_http_fastcgi_st_type; | |
1957 break; | |
1958 | |
1959 case ngx_http_fastcgi_st_type: | |
1960 switch (ch) { | |
1961 case NGX_HTTP_FASTCGI_STDOUT: | |
1962 case NGX_HTTP_FASTCGI_STDERR: | |
1963 case NGX_HTTP_FASTCGI_END_REQUEST: | |
1964 f->type = (ngx_uint_t) ch; | |
1965 break; | |
1966 default: | |
1967 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1968 "upstream sent invalid FastCGI " | |
1969 "record type: %d", ch); | |
1970 return NGX_ERROR; | |
1971 | |
1972 } | |
1973 state = ngx_http_fastcgi_st_request_id_hi; | |
1974 break; | |
1975 | |
1976 /* we support the single request per connection */ | |
1977 | |
1978 case ngx_http_fastcgi_st_request_id_hi: | |
1979 if (ch != 0) { | |
1980 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1981 "upstream sent unexpected FastCGI " | |
1982 "request id high byte: %d", ch); | |
1983 return NGX_ERROR; | |
1984 } | |
1985 state = ngx_http_fastcgi_st_request_id_lo; | |
1986 break; | |
1987 | |
1988 case ngx_http_fastcgi_st_request_id_lo: | |
1989 if (ch != 1) { | |
1990 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1991 "upstream sent unexpected FastCGI " | |
1992 "request id low byte: %d", ch); | |
1993 return NGX_ERROR; | |
1994 } | |
1995 state = ngx_http_fastcgi_st_content_length_hi; | |
1996 break; | |
1997 | |
1998 case ngx_http_fastcgi_st_content_length_hi: | |
1999 f->length = ch << 8; | |
2000 state = ngx_http_fastcgi_st_content_length_lo; | |
2001 break; | |
2002 | |
2003 case ngx_http_fastcgi_st_content_length_lo: | |
2004 f->length |= (size_t) ch; | |
2005 state = ngx_http_fastcgi_st_padding_length; | |
2006 break; | |
2007 | |
2008 case ngx_http_fastcgi_st_padding_length: | |
2009 f->padding = (size_t) ch; | |
2010 state = ngx_http_fastcgi_st_reserved; | |
2011 break; | |
2012 | |
2013 case ngx_http_fastcgi_st_reserved: | |
2014 state = ngx_http_fastcgi_st_data; | |
2015 | |
2016 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2017 "http fastcgi record length: %z", f->length); | |
2018 | |
2019 f->pos = p + 1; | |
2020 f->state = state; | |
2021 | |
2022 return NGX_OK; | |
2023 | |
2024 /* suppress warning */ | |
2025 case ngx_http_fastcgi_st_data: | |
2026 case ngx_http_fastcgi_st_padding: | |
2027 break; | |
2028 } | |
2029 } | |
2030 | |
2031 f->state = state; | |
2032 | |
2033 return NGX_AGAIN; | |
2034 } | |
2035 | |
2036 | |
487 | 2037 static void |
2038 ngx_http_fastcgi_abort_request(ngx_http_request_t *r) | |
479 | 2039 { |
2040 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2041 "abort http fastcgi request"); | |
2042 | |
2043 return; | |
2044 } | |
2045 | |
2046 | |
487 | 2047 static void |
2048 ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
479 | 2049 { |
2050 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2051 "finalize http fastcgi request"); | |
2052 | |
2053 return; | |
2054 } | |
2055 | |
2056 | |
509 | 2057 static ngx_int_t |
2058 ngx_http_fastcgi_add_variables(ngx_conf_t *cf) | |
479 | 2059 { |
2443 | 2060 ngx_http_variable_t *var, *v; |
2061 | |
2062 for (v = ngx_http_fastcgi_vars; v->name.len; v++) { | |
2063 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
2064 if (var == NULL) { | |
2065 return NGX_ERROR; | |
2066 } | |
2067 | |
2068 var->get_handler = v->get_handler; | |
2069 var->data = v->data; | |
479 | 2070 } |
2071 | |
509 | 2072 return NGX_OK; |
479 | 2073 } |
2074 | |
2075 | |
487 | 2076 static void * |
2077 ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf) | |
479 | 2078 { |
2079 ngx_http_fastcgi_loc_conf_t *conf; | |
2080 | |
501 | 2081 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t)); |
2082 if (conf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2895
diff
changeset
|
2083 return NULL; |
479 | 2084 } |
2085 | |
2086 /* | |
2087 * set by ngx_pcalloc(): | |
2088 * | |
2089 * conf->upstream.bufs.num = 0; | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2090 * conf->upstream.ignore_headers = 0; |
479 | 2091 * conf->upstream.next_upstream = 0; |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2092 * conf->upstream.cache_use_stale = 0; |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2093 * conf->upstream.cache_methods = 0; |
479 | 2094 * conf->upstream.temp_path = NULL; |
649 | 2095 * conf->upstream.hide_headers_hash = { NULL, 0 }; |
509 | 2096 * conf->upstream.uri = { 0, NULL }; |
2097 * conf->upstream.location = NULL; | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2098 * conf->upstream.store_lengths = NULL; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2099 * conf->upstream.store_values = NULL; |
509 | 2100 * |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3494
diff
changeset
|
2101 * conf->index.len = { 0, NULL }; |
479 | 2102 */ |
2103 | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2104 conf->upstream.store = NGX_CONF_UNSET; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2105 conf->upstream.store_access = NGX_CONF_UNSET_UINT; |
581 | 2106 conf->upstream.buffering = NGX_CONF_UNSET; |
629 | 2107 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; |
581 | 2108 |
479 | 2109 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
2110 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
507 | 2111 conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC; |
2112 | |
479 | 2113 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; |
581 | 2114 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE; |
529 | 2115 |
2116 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
577 | 2117 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; |
529 | 2118 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; |
509 | 2119 |
2120 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
2121 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
2122 | |
2602 | 2123 #if (NGX_HTTP_CACHE) |
2124 conf->upstream.cache = NGX_CONF_UNSET_PTR; | |
2125 conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT; | |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
2126 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2127 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; |
2602 | 2128 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2129 conf->upstream.cache_lock = NGX_CONF_UNSET; |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2130 conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; |
2602 | 2131 #endif |
2132 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2133 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
|
2134 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
|
2135 |
657 | 2136 conf->upstream.intercept_errors = NGX_CONF_UNSET; |
479 | 2137 |
2138 /* "fastcgi_cyclic_temp_file" is disabled */ | |
2139 conf->upstream.cyclic_temp_file = 0; | |
2140 | |
1452
cd586e963db0
change ngx_conf_merge_ptr_value() and update fastcgi_catch_stderr
Igor Sysoev <igor@sysoev.ru>
parents:
1295
diff
changeset
|
2141 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
|
2142 |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
2143 conf->keep_conn = NGX_CONF_UNSET; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
2144 |
3976
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3879
diff
changeset
|
2145 ngx_str_set(&conf->upstream.module, "fastcgi"); |
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3879
diff
changeset
|
2146 |
479 | 2147 return conf; |
2148 } | |
2149 | |
2150 | |
487 | 2151 static char * |
2152 ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
479 | 2153 { |
2154 ngx_http_fastcgi_loc_conf_t *prev = parent; | |
2155 ngx_http_fastcgi_loc_conf_t *conf = child; | |
2156 | |
509 | 2157 size_t size; |
649 | 2158 ngx_hash_init_t hash; |
3731
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2159 ngx_http_core_loc_conf_t *clcf; |
479 | 2160 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2161 if (conf->upstream.store != 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2162 ngx_conf_merge_value(conf->upstream.store, |
2894 | 2163 prev->upstream.store, 0); |
1295
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 if (conf->upstream.store_lengths == NULL) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2166 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
|
2167 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
|
2168 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2169 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2170 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2171 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
|
2172 prev->upstream.store_access, 0600); |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
2173 |
581 | 2174 ngx_conf_merge_value(conf->upstream.buffering, |
2175 prev->upstream.buffering, 1); | |
2176 | |
629 | 2177 ngx_conf_merge_value(conf->upstream.ignore_client_abort, |
2178 prev->upstream.ignore_client_abort, 0); | |
2179 | |
479 | 2180 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
2181 prev->upstream.connect_timeout, 60000); | |
507 | 2182 |
479 | 2183 ngx_conf_merge_msec_value(conf->upstream.send_timeout, |
2184 prev->upstream.send_timeout, 60000); | |
2185 | |
2186 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
2187 prev->upstream.read_timeout, 60000); | |
2188 | |
507 | 2189 ngx_conf_merge_size_value(conf->upstream.send_lowat, |
2190 prev->upstream.send_lowat, 0); | |
479 | 2191 |
581 | 2192 ngx_conf_merge_size_value(conf->upstream.buffer_size, |
2193 prev->upstream.buffer_size, | |
479 | 2194 (size_t) ngx_pagesize); |
2195 | |
507 | 2196 |
479 | 2197 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, |
2198 8, ngx_pagesize); | |
2199 | |
2200 if (conf->upstream.bufs.num < 2) { | |
2201 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2202 "there must be at least 2 \"fastcgi_buffers\""); | |
2203 return NGX_CONF_ERROR; | |
2204 } | |
2205 | |
2206 | |
581 | 2207 size = conf->upstream.buffer_size; |
479 | 2208 if (size < conf->upstream.bufs.size) { |
2209 size = conf->upstream.bufs.size; | |
2210 } | |
2211 | |
2212 | |
529 | 2213 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, |
2214 prev->upstream.busy_buffers_size_conf, | |
479 | 2215 NGX_CONF_UNSET_SIZE); |
2216 | |
529 | 2217 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 2218 conf->upstream.busy_buffers_size = 2 * size; |
529 | 2219 } else { |
2220 conf->upstream.busy_buffers_size = | |
2221 conf->upstream.busy_buffers_size_conf; | |
2222 } | |
479 | 2223 |
529 | 2224 if (conf->upstream.busy_buffers_size < size) { |
479 | 2225 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2226 "\"fastcgi_busy_buffers_size\" must be equal to or greater than " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2227 "the maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 2228 "one of the \"fastcgi_buffers\""); |
2229 | |
2230 return NGX_CONF_ERROR; | |
529 | 2231 } |
479 | 2232 |
529 | 2233 if (conf->upstream.busy_buffers_size |
2234 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
479 | 2235 { |
2236 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2237 "\"fastcgi_busy_buffers_size\" must be less than " | |
2238 "the size of all \"fastcgi_buffers\" minus one buffer"); | |
2239 | |
2240 return NGX_CONF_ERROR; | |
2241 } | |
2242 | |
2243 | |
529 | 2244 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, |
2245 prev->upstream.temp_file_write_size_conf, | |
479 | 2246 NGX_CONF_UNSET_SIZE); |
2247 | |
529 | 2248 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 2249 conf->upstream.temp_file_write_size = 2 * size; |
529 | 2250 } else { |
2251 conf->upstream.temp_file_write_size = | |
2252 conf->upstream.temp_file_write_size_conf; | |
2253 } | |
479 | 2254 |
529 | 2255 if (conf->upstream.temp_file_write_size < size) { |
479 | 2256 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2257 "\"fastcgi_temp_file_write_size\" must be equal to or greater " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2258 "than the maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 2259 "one of the \"fastcgi_buffers\""); |
2260 | |
2261 return NGX_CONF_ERROR; | |
2262 } | |
2263 | |
2264 | |
529 | 2265 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, |
2266 prev->upstream.max_temp_file_size_conf, | |
479 | 2267 NGX_CONF_UNSET_SIZE); |
2268 | |
529 | 2269 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 2270 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; |
529 | 2271 } else { |
2272 conf->upstream.max_temp_file_size = | |
2273 conf->upstream.max_temp_file_size_conf; | |
2274 } | |
479 | 2275 |
529 | 2276 if (conf->upstream.max_temp_file_size != 0 |
2277 && conf->upstream.max_temp_file_size < size) | |
479 | 2278 { |
2279 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2280 "\"fastcgi_max_temp_file_size\" must be equal to zero to disable " | |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2281 "temporary files usage or must be equal to or greater than " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2282 "the maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 2283 "one of the \"fastcgi_buffers\""); |
2284 | |
2285 return NGX_CONF_ERROR; | |
2286 } | |
2287 | |
2288 | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2289 ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2290 prev->upstream.ignore_headers, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2291 NGX_CONF_BITMASK_SET); |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2292 |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2293 |
479 | 2294 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, |
487 | 2295 prev->upstream.next_upstream, |
2296 (NGX_CONF_BITMASK_SET | |
2297 |NGX_HTTP_UPSTREAM_FT_ERROR | |
2298 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
479 | 2299 |
665 | 2300 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { |
2301 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
2302 |NGX_HTTP_UPSTREAM_FT_OFF; | |
2303 } | |
2304 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2305 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path, |
479 | 2306 prev->upstream.temp_path, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2307 &ngx_http_fastcgi_temp_path) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2308 != NGX_OK) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2309 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2310 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2311 } |
479 | 2312 |
2602 | 2313 #if (NGX_HTTP_CACHE) |
2314 | |
2315 ngx_conf_merge_ptr_value(conf->upstream.cache, | |
2316 prev->upstream.cache, NULL); | |
2317 | |
2318 if (conf->upstream.cache && conf->upstream.cache->data == NULL) { | |
2319 ngx_shm_zone_t *shm_zone; | |
2320 | |
2321 shm_zone = conf->upstream.cache; | |
2322 | |
2323 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2324 "\"fastcgi_cache\" zone \"%V\" is unknown", | |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2661
diff
changeset
|
2325 &shm_zone->shm.name); |
2602 | 2326 |
2327 return NGX_CONF_ERROR; | |
2328 } | |
2329 | |
2330 ngx_conf_merge_uint_value(conf->upstream.cache_min_uses, | |
2331 prev->upstream.cache_min_uses, 1); | |
2332 | |
2333 ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale, | |
2334 prev->upstream.cache_use_stale, | |
2335 (NGX_CONF_BITMASK_SET | |
2336 |NGX_HTTP_UPSTREAM_FT_OFF)); | |
2337 | |
2338 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) { | |
2339 conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET | |
2340 |NGX_HTTP_UPSTREAM_FT_OFF; | |
2341 } | |
2342 | |
4401
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
2343 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_ERROR) { |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
2344 conf->upstream.cache_use_stale |= NGX_HTTP_UPSTREAM_FT_NOLIVE; |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
2345 } |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
2346 |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2347 if (conf->upstream.cache_methods == 0) { |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2348 conf->upstream.cache_methods = prev->upstream.cache_methods; |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2349 } |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2350 |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2351 conf->upstream.cache_methods |= NGX_HTTP_GET|NGX_HTTP_HEAD; |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2352 |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
2353 ngx_conf_merge_ptr_value(conf->upstream.cache_bypass, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
2354 prev->upstream.cache_bypass, NULL); |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
2355 |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2356 ngx_conf_merge_ptr_value(conf->upstream.no_cache, |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2357 prev->upstream.no_cache, NULL); |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2358 |
3700
e40453e6931b
add warnings for proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3699
diff
changeset
|
2359 if (conf->upstream.no_cache && conf->upstream.cache_bypass == NULL) { |
e40453e6931b
add warnings for proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3699
diff
changeset
|
2360 ngx_log_error(NGX_LOG_WARN, cf->log, 0, |
e40453e6931b
add warnings for proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3699
diff
changeset
|
2361 "\"fastcgi_no_cache\" functionality has been changed in 0.8.46, " |
e40453e6931b
add warnings for proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3699
diff
changeset
|
2362 "now it should be used together with \"fastcgi_cache_bypass\""); |
e40453e6931b
add warnings for proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3699
diff
changeset
|
2363 } |
e40453e6931b
add warnings for proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3699
diff
changeset
|
2364 |
2602 | 2365 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, |
2366 prev->upstream.cache_valid, NULL); | |
2367 | |
2661 | 2368 if (conf->cache_key.value.data == NULL) { |
2369 conf->cache_key = prev->cache_key; | |
2370 } | |
2371 | |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2372 ngx_conf_merge_value(conf->upstream.cache_lock, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2373 prev->upstream.cache_lock, 0); |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2374 |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2375 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2376 prev->upstream.cache_lock_timeout, 5000); |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2377 |
2602 | 2378 #endif |
2379 | |
509 | 2380 ngx_conf_merge_value(conf->upstream.pass_request_headers, |
2381 prev->upstream.pass_request_headers, 1); | |
2382 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
2383 prev->upstream.pass_request_body, 1); | |
2384 | |
657 | 2385 ngx_conf_merge_value(conf->upstream.intercept_errors, |
2386 prev->upstream.intercept_errors, 0); | |
509 | 2387 |
1228 | 2388 ngx_conf_merge_ptr_value(conf->catch_stderr, prev->catch_stderr, NULL); |
2389 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
2390 ngx_conf_merge_value(conf->keep_conn, prev->keep_conn, 0); |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
2391 |
507 | 2392 |
479 | 2393 ngx_conf_merge_str_value(conf->index, prev->index, ""); |
2394 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2395 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
|
2396 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
|
2397 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
|
2398 |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2399 if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream, |
3670
2728c4e4a9ae
do not use a cache headers set to hide
Igor Sysoev <igor@sysoev.ru>
parents:
3667
diff
changeset
|
2400 &prev->upstream, ngx_http_fastcgi_hide_headers, &hash) |
649 | 2401 != NGX_OK) |
2402 { | |
2403 return NGX_CONF_ERROR; | |
2404 } | |
2405 | |
884 | 2406 if (conf->upstream.upstream == NULL) { |
2407 conf->upstream.upstream = prev->upstream.upstream; | |
507 | 2408 } |
2409 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2410 if (conf->fastcgi_lengths == NULL) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2411 conf->fastcgi_lengths = prev->fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2412 conf->fastcgi_values = prev->fastcgi_values; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2413 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2414 |
3731
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2415 if (conf->upstream.upstream || conf->fastcgi_lengths) { |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2416 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2417 if (clcf->handler == NULL && clcf->lmt_excpt) { |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2418 clcf->handler = ngx_http_fastcgi_handler; |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2419 } |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2420 } |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2421 |
2443 | 2422 #if (NGX_PCRE) |
2423 if (conf->split_regex == NULL) { | |
2424 conf->split_regex = prev->split_regex; | |
2425 conf->split_name = prev->split_name; | |
2426 } | |
2427 #endif | |
2428 | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2429 if (ngx_http_fastcgi_merge_params(cf, conf, prev) != NGX_OK) { |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2430 return NGX_CONF_ERROR; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2431 } |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2432 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2433 return NGX_CONF_OK; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2434 } |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2435 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2436 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2437 static ngx_int_t |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2438 ngx_http_fastcgi_merge_params(ngx_conf_t *cf, |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2439 ngx_http_fastcgi_loc_conf_t *conf, ngx_http_fastcgi_loc_conf_t *prev) |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2440 { |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2441 u_char *p; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2442 size_t size; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2443 uintptr_t *code; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2444 ngx_uint_t i, nsrc; |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2445 ngx_array_t headers_names; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2446 #if (NGX_HTTP_CACHE) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2447 ngx_array_t params_merged; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2448 #endif |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2449 ngx_hash_key_t *hk; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2450 ngx_hash_init_t hash; |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2451 ngx_http_upstream_param_t *src; |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2452 ngx_http_script_compile_t sc; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2453 ngx_http_script_copy_code_t *copy; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2454 |
509 | 2455 if (conf->params_source == NULL) { |
573 | 2456 conf->params_source = prev->params_source; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2457 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2458 if (prev->headers_hash.buckets |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2459 #if (NGX_HTTP_CACHE) |
4522 | 2460 && ((conf->upstream.cache == NULL) |
2461 == (prev->upstream.cache == NULL)) | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2462 #endif |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2463 ) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2464 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2465 conf->flushes = prev->flushes; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2466 conf->params_len = prev->params_len; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2467 conf->params = prev->params; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2468 conf->headers_hash = prev->headers_hash; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2469 conf->header_params = prev->header_params; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2470 |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2471 return NGX_OK; |
509 | 2472 } |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2473 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2474 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2475 if (conf->params_source == NULL |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2476 #if (NGX_HTTP_CACHE) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2477 && (conf->upstream.cache == NULL) |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2478 #endif |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2479 ) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2480 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2481 conf->headers_hash.buckets = (void *) 1; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2482 return NGX_OK; |
509 | 2483 } |
2484 | |
2485 conf->params_len = ngx_array_create(cf->pool, 64, 1); | |
2486 if (conf->params_len == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2487 return NGX_ERROR; |
509 | 2488 } |
573 | 2489 |
509 | 2490 conf->params = ngx_array_create(cf->pool, 512, 1); |
2491 if (conf->params == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2492 return NGX_ERROR; |
509 | 2493 } |
2494 | |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2495 if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t)) |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2496 != NGX_OK) |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2497 { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2498 return NGX_ERROR; |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2499 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2500 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2501 if (conf->params_source) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2502 src = conf->params_source->elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2503 nsrc = conf->params_source->nelts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2504 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2505 } else { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2506 src = NULL; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2507 nsrc = 0; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2508 } |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2509 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2510 #if (NGX_HTTP_CACHE) |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2511 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2512 if (conf->upstream.cache) { |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2513 ngx_keyval_t *h; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2514 ngx_http_upstream_param_t *s; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2515 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2516 if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2517 sizeof(ngx_http_upstream_param_t)) |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2518 != NGX_OK) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2519 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2520 return NGX_ERROR; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2521 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2522 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2523 for (i = 0; i < nsrc; i++) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2524 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2525 s = ngx_array_push(¶ms_merged); |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2526 if (s == NULL) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2527 return NGX_ERROR; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2528 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2529 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2530 *s = src[i]; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2531 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2532 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2533 h = ngx_http_fastcgi_cache_headers; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2534 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2535 while (h->key.len) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2536 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2537 src = params_merged.elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2538 nsrc = params_merged.nelts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2539 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2540 for (i = 0; i < nsrc; i++) { |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2541 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2542 goto next; |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2543 } |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2544 } |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2545 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2546 s = ngx_array_push(¶ms_merged); |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2547 if (s == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2548 return NGX_ERROR; |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2549 } |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2550 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2551 s->key = h->key; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2552 s->value = h->value; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2553 s->skip_empty = 0; |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2554 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2555 next: |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2556 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2557 h++; |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2558 } |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2559 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2560 src = params_merged.elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2561 nsrc = params_merged.nelts; |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2562 } |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2563 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2564 #endif |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2565 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2566 for (i = 0; i < nsrc; i++) { |
509 | 2567 |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2568 if (src[i].key.len > sizeof("HTTP_") - 1 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2569 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2570 { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2571 hk = ngx_array_push(&headers_names); |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2572 if (hk == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2573 return NGX_ERROR; |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2574 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2575 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2576 hk->key.len = src[i].key.len - 5; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2577 hk->key.data = src[i].key.data + 5; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2578 hk->key_hash = ngx_hash_key_lc(hk->key.data, hk->key.len); |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2579 hk->value = (void *) 1; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2580 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2581 if (src[i].value.len == 0) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2582 continue; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2583 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2584 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2585 |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2586 copy = ngx_array_push_n(conf->params_len, |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2587 sizeof(ngx_http_script_copy_code_t)); |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2588 if (copy == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2589 return NGX_ERROR; |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2590 } |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2591 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2592 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2593 copy->len = src[i].key.len; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2594 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2595 copy = ngx_array_push_n(conf->params_len, |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2596 sizeof(ngx_http_script_copy_code_t)); |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2597 if (copy == NULL) { |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2598 return NGX_ERROR; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2599 } |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2600 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2601 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2602 copy->len = src[i].skip_empty; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2603 |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2604 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2605 size = (sizeof(ngx_http_script_copy_code_t) |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2606 + src[i].key.len + sizeof(uintptr_t) - 1) |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2607 & ~(sizeof(uintptr_t) - 1); |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2608 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2609 copy = ngx_array_push_n(conf->params, size); |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2610 if (copy == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2611 return NGX_ERROR; |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2612 } |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2613 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2614 copy->code = ngx_http_script_copy_code; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2615 copy->len = src[i].key.len; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2616 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2617 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2618 ngx_memcpy(p, src[i].key.data, src[i].key.len); |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2619 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2620 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2621 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2622 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2623 sc.cf = cf; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2624 sc.source = &src[i].value; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2625 sc.flushes = &conf->flushes; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2626 sc.lengths = &conf->params_len; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2627 sc.values = &conf->params; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2628 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2629 if (ngx_http_script_compile(&sc) != NGX_OK) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2630 return NGX_ERROR; |
509 | 2631 } |
2632 | |
2633 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
2634 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2635 return NGX_ERROR; |
509 | 2636 } |
2637 | |
2638 *code = (uintptr_t) NULL; | |
2639 | |
2640 | |
2641 code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); | |
2642 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2643 return NGX_ERROR; |
509 | 2644 } |
2645 | |
2646 *code = (uintptr_t) NULL; | |
2647 } | |
2648 | |
2649 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
2650 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2651 return NGX_ERROR; |
509 | 2652 } |
2653 | |
2654 *code = (uintptr_t) NULL; | |
2655 | |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2656 conf->header_params = headers_names.nelts; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2657 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2658 hash.hash = &conf->headers_hash; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2659 hash.key = ngx_hash_key_lc; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2660 hash.max_size = 512; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2661 hash.bucket_size = 64; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2662 hash.name = "fastcgi_params_hash"; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2663 hash.pool = cf->pool; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2664 hash.temp_pool = NULL; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2665 |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2666 return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); |
479 | 2667 } |
509 | 2668 |
2669 | |
573 | 2670 static ngx_int_t |
2671 ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, | |
2672 ngx_http_variable_value_t *v, uintptr_t data) | |
509 | 2673 { |
2674 u_char *p; | |
2443 | 2675 ngx_http_fastcgi_ctx_t *f; |
509 | 2676 ngx_http_fastcgi_loc_conf_t *flcf; |
2677 | |
2443 | 2678 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
2679 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2680 f = ngx_http_fastcgi_split(r, flcf); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2681 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2682 if (f == NULL) { |
2443 | 2683 return NGX_ERROR; |
2684 } | |
2685 | |
2686 if (f->script_name.len == 0 | |
2687 || f->script_name.data[f->script_name.len - 1] != '/') | |
2688 { | |
2689 v->len = f->script_name.len; | |
1097
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2690 v->valid = 1; |
1565 | 2691 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
|
2692 v->not_found = 0; |
2443 | 2693 v->data = f->script_name.data; |
1097
df8cdf626c87
fix segfault when $fastcgi_script_name is used in access_log
Igor Sysoev <igor@sysoev.ru>
parents:
1037
diff
changeset
|
2694 |
573 | 2695 return NGX_OK; |
509 | 2696 } |
2697 | |
2443 | 2698 v->len = f->script_name.len + flcf->index.len; |
2699 | |
2700 v->data = ngx_pnalloc(r->pool, v->len); | |
2701 if (v->data == NULL) { | |
2702 return NGX_ERROR; | |
2703 } | |
2704 | |
2705 p = ngx_copy(v->data, f->script_name.data, f->script_name.len); | |
2706 ngx_memcpy(p, flcf->index.data, flcf->index.len); | |
2707 | |
573 | 2708 return NGX_OK; |
509 | 2709 } |
2710 | |
2711 | |
2443 | 2712 static ngx_int_t |
2713 ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r, | |
2714 ngx_http_variable_value_t *v, uintptr_t data) | |
2715 { | |
2716 ngx_http_fastcgi_ctx_t *f; | |
2717 ngx_http_fastcgi_loc_conf_t *flcf; | |
2718 | |
2719 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); | |
2720 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2721 f = ngx_http_fastcgi_split(r, flcf); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2722 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2723 if (f == NULL) { |
2443 | 2724 return NGX_ERROR; |
2725 } | |
2726 | |
2727 v->len = f->path_info.len; | |
2728 v->valid = 1; | |
2729 v->no_cacheable = 0; | |
2730 v->not_found = 0; | |
2731 v->data = f->path_info.data; | |
2732 | |
2733 return NGX_OK; | |
2734 } | |
2735 | |
2736 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2737 static ngx_http_fastcgi_ctx_t * |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2738 ngx_http_fastcgi_split(ngx_http_request_t *r, ngx_http_fastcgi_loc_conf_t *flcf) |
2443 | 2739 { |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2740 ngx_http_fastcgi_ctx_t *f; |
2443 | 2741 #if (NGX_PCRE) |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2742 ngx_int_t n; |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2743 int captures[(1 + 2) * 3]; |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2744 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2745 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2746 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2747 if (f == NULL) { |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2748 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2749 if (f == NULL) { |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2750 return NULL; |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2751 } |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2752 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2753 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2754 } |
2443 | 2755 |
2756 if (f->script_name.len) { | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2757 return f; |
2443 | 2758 } |
2759 | |
2760 if (flcf->split_regex == NULL) { | |
2761 f->script_name = r->uri; | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2762 return f; |
2443 | 2763 } |
2764 | |
2765 n = ngx_regex_exec(flcf->split_regex, &r->uri, captures, (1 + 2) * 3); | |
2766 | |
3325 | 2767 if (n >= 0) { /* match */ |
2768 f->script_name.len = captures[3] - captures[2]; | |
3735
1ba712d077d1
fix fastcgi_split_path_info, if URI was not fully captured
Igor Sysoev <igor@sysoev.ru>
parents:
3731
diff
changeset
|
2769 f->script_name.data = r->uri.data + captures[2]; |
3325 | 2770 |
2771 f->path_info.len = captures[5] - captures[4]; | |
3735
1ba712d077d1
fix fastcgi_split_path_info, if URI was not fully captured
Igor Sysoev <igor@sysoev.ru>
parents:
3731
diff
changeset
|
2772 f->path_info.data = r->uri.data + captures[4]; |
3325 | 2773 |
2774 return f; | |
2775 } | |
2776 | |
2443 | 2777 if (n == NGX_REGEX_NO_MATCHED) { |
2778 f->script_name = r->uri; | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2779 return f; |
2443 | 2780 } |
2781 | |
3325 | 2782 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
2783 ngx_regex_exec_n " failed: %i on \"%V\" using \"%V\"", | |
2784 n, &r->uri, &flcf->split_name); | |
2785 return NULL; | |
2443 | 2786 |
2787 #else | |
2788 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2789 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2790 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2791 if (f == NULL) { |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2792 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2793 if (f == NULL) { |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2794 return NULL; |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2795 } |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2796 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2797 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2798 } |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2799 |
2443 | 2800 f->script_name = r->uri; |
2801 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2802 return f; |
2443 | 2803 |
2804 #endif | |
2805 } | |
2806 | |
2807 | |
509 | 2808 static char * |
2809 ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2810 { | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2811 ngx_http_fastcgi_loc_conf_t *flcf = conf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2812 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2813 ngx_url_t u; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2814 ngx_str_t *value, *url; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2815 ngx_uint_t n; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2816 ngx_http_core_loc_conf_t *clcf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2817 ngx_http_script_compile_t sc; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2818 |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2390
diff
changeset
|
2819 if (flcf->upstream.upstream || flcf->fastcgi_lengths) { |
555 | 2820 return "is duplicate"; |
2821 } | |
2822 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2823 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
2989
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2927
diff
changeset
|
2824 |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2825 clcf->handler = ngx_http_fastcgi_handler; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2826 |
2989
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2927
diff
changeset
|
2827 if (clcf->name.data[clcf->name.len - 1] == '/') { |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2927
diff
changeset
|
2828 clcf->auto_redirect = 1; |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2927
diff
changeset
|
2829 } |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2927
diff
changeset
|
2830 |
509 | 2831 value = cf->args->elts; |
2832 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2833 url = &value[1]; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2834 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2835 n = ngx_http_script_variables_count(url); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2836 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2837 if (n) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2838 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2839 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2840 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2841 sc.cf = cf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2842 sc.source = url; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2843 sc.lengths = &flcf->fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2844 sc.values = &flcf->fastcgi_values; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2845 sc.variables = n; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2846 sc.complete_lengths = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2847 sc.complete_values = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2848 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2849 if (ngx_http_script_compile(&sc) != NGX_OK) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2850 return NGX_CONF_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2851 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2852 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2853 return NGX_CONF_OK; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2854 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2855 |
651 | 2856 ngx_memzero(&u, sizeof(ngx_url_t)); |
2857 | |
2858 u.url = value[1]; | |
884 | 2859 u.no_resolve = 1; |
2860 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2861 flcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2862 if (flcf->upstream.upstream == NULL) { |
509 | 2863 return NGX_CONF_ERROR; |
2864 } | |
2865 | |
2866 return NGX_CONF_OK; | |
2867 } | |
2868 | |
2869 | |
2870 static char * | |
2443 | 2871 ngx_http_fastcgi_split_path_info(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
2872 { | |
2873 #if (NGX_PCRE) | |
2874 ngx_http_fastcgi_loc_conf_t *flcf = conf; | |
2875 | |
3325 | 2876 ngx_str_t *value; |
2877 ngx_regex_compile_t rc; | |
2878 u_char errstr[NGX_MAX_CONF_ERRSTR]; | |
2443 | 2879 |
2880 value = cf->args->elts; | |
2881 | |
2882 flcf->split_name = value[1]; | |
2883 | |
3325 | 2884 ngx_memzero(&rc, sizeof(ngx_regex_compile_t)); |
2885 | |
2886 rc.pattern = value[1]; | |
2887 rc.pool = cf->pool; | |
2888 rc.err.len = NGX_MAX_CONF_ERRSTR; | |
2889 rc.err.data = errstr; | |
2890 | |
2891 if (ngx_regex_compile(&rc) != NGX_OK) { | |
2892 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V", &rc.err); | |
2443 | 2893 return NGX_CONF_ERROR; |
2894 } | |
2895 | |
3325 | 2896 if (rc.captures != 2) { |
2443 | 2897 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2898 "pattern \"%V\" must have 2 captures", &value[1]); | |
2899 return NGX_CONF_ERROR; | |
2900 } | |
2901 | |
3325 | 2902 flcf->split_regex = rc.regex; |
2903 | |
2443 | 2904 return NGX_CONF_OK; |
2905 | |
2906 #else | |
2907 | |
2908 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2909 "\"%V\" requires PCRE library", &cmd->name); | |
2910 return NGX_CONF_ERROR; | |
2911 | |
2912 #endif | |
2913 } | |
2914 | |
2915 | |
2916 static char * | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2917 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
|
2918 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2919 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
|
2920 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2921 ngx_str_t *value; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2922 ngx_http_script_compile_t sc; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2923 |
2894 | 2924 if (flcf->upstream.store != NGX_CONF_UNSET |
2925 || flcf->upstream.store_lengths) | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2926 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2927 return "is duplicate"; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2928 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2929 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2930 value = cf->args->elts; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2931 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2932 if (ngx_strcmp(value[1].data, "off") == 0) { |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2933 flcf->upstream.store = 0; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2934 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2935 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2936 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2937 #if (NGX_HTTP_CACHE) |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2938 |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2939 if (flcf->upstream.cache != NGX_CONF_UNSET_PTR |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2940 && flcf->upstream.cache != NULL) |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2941 { |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2942 return "is incompatible with \"fastcgi_cache\""; |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2943 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2944 |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2945 #endif |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2946 |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2947 if (ngx_strcmp(value[1].data, "on") == 0) { |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2948 flcf->upstream.store = 1; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2949 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2950 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2951 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2952 /* include the terminating '\0' into script */ |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2953 value[1].len++; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2954 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2955 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
|
2956 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2957 sc.cf = cf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2958 sc.source = &value[1]; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2959 sc.lengths = &flcf->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2960 sc.values = &flcf->upstream.store_values; |
1563
022ec9420f80
style fix: remove double semicolons
Igor Sysoev <igor@sysoev.ru>
parents:
1488
diff
changeset
|
2961 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
|
2962 sc.complete_lengths = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2963 sc.complete_values = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2964 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2965 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
|
2966 return NGX_CONF_ERROR; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2967 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2968 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2969 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2970 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2971 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2972 |
2602 | 2973 #if (NGX_HTTP_CACHE) |
2974 | |
2975 static char * | |
2976 ngx_http_fastcgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2977 { | |
2978 ngx_http_fastcgi_loc_conf_t *flcf = conf; | |
2979 | |
2980 ngx_str_t *value; | |
2981 | |
2982 value = cf->args->elts; | |
2983 | |
2984 if (flcf->upstream.cache != NGX_CONF_UNSET_PTR) { | |
2985 return "is duplicate"; | |
2986 } | |
2987 | |
2988 if (ngx_strcmp(value[1].data, "off") == 0) { | |
2989 flcf->upstream.cache = NULL; | |
2990 return NGX_CONF_OK; | |
2991 } | |
2992 | |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2993 if (flcf->upstream.store > 0 || flcf->upstream.store_lengths) { |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2994 return "is incompatible with \"fastcgi_store\""; |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2995 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2996 |
2602 | 2997 flcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0, |
2998 &ngx_http_fastcgi_module); | |
2999 if (flcf->upstream.cache == NULL) { | |
3000 return NGX_CONF_ERROR; | |
3001 } | |
3002 | |
3003 return NGX_CONF_OK; | |
3004 } | |
3005 | |
3006 | |
3007 static char * | |
3008 ngx_http_fastcgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
3009 { | |
3010 ngx_http_fastcgi_loc_conf_t *flcf = conf; | |
3011 | |
3012 ngx_str_t *value; | |
3013 ngx_http_compile_complex_value_t ccv; | |
3014 | |
3015 value = cf->args->elts; | |
3016 | |
3017 if (flcf->cache_key.value.len) { | |
3018 return "is duplicate"; | |
3019 } | |
3020 | |
3021 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
3022 | |
3023 ccv.cf = cf; | |
3024 ccv.value = &value[1]; | |
3025 ccv.complex_value = &flcf->cache_key; | |
3026 | |
3027 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
3028 return NGX_CONF_ERROR; | |
3029 } | |
3030 | |
3031 return NGX_CONF_OK; | |
3032 } | |
3033 | |
3034 #endif | |
3035 | |
3036 | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3037 static char * |
509 | 3038 ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data) |
3039 { | |
3040 #if (NGX_FREEBSD) | |
3041 ssize_t *np = data; | |
3042 | |
673 | 3043 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { |
509 | 3044 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3045 "\"fastcgi_send_lowat\" must be less than %d " | |
3046 "(sysctl net.inet.tcp.sendspace)", | |
3047 ngx_freebsd_net_inet_tcp_sendspace); | |
3048 | |
3049 return NGX_CONF_ERROR; | |
3050 } | |
3051 | |
3052 #elif !(NGX_HAVE_SO_SNDLOWAT) | |
3053 ssize_t *np = data; | |
3054 | |
3055 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
3056 "\"fastcgi_send_lowat\" is not supported, ignored"); | |
3057 | |
3058 *np = 0; | |
3059 | |
3060 #endif | |
3061 | |
3062 return NGX_CONF_OK; | |
3063 } |