Mercurial > hg > nginx
annotate src/http/modules/ngx_http_fastcgi_module.c @ 4583:a1d5842064f7
Fixed buffer overflow when long URI is processed by "try_files" in
regex location with "alias" (fixes ticket #135).
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 12 Apr 2012 09:19:14 +0000 |
parents | 1ebec1d15a25 |
children | 834049edae24 |
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; | |
622 | |
649 | 623 u->buffering = 1; |
624 | |
581 | 625 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); |
626 if (u->pipe == NULL) { | |
627 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
628 } | |
629 | |
630 u->pipe->input_filter = ngx_http_fastcgi_input_filter; | |
631 u->pipe->input_ctx = r; | |
479 | 632 |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
633 u->input_filter_init = ngx_http_fastcgi_input_filter_init; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
634 |
479 | 635 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init); |
636 | |
637 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
638 return rc; | |
639 } | |
640 | |
641 return NGX_DONE; | |
642 } | |
643 | |
644 | |
487 | 645 static ngx_int_t |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
646 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
|
647 { |
3610 | 648 ngx_url_t url; |
649 ngx_http_upstream_t *u; | |
650 | |
651 ngx_memzero(&url, sizeof(ngx_url_t)); | |
652 | |
653 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
|
654 flcf->fastcgi_values->elts) |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
655 == NULL) |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
656 { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
657 return NGX_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
658 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
659 |
3610 | 660 url.no_resolve = 1; |
661 | |
662 if (ngx_parse_url(r->pool, &url) != NGX_OK) { | |
663 if (url.err) { | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
664 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
3610 | 665 "%s in upstream \"%V\"", url.err, &url.url); |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
666 } |
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 return NGX_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
669 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
670 |
3610 | 671 u = r->upstream; |
672 | |
673 u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t)); | |
674 if (u->resolved == NULL) { | |
675 return NGX_ERROR; | |
676 } | |
677 | |
678 if (url.addrs && url.addrs[0].sockaddr) { | |
679 u->resolved->sockaddr = url.addrs[0].sockaddr; | |
680 u->resolved->socklen = url.addrs[0].socklen; | |
681 u->resolved->naddrs = 1; | |
682 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
|
683 |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2396
diff
changeset
|
684 } else { |
3610 | 685 u->resolved->host = url.host; |
686 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
|
687 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
|
688 } |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
689 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
690 return NGX_OK; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
691 } |
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 |
2602 | 694 #if (NGX_HTTP_CACHE) |
695 | |
696 static ngx_int_t | |
697 ngx_http_fastcgi_create_key(ngx_http_request_t *r) | |
698 { | |
699 ngx_str_t *key; | |
700 ngx_http_fastcgi_loc_conf_t *flcf; | |
701 | |
702 key = ngx_array_push(&r->cache->keys); | |
703 if (key == NULL) { | |
704 return NGX_ERROR; | |
705 } | |
706 | |
707 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); | |
708 | |
709 if (ngx_http_complex_value(r, &flcf->cache_key, key) != NGX_OK) { | |
710 return NGX_ERROR; | |
711 } | |
712 | |
713 return NGX_OK; | |
714 } | |
715 | |
716 #endif | |
717 | |
718 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
719 static ngx_int_t |
487 | 720 ngx_http_fastcgi_create_request(ngx_http_request_t *r) |
479 | 721 { |
509 | 722 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
|
723 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
|
724 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
|
725 allocated; |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
726 ngx_uint_t i, n, next, hash, skip_empty, header_params; |
509 | 727 ngx_buf_t *b; |
728 ngx_chain_t *cl, *body; | |
729 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
|
730 ngx_table_elt_t *header, **ignored; |
509 | 731 ngx_http_script_code_pt code; |
732 ngx_http_script_engine_t e, le; | |
733 ngx_http_fastcgi_header_t *h; | |
734 ngx_http_fastcgi_loc_conf_t *flcf; | |
735 ngx_http_script_len_code_pt lcode; | |
479 | 736 |
509 | 737 len = 0; |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
738 header_params = 0; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
739 ignored = NULL; |
485 | 740 |
479 | 741 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
742 | |
509 | 743 if (flcf->params_len) { |
744 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); | |
479 | 745 |
1565 | 746 ngx_http_script_flush_no_cacheable_variables(r, flcf->flushes); |
573 | 747 le.flushed = 1; |
748 | |
509 | 749 le.ip = flcf->params_len->elts; |
750 le.request = r; | |
479 | 751 |
509 | 752 while (*(uintptr_t *) le.ip) { |
487 | 753 |
509 | 754 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
755 key_len = lcode(&le); | |
479 | 756 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
757 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
|
758 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
|
759 |
509 | 760 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
761 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
762 } | |
763 le.ip += sizeof(uintptr_t); | |
479 | 764 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
765 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
|
766 continue; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
767 } |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
768 |
537 | 769 len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len; |
485 | 770 } |
771 } | |
772 | |
509 | 773 if (flcf->upstream.pass_request_headers) { |
485 | 774 |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
775 allocated = 0; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
776 lowcase_key = NULL; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
777 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
778 if (flcf->header_params) { |
4015
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
779 n = 0; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
780 part = &r->headers_in.headers.part; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
781 |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
782 while (part) { |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
783 n += part->nelts; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
784 part = part->next; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
785 } |
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 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
|
788 if (ignored == NULL) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
789 return NGX_ERROR; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
790 } |
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 |
509 | 793 part = &r->headers_in.headers.part; |
794 header = part->elts; | |
795 | |
796 for (i = 0; /* void */; i++) { | |
479 | 797 |
509 | 798 if (i >= part->nelts) { |
799 if (part->next == NULL) { | |
800 break; | |
801 } | |
479 | 802 |
509 | 803 part = part->next; |
804 header = part->elts; | |
805 i = 0; | |
479 | 806 } |
807 | |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
808 if (flcf->header_params) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
809 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
|
810 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
|
811 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
|
812 if (lowcase_key == NULL) { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
813 return NGX_ERROR; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
814 } |
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 hash = 0; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
818 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
819 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
|
820 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
|
821 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
822 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
|
823 ch |= 0x20; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
824 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
825 } else if (ch == '-') { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
826 ch = '_'; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
827 } |
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 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
|
830 lowcase_key[n] = ch; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
831 } |
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 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
|
834 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
|
835 continue; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
836 } |
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 n += sizeof("HTTP_") - 1; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
839 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
840 } else { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
841 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
|
842 } |
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 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
|
845 + n + header[i].value.len; |
479 | 846 } |
847 } | |
848 | |
849 | |
850 if (len > 65535) { | |
851 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
1678 | 852 "fastcgi request record is too big: %uz", len); |
479 | 853 return NGX_ERROR; |
854 } | |
855 | |
856 | |
857 padding = 8 - len % 8; | |
858 padding = (padding == 8) ? 0 : padding; | |
859 | |
860 | |
861 size = sizeof(ngx_http_fastcgi_header_t) | |
862 + sizeof(ngx_http_fastcgi_begin_request_t) | |
863 | |
864 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
865 + len + padding | |
866 + sizeof(ngx_http_fastcgi_header_t) /* NGX_HTTP_FASTCGI_PARAMS */ | |
867 | |
868 + sizeof(ngx_http_fastcgi_header_t); /* NGX_HTTP_FASTCGI_STDIN */ | |
869 | |
870 | |
501 | 871 b = ngx_create_temp_buf(r->pool, size); |
872 if (b == NULL) { | |
479 | 873 return NGX_ERROR; |
874 } | |
875 | |
501 | 876 cl = ngx_alloc_chain_link(r->pool); |
877 if (cl == NULL) { | |
479 | 878 return NGX_ERROR; |
879 } | |
880 | |
881 cl->buf = b; | |
882 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
883 ngx_http_fastcgi_request_start.br.flags = |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
884 flcf->keep_conn ? NGX_HTTP_FASTCGI_KEEP_CONN : 0; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
885 |
509 | 886 ngx_memcpy(b->pos, &ngx_http_fastcgi_request_start, |
887 sizeof(ngx_http_fastcgi_request_start_t)); | |
479 | 888 |
889 h = (ngx_http_fastcgi_header_t *) | |
890 (b->pos + sizeof(ngx_http_fastcgi_header_t) | |
891 + sizeof(ngx_http_fastcgi_begin_request_t)); | |
892 | |
893 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
894 h->content_length_lo = (u_char) (len & 0xff); | |
895 h->padding_length = (u_char) padding; | |
896 h->reserved = 0; | |
897 | |
898 b->last = b->pos + sizeof(ngx_http_fastcgi_header_t) | |
899 + sizeof(ngx_http_fastcgi_begin_request_t) | |
900 + sizeof(ngx_http_fastcgi_header_t); | |
901 | |
902 | |
509 | 903 if (flcf->params_len) { |
904 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); | |
479 | 905 |
509 | 906 e.ip = flcf->params->elts; |
907 e.pos = b->last; | |
908 e.request = r; | |
573 | 909 e.flushed = 1; |
479 | 910 |
509 | 911 le.ip = flcf->params_len->elts; |
479 | 912 |
509 | 913 while (*(uintptr_t *) le.ip) { |
479 | 914 |
509 | 915 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
916 key_len = (u_char) lcode(&le); | |
479 | 917 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
918 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
|
919 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
|
920 |
509 | 921 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
922 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
923 } | |
924 le.ip += sizeof(uintptr_t); | |
479 | 925 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
926 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
|
927 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
|
928 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
929 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
|
930 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
|
931 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
|
932 } |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
933 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
|
934 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
935 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
|
936 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
937 continue; |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
938 } |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
939 |
537 | 940 *e.pos++ = (u_char) key_len; |
479 | 941 |
537 | 942 if (val_len > 127) { |
943 *e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80); | |
944 *e.pos++ = (u_char) ((val_len >> 16) & 0xff); | |
945 *e.pos++ = (u_char) ((val_len >> 8) & 0xff); | |
946 *e.pos++ = (u_char) (val_len & 0xff); | |
479 | 947 |
537 | 948 } else { |
949 *e.pos++ = (u_char) val_len; | |
509 | 950 } |
479 | 951 |
509 | 952 while (*(uintptr_t *) e.ip) { |
953 code = *(ngx_http_script_code_pt *) e.ip; | |
954 code((ngx_http_script_engine_t *) &e); | |
955 } | |
956 e.ip += sizeof(uintptr_t); | |
1945 | 957 |
958 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
959 "fastcgi param: \"%*s: %*s\"", | |
960 key_len, e.pos - (key_len + val_len), | |
961 val_len, e.pos - val_len); | |
479 | 962 } |
963 | |
509 | 964 b->last = e.pos; |
487 | 965 } |
966 | |
967 | |
509 | 968 if (flcf->upstream.pass_request_headers) { |
479 | 969 |
509 | 970 part = &r->headers_in.headers.part; |
971 header = part->elts; | |
479 | 972 |
509 | 973 for (i = 0; /* void */; i++) { |
491 | 974 |
509 | 975 if (i >= part->nelts) { |
976 if (part->next == NULL) { | |
577 | 977 break; |
509 | 978 } |
577 | 979 |
509 | 980 part = part->next; |
981 header = part->elts; | |
982 i = 0; | |
983 } | |
479 | 984 |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
985 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
|
986 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
|
987 goto next; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
988 } |
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 |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
991 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
|
992 if (key_len > 127) { |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
993 *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
|
994 *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
|
995 *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
|
996 *b->last++ = (u_char) (key_len & 0xff); |
577 | 997 |
509 | 998 } else { |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
999 *b->last++ = (u_char) key_len; |
487 | 1000 } |
1001 | |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1002 val_len = header[i].value.len; |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1003 if (val_len > 127) { |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1004 *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
|
1005 *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
|
1006 *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
|
1007 *b->last++ = (u_char) (val_len & 0xff); |
487 | 1008 |
509 | 1009 } else { |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1010 *b->last++ = (u_char) val_len; |
479 | 1011 } |
1012 | |
509 | 1013 b->last = ngx_cpymem(b->last, "HTTP_", sizeof("HTTP_") - 1); |
479 | 1014 |
509 | 1015 for (n = 0; n < header[i].key.len; n++) { |
1016 ch = header[i].key.data[n]; | |
479 | 1017 |
509 | 1018 if (ch >= 'a' && ch <= 'z') { |
1019 ch &= ~0x20; | |
479 | 1020 |
509 | 1021 } else if (ch == '-') { |
1022 ch = '_'; | |
1023 } | |
479 | 1024 |
509 | 1025 *b->last++ = ch; |
479 | 1026 } |
1027 | |
3559
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1028 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
|
1029 |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1030 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
|
1031 "fastcgi param: \"%*s: %*s\"", |
519dcf4cb3de
add client request headers debug logging in fastcgi
Igor Sysoev <igor@sysoev.ru>
parents:
3558
diff
changeset
|
1032 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
|
1033 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
|
1034 next: |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
1035 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
1036 continue; |
479 | 1037 } |
1038 } | |
1039 | |
1040 | |
1041 if (padding) { | |
1042 ngx_memzero(b->last, padding); | |
1043 b->last += padding; | |
1044 } | |
1045 | |
1046 | |
1047 h = (ngx_http_fastcgi_header_t *) b->last; | |
1048 b->last += sizeof(ngx_http_fastcgi_header_t); | |
1049 | |
1050 h->version = 1; | |
1051 h->type = NGX_HTTP_FASTCGI_PARAMS; | |
1052 h->request_id_hi = 0; | |
1053 h->request_id_lo = 1; | |
1054 h->content_length_hi = 0; | |
1055 h->content_length_lo = 0; | |
1056 h->padding_length = 0; | |
1057 h->reserved = 0; | |
1058 | |
1059 h = (ngx_http_fastcgi_header_t *) b->last; | |
1060 b->last += sizeof(ngx_http_fastcgi_header_t); | |
1061 | |
509 | 1062 if (flcf->upstream.pass_request_body) { |
1063 body = r->upstream->request_bufs; | |
1064 r->upstream->request_bufs = cl; | |
479 | 1065 |
1066 #if (NGX_SUPPRESS_WARN) | |
509 | 1067 file_pos = 0; |
1068 pos = NULL; | |
479 | 1069 #endif |
1070 | |
509 | 1071 while (body) { |
479 | 1072 |
509 | 1073 if (body->buf->in_file) { |
1074 file_pos = body->buf->file_pos; | |
479 | 1075 |
509 | 1076 } else { |
1077 pos = body->buf->pos; | |
479 | 1078 } |
1079 | |
509 | 1080 next = 0; |
479 | 1081 |
509 | 1082 do { |
1083 b = ngx_alloc_buf(r->pool); | |
1084 if (b == NULL) { | |
1085 return NGX_ERROR; | |
479 | 1086 } |
1087 | |
509 | 1088 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); |
1089 | |
1090 if (body->buf->in_file) { | |
1091 b->file_pos = file_pos; | |
1092 file_pos += 32 * 1024; | |
479 | 1093 |
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
|
1094 if (file_pos >= body->buf->file_last) { |
509 | 1095 file_pos = body->buf->file_last; |
1096 next = 1; | |
1097 } | |
1098 | |
1099 b->file_last = file_pos; | |
1100 len = (ngx_uint_t) (file_pos - b->file_pos); | |
1101 | |
1102 } else { | |
1103 b->pos = pos; | |
1104 pos += 32 * 1024; | |
479 | 1105 |
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
|
1106 if (pos >= body->buf->last) { |
509 | 1107 pos = body->buf->last; |
1108 next = 1; | |
1109 } | |
1110 | |
1111 b->last = pos; | |
1112 len = (ngx_uint_t) (pos - b->pos); | |
1113 } | |
479 | 1114 |
509 | 1115 padding = 8 - len % 8; |
1116 padding = (padding == 8) ? 0 : padding; | |
479 | 1117 |
509 | 1118 h->version = 1; |
1119 h->type = NGX_HTTP_FASTCGI_STDIN; | |
1120 h->request_id_hi = 0; | |
1121 h->request_id_lo = 1; | |
1122 h->content_length_hi = (u_char) ((len >> 8) & 0xff); | |
1123 h->content_length_lo = (u_char) (len & 0xff); | |
1124 h->padding_length = (u_char) padding; | |
1125 h->reserved = 0; | |
479 | 1126 |
509 | 1127 cl->next = ngx_alloc_chain_link(r->pool); |
1128 if (cl->next == NULL) { | |
1129 return NGX_ERROR; | |
1130 } | |
479 | 1131 |
509 | 1132 cl = cl->next; |
1133 cl->buf = b; | |
1134 | |
1135 b = ngx_create_temp_buf(r->pool, | |
1136 sizeof(ngx_http_fastcgi_header_t) | |
1137 + padding); | |
1138 if (b == NULL) { | |
1139 return NGX_ERROR; | |
1140 } | |
479 | 1141 |
509 | 1142 if (padding) { |
1143 ngx_memzero(b->last, padding); | |
1144 b->last += padding; | |
1145 } | |
1146 | |
1147 h = (ngx_http_fastcgi_header_t *) b->last; | |
1148 b->last += sizeof(ngx_http_fastcgi_header_t); | |
479 | 1149 |
509 | 1150 cl->next = ngx_alloc_chain_link(r->pool); |
1151 if (cl->next == NULL) { | |
1152 return NGX_ERROR; | |
1153 } | |
1154 | |
1155 cl = cl->next; | |
1156 cl->buf = b; | |
479 | 1157 |
509 | 1158 } while (!next); |
479 | 1159 |
509 | 1160 body = body->next; |
1161 } | |
479 | 1162 |
509 | 1163 } else { |
1164 r->upstream->request_bufs = cl; | |
479 | 1165 } |
1166 | |
1167 h->version = 1; | |
1168 h->type = NGX_HTTP_FASTCGI_STDIN; | |
1169 h->request_id_hi = 0; | |
1170 h->request_id_lo = 1; | |
1171 h->content_length_hi = 0; | |
1172 h->content_length_lo = 0; | |
1173 h->padding_length = 0; | |
1174 h->reserved = 0; | |
1175 | |
1176 cl->next = NULL; | |
1177 | |
1178 return NGX_OK; | |
1179 } | |
1180 | |
1181 | |
487 | 1182 static ngx_int_t |
1183 ngx_http_fastcgi_reinit_request(ngx_http_request_t *r) | |
479 | 1184 { |
1185 ngx_http_fastcgi_ctx_t *f; | |
1186 | |
1187 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
1188 | |
1189 if (f == NULL) { | |
1190 return NGX_OK; | |
1191 } | |
1192 | |
1193 f->state = ngx_http_fastcgi_st_version; | |
615 | 1194 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
|
1195 f->large_stderr = 0; |
479 | 1196 |
1197 return NGX_OK; | |
1198 } | |
1199 | |
1200 | |
507 | 1201 static ngx_int_t |
1202 ngx_http_fastcgi_process_header(ngx_http_request_t *r) | |
479 | 1203 { |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1204 u_char *p, *msg, *start, *last, |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1205 *part_start, *part_end; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1206 size_t size; |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1207 ngx_str_t *status_line, *pattern; |
509 | 1208 ngx_int_t rc, status; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1209 ngx_buf_t buf; |
649 | 1210 ngx_uint_t i; |
509 | 1211 ngx_table_elt_t *h; |
1212 ngx_http_upstream_t *u; | |
1213 ngx_http_fastcgi_ctx_t *f; | |
1214 ngx_http_upstream_header_t *hh; | |
1228 | 1215 ngx_http_fastcgi_loc_conf_t *flcf; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1216 ngx_http_fastcgi_split_part_t *part; |
509 | 1217 ngx_http_upstream_main_conf_t *umcf; |
479 | 1218 |
1219 f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module); | |
1220 | |
509 | 1221 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); |
1222 | |
479 | 1223 u = r->upstream; |
1224 | |
1225 for ( ;; ) { | |
1226 | |
1227 if (f->state < ngx_http_fastcgi_st_data) { | |
1228 | |
581 | 1229 f->pos = u->buffer.pos; |
1230 f->last = u->buffer.last; | |
479 | 1231 |
1232 rc = ngx_http_fastcgi_process_record(r, f); | |
1233 | |
581 | 1234 u->buffer.pos = f->pos; |
1235 u->buffer.last = f->last; | |
479 | 1236 |
1237 if (rc == NGX_AGAIN) { | |
1238 return NGX_AGAIN; | |
1239 } | |
1240 | |
1241 if (rc == NGX_ERROR) { | |
1242 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1243 } | |
1244 | |
491 | 1245 if (f->type != NGX_HTTP_FASTCGI_STDOUT |
1246 && f->type != NGX_HTTP_FASTCGI_STDERR) | |
1247 { | |
479 | 1248 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1249 "upstream sent unexpected FastCGI record: %d", | |
1250 f->type); | |
1251 | |
1252 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1253 } | |
1254 | |
491 | 1255 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { |
479 | 1256 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1257 "upstream closed prematurely FastCGI stdout"); | |
1258 | |
1259 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1260 } | |
1261 } | |
1262 | |
1263 if (f->state == ngx_http_fastcgi_st_padding) { | |
1264 | |
581 | 1265 if (u->buffer.pos + f->padding < u->buffer.last) { |
479 | 1266 f->state = ngx_http_fastcgi_st_version; |
581 | 1267 u->buffer.pos += f->padding; |
479 | 1268 |
1269 continue; | |
1270 } | |
1271 | |
581 | 1272 if (u->buffer.pos + f->padding == u->buffer.last) { |
479 | 1273 f->state = ngx_http_fastcgi_st_version; |
581 | 1274 u->buffer.pos = u->buffer.last; |
479 | 1275 |
1276 return NGX_AGAIN; | |
1277 } | |
1278 | |
581 | 1279 f->padding -= u->buffer.last - u->buffer.pos; |
1280 u->buffer.pos = u->buffer.last; | |
479 | 1281 |
1282 return NGX_AGAIN; | |
1283 } | |
1284 | |
491 | 1285 |
479 | 1286 /* f->state == ngx_http_fastcgi_st_data */ |
1287 | |
491 | 1288 if (f->type == NGX_HTTP_FASTCGI_STDERR) { |
1289 | |
1290 if (f->length) { | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1291 msg = u->buffer.pos; |
491 | 1292 |
581 | 1293 if (u->buffer.pos + f->length <= u->buffer.last) { |
1294 u->buffer.pos += f->length; | |
491 | 1295 f->length = 0; |
1296 f->state = ngx_http_fastcgi_st_padding; | |
1297 | |
577 | 1298 } else { |
581 | 1299 f->length -= u->buffer.last - u->buffer.pos; |
1300 u->buffer.pos = u->buffer.last; | |
491 | 1301 } |
1302 | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1303 for (p = u->buffer.pos - 1; msg < p; p--) { |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1304 if (*p != LF && *p != CR && *p != '.' && *p != ' ') { |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1305 break; |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1306 } |
491 | 1307 } |
1308 | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1309 p++; |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1310 |
491 | 1311 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
|
1312 "FastCGI sent in stderr: \"%*s\"", p - msg, msg); |
491 | 1313 |
1228 | 1314 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
1315 | |
1316 if (flcf->catch_stderr) { | |
1317 pattern = flcf->catch_stderr->elts; | |
1318 | |
1319 for (i = 0; i < flcf->catch_stderr->nelts; i++) { | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1320 if (ngx_strnstr(msg, (char *) pattern[i].data, |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1321 p - msg) |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1322 != NULL) |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1323 { |
1700
7f3350b18e75
return NGX_HTTP_UPSTREAM_INVALID_HEADER instead of NGX_HTTP_BAD_GATEWAY
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
1324 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
1228 | 1325 } |
1326 } | |
1327 } | |
1328 | |
581 | 1329 if (u->buffer.pos == u->buffer.last) { |
615 | 1330 |
1331 if (!f->fastcgi_stdout) { | |
1332 | |
1333 /* | |
1334 * the special handling the large number | |
1335 * of the PHP warnings to not allocate memory | |
1336 */ | |
1337 | |
3460
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1338 #if (NGX_HTTP_CACHE) |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1339 if (r->cache) { |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1340 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
|
1341 + r->cache->header_start; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1342 } else { |
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 } |
3850
ca7b9caa20e5
fix large stderr handling without http cache
Igor Sysoev <igor@sysoev.ru>
parents:
3735
diff
changeset
|
1345 #else |
ca7b9caa20e5
fix large stderr handling without http cache
Igor Sysoev <igor@sysoev.ru>
parents:
3735
diff
changeset
|
1346 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
|
1347 #endif |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1348 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
|
1349 f->large_stderr = 1; |
615 | 1350 } |
1351 | |
491 | 1352 return NGX_AGAIN; |
1353 } | |
1354 | |
1355 } else { | |
1356 f->state = ngx_http_fastcgi_st_version; | |
1357 } | |
1358 | |
1359 continue; | |
1360 } | |
1361 | |
1362 | |
1363 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1364 | |
3460
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1365 #if (NGX_HTTP_CACHE) |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1366 |
3469
08a66ba99191
fix segfault if there was non cached large FastCGI stderr output before header,
Igor Sysoev <igor@sysoev.ru>
parents:
3460
diff
changeset
|
1367 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
|
1368 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
|
1369 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
|
1370 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
|
1371 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1372 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
|
1373 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1374 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
|
1375 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1376 /* |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1377 * 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
|
1378 * 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
|
1379 * 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
|
1380 * 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
|
1381 * 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
|
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 if (len >= 0) { |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1385 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
|
1386 fh->version = 1; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1387 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
|
1388 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
|
1389 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
|
1390 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
|
1391 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
|
1392 fh->padding_length = 0; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1393 fh->reserved = 0; |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1394 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1395 } else { |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1396 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
|
1397 - 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
|
1398 } |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1399 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1400 f->large_stderr = 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 |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1403 #endif |
bbea0b19b608
fix cached FastCGI response with large stderr output before header
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
1404 |
615 | 1405 f->fastcgi_stdout = 1; |
1406 | |
581 | 1407 start = u->buffer.pos; |
479 | 1408 |
581 | 1409 if (u->buffer.pos + f->length < u->buffer.last) { |
479 | 1410 |
1411 /* | |
581 | 1412 * set u->buffer.last to the end of the FastCGI record data |
479 | 1413 * for ngx_http_parse_header_line() |
1414 */ | |
1415 | |
581 | 1416 last = u->buffer.last; |
1417 u->buffer.last = u->buffer.pos + f->length; | |
479 | 1418 |
1419 } else { | |
1420 last = NULL; | |
1421 } | |
1422 | |
1423 for ( ;; ) { | |
1424 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1425 part_start = u->buffer.pos; |
3011
5957e869f04d
fix a garbage in a split fastcgi header
Igor Sysoev <igor@sysoev.ru>
parents:
3010
diff
changeset
|
1426 part_end = u->buffer.last; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1427 |
2256 | 1428 rc = ngx_http_parse_header_line(r, &u->buffer, 1); |
479 | 1429 |
1430 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1431 "http fastcgi parser: %d", rc); | |
1432 | |
1433 if (rc == NGX_AGAIN) { | |
1434 break; | |
1435 } | |
1436 | |
1437 if (rc == NGX_OK) { | |
1438 | |
1439 /* a header line has been parsed successfully */ | |
1440 | |
509 | 1441 h = ngx_list_push(&u->headers_in.headers); |
501 | 1442 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
|
1443 return NGX_ERROR; |
479 | 1444 } |
1445 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1446 if (f->split_parts && f->split_parts->nelts) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1447 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1448 part = f->split_parts->elts; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1449 size = u->buffer.pos - part_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1450 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1451 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
|
1452 size += part[i].end - part[i].start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1453 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1454 |
2049 | 1455 p = ngx_pnalloc(r->pool, size); |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1456 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
|
1457 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1458 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1459 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1460 buf.pos = p; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1461 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1462 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
|
1463 p = ngx_cpymem(p, part[i].start, |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1464 part[i].end - part[i].start); |
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 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
|
1468 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1469 buf.last = p; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1470 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1471 f->split_parts->nelts = 0; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1472 |
2256 | 1473 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
|
1474 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1475 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
|
1476 h->key.data = r->header_name_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1477 h->key.data[h->key.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1478 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1479 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
|
1480 h->value.data = r->header_start; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1481 h->value.data[h->value.len] = '\0'; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1482 |
2049 | 1483 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
|
1484 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
|
1485 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1486 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1487 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1488 } else { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1489 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1490 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
|
1491 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
|
1492 |
2049 | 1493 h->key.data = ngx_pnalloc(r->pool, |
1494 h->key.len + 1 + h->value.len + 1 | |
1495 + h->key.len); | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1496 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
|
1497 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1498 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1499 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1500 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
|
1501 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
|
1502 + h->value.len + 1; |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1503 |
4529
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
1504 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
|
1505 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
|
1506 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
|
1507 h->value.data[h->value.len] = '\0'; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1508 } |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1509 |
509 | 1510 h->hash = r->header_hash; |
1511 | |
649 | 1512 if (h->key.len == r->lowcase_index) { |
1513 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1514 | |
1515 } else { | |
2135 | 1516 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); |
479 | 1517 } |
1518 | |
649 | 1519 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, |
1520 h->lowcase_key, h->key.len); | |
1521 | |
1522 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
|
1523 return NGX_ERROR; |
649 | 1524 } |
1525 | |
479 | 1526 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1527 "http fastcgi header: \"%V: %V\"", | |
1528 &h->key, &h->value); | |
1529 | |
615 | 1530 if (u->buffer.pos < u->buffer.last) { |
1531 continue; | |
1532 } | |
1533 | |
1534 /* the end of the FastCGI record */ | |
1535 | |
1536 break; | |
479 | 1537 } |
1538 | |
1539 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
1540 | |
1541 /* a whole header has been parsed successfully */ | |
1542 | |
1543 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1544 "http fastcgi header done"); | |
1545 | |
509 | 1546 if (u->headers_in.status) { |
1547 status_line = &u->headers_in.status->value; | |
479 | 1548 |
1549 status = ngx_atoi(status_line->data, 3); | |
1550 | |
1551 if (status == NGX_ERROR) { | |
1698
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1552 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
|
1553 "upstream sent invalid status \"%V\"", |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1554 status_line); |
70202cd85645
return NGX_HTTP_UPSTREAM_INVALID_HEADER for invalid status
Igor Sysoev <igor@sysoev.ru>
parents:
1678
diff
changeset
|
1555 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
479 | 1556 } |
1557 | |
529 | 1558 u->headers_in.status_n = status; |
1559 u->headers_in.status_line = *status_line; | |
479 | 1560 |
2140
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1561 } 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
|
1562 u->headers_in.status_n = 302; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3494
diff
changeset
|
1563 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
|
1564 "302 Moved Temporarily"); |
2140
dce5ddef5af9
if upstream sent a location header without status use 302
Igor Sysoev <igor@sysoev.ru>
parents:
2135
diff
changeset
|
1565 |
479 | 1566 } else { |
529 | 1567 u->headers_in.status_n = 200; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3494
diff
changeset
|
1568 ngx_str_set(&u->headers_in.status_line, "200 OK"); |
479 | 1569 } |
1570 | |
2602 | 1571 if (u->state) { |
1572 u->state->status = u->headers_in.status_n; | |
479 | 1573 } |
1574 | |
1575 break; | |
1576 } | |
1577 | |
1578 /* there was error while a header line parsing */ | |
1579 | |
1580 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
619 | 1581 "upstream sent invalid header"); |
479 | 1582 |
1583 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1584 } | |
1585 | |
1586 if (last) { | |
581 | 1587 u->buffer.last = last; |
479 | 1588 } |
1589 | |
581 | 1590 f->length -= u->buffer.pos - start; |
479 | 1591 |
1592 if (f->length == 0) { | |
1593 if (f->padding) { | |
1594 f->state = ngx_http_fastcgi_st_padding; | |
1595 } else { | |
1596 f->state = ngx_http_fastcgi_st_version; | |
1597 } | |
1598 } | |
1599 | |
615 | 1600 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { |
1601 return NGX_OK; | |
1602 } | |
1603 | |
1274 | 1604 if (rc == NGX_OK) { |
1998
63c60504c0bf
fix error introduced in r1273 and r1275:
Igor Sysoev <igor@sysoev.ru>
parents:
1945
diff
changeset
|
1605 continue; |
615 | 1606 } |
1607 | |
1274 | 1608 /* rc == NGX_AGAIN */ |
1609 | |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1610 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
|
1611 "upstream split a header line in FastCGI records"); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1612 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1613 if (f->split_parts == NULL) { |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1614 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
|
1615 sizeof(ngx_http_fastcgi_split_part_t)); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1616 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
|
1617 return NGX_ERROR; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1618 } |
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 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1621 part = ngx_array_push(f->split_parts); |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1622 |
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1623 part->start = part_start; |
3011
5957e869f04d
fix a garbage in a split fastcgi header
Igor Sysoev <igor@sysoev.ru>
parents:
3010
diff
changeset
|
1624 part->end = part_end; |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1625 |
3010
37400c84396e
continue to parse available fastcgi record after a split header,
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
1626 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
|
1627 continue; |
37400c84396e
continue to parse available fastcgi record after a split header,
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
1628 } |
37400c84396e
continue to parse available fastcgi record after a split header,
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
1629 |
1276
1494a23b1ed4
fix headers split in FastCGI records
Igor Sysoev <igor@sysoev.ru>
parents:
1274
diff
changeset
|
1630 return NGX_AGAIN; |
479 | 1631 } |
1632 } | |
1633 | |
1634 | |
487 | 1635 static ngx_int_t |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1636 ngx_http_fastcgi_input_filter_init(void *data) |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1637 { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1638 ngx_http_request_t *r = data; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1639 ngx_http_fastcgi_loc_conf_t *flcf; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1640 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1641 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
|
1642 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1643 r->upstream->pipe->length = flcf->keep_conn ? |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1644 (off_t) sizeof(ngx_http_fastcgi_header_t) : -1; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1645 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1646 return NGX_OK; |
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 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1649 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1650 static ngx_int_t |
487 | 1651 ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) |
479 | 1652 { |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1653 u_char *m, *msg; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1654 ngx_int_t rc; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1655 ngx_buf_t *b, **prev; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1656 ngx_chain_t *cl; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1657 ngx_http_request_t *r; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1658 ngx_http_fastcgi_ctx_t *f; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1659 ngx_http_fastcgi_loc_conf_t *flcf; |
479 | 1660 |
1661 if (buf->pos == buf->last) { | |
1662 return NGX_OK; | |
1663 } | |
1664 | |
1665 r = p->input_ctx; | |
1666 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
|
1667 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
479 | 1668 |
1669 b = NULL; | |
483 | 1670 prev = &buf->shadow; |
479 | 1671 |
1672 f->pos = buf->pos; | |
1673 f->last = buf->last; | |
1674 | |
1675 for ( ;; ) { | |
1676 if (f->state < ngx_http_fastcgi_st_data) { | |
1677 | |
1678 rc = ngx_http_fastcgi_process_record(r, f); | |
1679 | |
1680 if (rc == NGX_AGAIN) { | |
1681 break; | |
1682 } | |
1683 | |
1684 if (rc == NGX_ERROR) { | |
1685 return NGX_ERROR; | |
1686 } | |
1687 | |
1688 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { | |
1689 f->state = ngx_http_fastcgi_st_version; | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1690 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1691 if (!flcf->keep_conn) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1692 p->upstream_done = 1; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1693 } |
479 | 1694 |
1695 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | |
1696 "http fastcgi closed stdout"); | |
1697 | |
1698 continue; | |
1699 } | |
1700 | |
1701 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { | |
1702 f->state = ngx_http_fastcgi_st_version; | |
1703 p->upstream_done = 1; | |
1704 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1705 if (flcf->keep_conn) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1706 r->upstream->keepalive = 1; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1707 } |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1708 |
479 | 1709 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, |
1710 "http fastcgi sent end request"); | |
1711 | |
1712 break; | |
1713 } | |
1714 } | |
1715 | |
1716 | |
1717 if (f->state == ngx_http_fastcgi_st_padding) { | |
1718 | |
1719 if (f->pos + f->padding < f->last) { | |
1720 f->state = ngx_http_fastcgi_st_version; | |
1721 f->pos += f->padding; | |
1722 | |
1723 continue; | |
1724 } | |
1725 | |
1726 if (f->pos + f->padding == f->last) { | |
1727 f->state = ngx_http_fastcgi_st_version; | |
1728 | |
1729 break; | |
1730 } | |
1731 | |
1732 f->padding -= f->last - f->pos; | |
1733 | |
1734 break; | |
1735 } | |
1736 | |
1737 | |
1738 /* f->state == ngx_http_fastcgi_st_data */ | |
1739 | |
1740 if (f->type == NGX_HTTP_FASTCGI_STDERR) { | |
1741 | |
1742 if (f->length) { | |
639 | 1743 |
1744 if (f->pos == f->last) { | |
1745 break; | |
1746 } | |
1747 | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1748 msg = f->pos; |
479 | 1749 |
1750 if (f->pos + f->length <= f->last) { | |
1751 f->pos += f->length; | |
491 | 1752 f->length = 0; |
1753 f->state = ngx_http_fastcgi_st_padding; | |
479 | 1754 |
577 | 1755 } else { |
479 | 1756 f->length -= f->last - f->pos; |
1757 f->pos = f->last; | |
1758 } | |
1759 | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1760 for (m = f->pos - 1; msg < m; m--) { |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1761 if (*m != LF && *m != CR && *m != '.' && *m != ' ') { |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1762 break; |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1763 } |
491 | 1764 } |
479 | 1765 |
1766 ngx_log_error(NGX_LOG_ERR, p->log, 0, | |
3025
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1767 "FastCGI sent in stderr: \"%*s\"", |
baff3edcb6e2
refactor fastcgi stderr handling
Igor Sysoev <igor@sysoev.ru>
parents:
3011
diff
changeset
|
1768 m + 1 - msg, msg); |
479 | 1769 |
1770 if (f->pos == f->last) { | |
1771 break; | |
1772 } | |
491 | 1773 |
1774 } else { | |
1775 f->state = ngx_http_fastcgi_st_version; | |
479 | 1776 } |
1777 | |
1778 continue; | |
1779 } | |
1780 | |
1781 | |
1782 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | |
1783 | |
639 | 1784 if (f->pos == f->last) { |
1785 break; | |
1786 } | |
1787 | |
479 | 1788 if (p->free) { |
4136
7898857ff34b
Fixed loss of chain links in fastcgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4122
diff
changeset
|
1789 cl = p->free; |
7898857ff34b
Fixed loss of chain links in fastcgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4122
diff
changeset
|
1790 b = cl->buf; |
7898857ff34b
Fixed loss of chain links in fastcgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4122
diff
changeset
|
1791 p->free = cl->next; |
7898857ff34b
Fixed loss of chain links in fastcgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4122
diff
changeset
|
1792 ngx_free_chain(p->pool, cl); |
479 | 1793 |
1794 } else { | |
501 | 1795 b = ngx_alloc_buf(p->pool); |
1796 if (b == NULL) { | |
479 | 1797 return NGX_ERROR; |
1798 } | |
1799 } | |
1800 | |
1801 ngx_memzero(b, sizeof(ngx_buf_t)); | |
1802 | |
1803 b->pos = f->pos; | |
483 | 1804 b->start = buf->start; |
1805 b->end = buf->end; | |
479 | 1806 b->tag = p->tag; |
1807 b->temporary = 1; | |
1808 b->recycled = 1; | |
483 | 1809 |
1810 *prev = b; | |
1811 prev = &b->shadow; | |
479 | 1812 |
501 | 1813 cl = ngx_alloc_chain_link(p->pool); |
1814 if (cl == NULL) { | |
479 | 1815 return NGX_ERROR; |
1816 } | |
1817 | |
1818 cl->buf = b; | |
1819 cl->next = NULL; | |
1820 | |
501 | 1821 if (p->in) { |
1822 *p->last_in = cl; | |
1823 } else { | |
1824 p->in = cl; | |
1825 } | |
1826 p->last_in = &cl->next; | |
1827 | |
1828 | |
483 | 1829 /* STUB */ b->num = buf->num; |
1830 | |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1831 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1832 "input buf #%d %p", b->num, b->pos); |
479 | 1833 |
1834 if (f->pos + f->length < f->last) { | |
1835 | |
1836 if (f->padding) { | |
1837 f->state = ngx_http_fastcgi_st_padding; | |
1838 } else { | |
1839 f->state = ngx_http_fastcgi_st_version; | |
1840 } | |
1841 | |
1842 f->pos += f->length; | |
1843 b->last = f->pos; | |
1844 | |
1845 continue; | |
1846 } | |
1847 | |
1848 if (f->pos + f->length == f->last) { | |
1849 | |
1850 if (f->padding) { | |
1851 f->state = ngx_http_fastcgi_st_padding; | |
1852 } else { | |
1853 f->state = ngx_http_fastcgi_st_version; | |
1854 } | |
1855 | |
1856 b->last = f->last; | |
1857 | |
1858 break; | |
1859 } | |
1860 | |
1861 f->length -= f->last - f->pos; | |
1862 | |
1863 b->last = f->last; | |
1864 | |
1865 break; | |
1866 | |
1867 } | |
1868 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1869 if (flcf->keep_conn) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1870 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1871 /* 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
|
1872 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1873 if (f->state < ngx_http_fastcgi_st_data) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1874 p->length = 1; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1875 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1876 } else if (f->state == ngx_http_fastcgi_st_padding) { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1877 p->length = f->padding; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1878 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1879 } else { |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1880 /* ngx_http_fastcgi_st_data */ |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1881 |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1882 p->length = f->length; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1883 } |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1884 } |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1885 |
479 | 1886 if (b) { |
483 | 1887 b->shadow = buf; |
479 | 1888 b->last_shadow = 1; |
483 | 1889 |
1030
5a86fcc480c6
add debug logging for FastCGI zero size buf alert
Igor Sysoev <igor@sysoev.ru>
parents:
906
diff
changeset
|
1890 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1037 | 1891 "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
|
1892 |
483 | 1893 return NGX_OK; |
1894 } | |
1895 | |
1896 /* there is no data record in the buf, add it to free chain */ | |
1897 | |
1898 if (ngx_event_pipe_add_free_buf(p, buf) != NGX_OK) { | |
1899 return NGX_ERROR; | |
479 | 1900 } |
1901 | |
1902 return NGX_OK; | |
1903 } | |
1904 | |
1905 | |
487 | 1906 static ngx_int_t |
1907 ngx_http_fastcgi_process_record(ngx_http_request_t *r, | |
1908 ngx_http_fastcgi_ctx_t *f) | |
479 | 1909 { |
1910 u_char ch, *p; | |
1911 ngx_http_fastcgi_state_e state; | |
1912 | |
1913 state = f->state; | |
1914 | |
1915 for (p = f->pos; p < f->last; p++) { | |
1916 | |
1917 ch = *p; | |
1918 | |
1919 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1920 "http fastcgi record byte: %02Xd", ch); | |
1921 | |
1922 switch (state) { | |
1923 | |
1924 case ngx_http_fastcgi_st_version: | |
1925 if (ch != 1) { | |
1926 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1927 "upstream sent unsupported FastCGI " | |
1928 "protocol version: %d", ch); | |
1929 return NGX_ERROR; | |
1930 } | |
1931 state = ngx_http_fastcgi_st_type; | |
1932 break; | |
1933 | |
1934 case ngx_http_fastcgi_st_type: | |
1935 switch (ch) { | |
1936 case NGX_HTTP_FASTCGI_STDOUT: | |
1937 case NGX_HTTP_FASTCGI_STDERR: | |
1938 case NGX_HTTP_FASTCGI_END_REQUEST: | |
1939 f->type = (ngx_uint_t) ch; | |
1940 break; | |
1941 default: | |
1942 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1943 "upstream sent invalid FastCGI " | |
1944 "record type: %d", ch); | |
1945 return NGX_ERROR; | |
1946 | |
1947 } | |
1948 state = ngx_http_fastcgi_st_request_id_hi; | |
1949 break; | |
1950 | |
1951 /* we support the single request per connection */ | |
1952 | |
1953 case ngx_http_fastcgi_st_request_id_hi: | |
1954 if (ch != 0) { | |
1955 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1956 "upstream sent unexpected FastCGI " | |
1957 "request id high byte: %d", ch); | |
1958 return NGX_ERROR; | |
1959 } | |
1960 state = ngx_http_fastcgi_st_request_id_lo; | |
1961 break; | |
1962 | |
1963 case ngx_http_fastcgi_st_request_id_lo: | |
1964 if (ch != 1) { | |
1965 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1966 "upstream sent unexpected FastCGI " | |
1967 "request id low byte: %d", ch); | |
1968 return NGX_ERROR; | |
1969 } | |
1970 state = ngx_http_fastcgi_st_content_length_hi; | |
1971 break; | |
1972 | |
1973 case ngx_http_fastcgi_st_content_length_hi: | |
1974 f->length = ch << 8; | |
1975 state = ngx_http_fastcgi_st_content_length_lo; | |
1976 break; | |
1977 | |
1978 case ngx_http_fastcgi_st_content_length_lo: | |
1979 f->length |= (size_t) ch; | |
1980 state = ngx_http_fastcgi_st_padding_length; | |
1981 break; | |
1982 | |
1983 case ngx_http_fastcgi_st_padding_length: | |
1984 f->padding = (size_t) ch; | |
1985 state = ngx_http_fastcgi_st_reserved; | |
1986 break; | |
1987 | |
1988 case ngx_http_fastcgi_st_reserved: | |
1989 state = ngx_http_fastcgi_st_data; | |
1990 | |
1991 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1992 "http fastcgi record length: %z", f->length); | |
1993 | |
1994 f->pos = p + 1; | |
1995 f->state = state; | |
1996 | |
1997 return NGX_OK; | |
1998 | |
1999 /* suppress warning */ | |
2000 case ngx_http_fastcgi_st_data: | |
2001 case ngx_http_fastcgi_st_padding: | |
2002 break; | |
2003 } | |
2004 } | |
2005 | |
2006 f->state = state; | |
2007 | |
2008 return NGX_AGAIN; | |
2009 } | |
2010 | |
2011 | |
487 | 2012 static void |
2013 ngx_http_fastcgi_abort_request(ngx_http_request_t *r) | |
479 | 2014 { |
2015 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2016 "abort http fastcgi request"); | |
2017 | |
2018 return; | |
2019 } | |
2020 | |
2021 | |
487 | 2022 static void |
2023 ngx_http_fastcgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
479 | 2024 { |
2025 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2026 "finalize http fastcgi request"); | |
2027 | |
2028 return; | |
2029 } | |
2030 | |
2031 | |
509 | 2032 static ngx_int_t |
2033 ngx_http_fastcgi_add_variables(ngx_conf_t *cf) | |
479 | 2034 { |
2443 | 2035 ngx_http_variable_t *var, *v; |
2036 | |
2037 for (v = ngx_http_fastcgi_vars; v->name.len; v++) { | |
2038 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
2039 if (var == NULL) { | |
2040 return NGX_ERROR; | |
2041 } | |
2042 | |
2043 var->get_handler = v->get_handler; | |
2044 var->data = v->data; | |
479 | 2045 } |
2046 | |
509 | 2047 return NGX_OK; |
479 | 2048 } |
2049 | |
2050 | |
487 | 2051 static void * |
2052 ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf) | |
479 | 2053 { |
2054 ngx_http_fastcgi_loc_conf_t *conf; | |
2055 | |
501 | 2056 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t)); |
2057 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
|
2058 return NULL; |
479 | 2059 } |
2060 | |
2061 /* | |
2062 * set by ngx_pcalloc(): | |
2063 * | |
2064 * conf->upstream.bufs.num = 0; | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2065 * conf->upstream.ignore_headers = 0; |
479 | 2066 * conf->upstream.next_upstream = 0; |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2067 * conf->upstream.cache_use_stale = 0; |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2068 * conf->upstream.cache_methods = 0; |
479 | 2069 * conf->upstream.temp_path = NULL; |
649 | 2070 * conf->upstream.hide_headers_hash = { NULL, 0 }; |
509 | 2071 * conf->upstream.uri = { 0, NULL }; |
2072 * conf->upstream.location = NULL; | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2073 * conf->upstream.store_lengths = NULL; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2074 * conf->upstream.store_values = NULL; |
509 | 2075 * |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3494
diff
changeset
|
2076 * conf->index.len = { 0, NULL }; |
479 | 2077 */ |
2078 | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2079 conf->upstream.store = NGX_CONF_UNSET; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2080 conf->upstream.store_access = NGX_CONF_UNSET_UINT; |
581 | 2081 conf->upstream.buffering = NGX_CONF_UNSET; |
629 | 2082 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; |
581 | 2083 |
479 | 2084 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
2085 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
507 | 2086 conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC; |
2087 | |
479 | 2088 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; |
581 | 2089 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE; |
529 | 2090 |
2091 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
577 | 2092 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; |
529 | 2093 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; |
509 | 2094 |
2095 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
2096 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
2097 | |
2602 | 2098 #if (NGX_HTTP_CACHE) |
2099 conf->upstream.cache = NGX_CONF_UNSET_PTR; | |
2100 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
|
2101 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
|
2102 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; |
2602 | 2103 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
|
2104 conf->upstream.cache_lock = NGX_CONF_UNSET; |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2105 conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; |
2602 | 2106 #endif |
2107 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2108 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
|
2109 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
|
2110 |
657 | 2111 conf->upstream.intercept_errors = NGX_CONF_UNSET; |
479 | 2112 |
2113 /* "fastcgi_cyclic_temp_file" is disabled */ | |
2114 conf->upstream.cyclic_temp_file = 0; | |
2115 | |
1452
cd586e963db0
change ngx_conf_merge_ptr_value() and update fastcgi_catch_stderr
Igor Sysoev <igor@sysoev.ru>
parents:
1295
diff
changeset
|
2116 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
|
2117 |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
2118 conf->keep_conn = NGX_CONF_UNSET; |
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
2119 |
3976
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3879
diff
changeset
|
2120 ngx_str_set(&conf->upstream.module, "fastcgi"); |
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3879
diff
changeset
|
2121 |
479 | 2122 return conf; |
2123 } | |
2124 | |
2125 | |
487 | 2126 static char * |
2127 ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
479 | 2128 { |
2129 ngx_http_fastcgi_loc_conf_t *prev = parent; | |
2130 ngx_http_fastcgi_loc_conf_t *conf = child; | |
2131 | |
509 | 2132 size_t size; |
649 | 2133 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
|
2134 ngx_http_core_loc_conf_t *clcf; |
479 | 2135 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2136 if (conf->upstream.store != 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2137 ngx_conf_merge_value(conf->upstream.store, |
2894 | 2138 prev->upstream.store, 0); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2139 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2140 if (conf->upstream.store_lengths == NULL) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2141 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
|
2142 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
|
2143 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2144 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2145 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2146 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
|
2147 prev->upstream.store_access, 0600); |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1276
diff
changeset
|
2148 |
581 | 2149 ngx_conf_merge_value(conf->upstream.buffering, |
2150 prev->upstream.buffering, 1); | |
2151 | |
629 | 2152 ngx_conf_merge_value(conf->upstream.ignore_client_abort, |
2153 prev->upstream.ignore_client_abort, 0); | |
2154 | |
479 | 2155 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
2156 prev->upstream.connect_timeout, 60000); | |
507 | 2157 |
479 | 2158 ngx_conf_merge_msec_value(conf->upstream.send_timeout, |
2159 prev->upstream.send_timeout, 60000); | |
2160 | |
2161 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
2162 prev->upstream.read_timeout, 60000); | |
2163 | |
507 | 2164 ngx_conf_merge_size_value(conf->upstream.send_lowat, |
2165 prev->upstream.send_lowat, 0); | |
479 | 2166 |
581 | 2167 ngx_conf_merge_size_value(conf->upstream.buffer_size, |
2168 prev->upstream.buffer_size, | |
479 | 2169 (size_t) ngx_pagesize); |
2170 | |
507 | 2171 |
479 | 2172 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, |
2173 8, ngx_pagesize); | |
2174 | |
2175 if (conf->upstream.bufs.num < 2) { | |
2176 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2177 "there must be at least 2 \"fastcgi_buffers\""); | |
2178 return NGX_CONF_ERROR; | |
2179 } | |
2180 | |
2181 | |
581 | 2182 size = conf->upstream.buffer_size; |
479 | 2183 if (size < conf->upstream.bufs.size) { |
2184 size = conf->upstream.bufs.size; | |
2185 } | |
2186 | |
2187 | |
529 | 2188 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, |
2189 prev->upstream.busy_buffers_size_conf, | |
479 | 2190 NGX_CONF_UNSET_SIZE); |
2191 | |
529 | 2192 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 2193 conf->upstream.busy_buffers_size = 2 * size; |
529 | 2194 } else { |
2195 conf->upstream.busy_buffers_size = | |
2196 conf->upstream.busy_buffers_size_conf; | |
2197 } | |
479 | 2198 |
529 | 2199 if (conf->upstream.busy_buffers_size < size) { |
479 | 2200 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2201 "\"fastcgi_busy_buffers_size\" must be equal or bigger than " | |
1125
2d978e1443ed
use the contemporary directives
Igor Sysoev <igor@sysoev.ru>
parents:
1097
diff
changeset
|
2202 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 2203 "one of the \"fastcgi_buffers\""); |
2204 | |
2205 return NGX_CONF_ERROR; | |
529 | 2206 } |
479 | 2207 |
529 | 2208 if (conf->upstream.busy_buffers_size |
2209 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
479 | 2210 { |
2211 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2212 "\"fastcgi_busy_buffers_size\" must be less than " | |
2213 "the size of all \"fastcgi_buffers\" minus one buffer"); | |
2214 | |
2215 return NGX_CONF_ERROR; | |
2216 } | |
2217 | |
2218 | |
529 | 2219 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, |
2220 prev->upstream.temp_file_write_size_conf, | |
479 | 2221 NGX_CONF_UNSET_SIZE); |
2222 | |
529 | 2223 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 2224 conf->upstream.temp_file_write_size = 2 * size; |
529 | 2225 } else { |
2226 conf->upstream.temp_file_write_size = | |
2227 conf->upstream.temp_file_write_size_conf; | |
2228 } | |
479 | 2229 |
529 | 2230 if (conf->upstream.temp_file_write_size < size) { |
479 | 2231 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2232 "\"fastcgi_temp_file_write_size\" must be equal or bigger than " | |
1125
2d978e1443ed
use the contemporary directives
Igor Sysoev <igor@sysoev.ru>
parents:
1097
diff
changeset
|
2233 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 2234 "one of the \"fastcgi_buffers\""); |
2235 | |
2236 return NGX_CONF_ERROR; | |
2237 } | |
2238 | |
2239 | |
529 | 2240 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, |
2241 prev->upstream.max_temp_file_size_conf, | |
479 | 2242 NGX_CONF_UNSET_SIZE); |
2243 | |
529 | 2244 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { |
479 | 2245 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; |
529 | 2246 } else { |
2247 conf->upstream.max_temp_file_size = | |
2248 conf->upstream.max_temp_file_size_conf; | |
2249 } | |
479 | 2250 |
529 | 2251 if (conf->upstream.max_temp_file_size != 0 |
2252 && conf->upstream.max_temp_file_size < size) | |
479 | 2253 { |
2254 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2255 "\"fastcgi_max_temp_file_size\" must be equal to zero to disable " | |
2256 "the temporary files usage or must be equal or bigger than " | |
1125
2d978e1443ed
use the contemporary directives
Igor Sysoev <igor@sysoev.ru>
parents:
1097
diff
changeset
|
2257 "maximum of the value of \"fastcgi_buffer_size\" and " |
479 | 2258 "one of the \"fastcgi_buffers\""); |
2259 | |
2260 return NGX_CONF_ERROR; | |
2261 } | |
2262 | |
2263 | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2264 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
|
2265 prev->upstream.ignore_headers, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2266 NGX_CONF_BITMASK_SET); |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2267 |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2729
diff
changeset
|
2268 |
479 | 2269 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, |
487 | 2270 prev->upstream.next_upstream, |
2271 (NGX_CONF_BITMASK_SET | |
2272 |NGX_HTTP_UPSTREAM_FT_ERROR | |
2273 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
479 | 2274 |
665 | 2275 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { |
2276 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
2277 |NGX_HTTP_UPSTREAM_FT_OFF; | |
2278 } | |
2279 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2280 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path, |
479 | 2281 prev->upstream.temp_path, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2282 &ngx_http_fastcgi_temp_path) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2283 != NGX_OK) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2284 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2285 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2467
diff
changeset
|
2286 } |
479 | 2287 |
2602 | 2288 #if (NGX_HTTP_CACHE) |
2289 | |
2290 ngx_conf_merge_ptr_value(conf->upstream.cache, | |
2291 prev->upstream.cache, NULL); | |
2292 | |
2293 if (conf->upstream.cache && conf->upstream.cache->data == NULL) { | |
2294 ngx_shm_zone_t *shm_zone; | |
2295 | |
2296 shm_zone = conf->upstream.cache; | |
2297 | |
2298 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2299 "\"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
|
2300 &shm_zone->shm.name); |
2602 | 2301 |
2302 return NGX_CONF_ERROR; | |
2303 } | |
2304 | |
2305 ngx_conf_merge_uint_value(conf->upstream.cache_min_uses, | |
2306 prev->upstream.cache_min_uses, 1); | |
2307 | |
2308 ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale, | |
2309 prev->upstream.cache_use_stale, | |
2310 (NGX_CONF_BITMASK_SET | |
2311 |NGX_HTTP_UPSTREAM_FT_OFF)); | |
2312 | |
2313 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) { | |
2314 conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET | |
2315 |NGX_HTTP_UPSTREAM_FT_OFF; | |
2316 } | |
2317 | |
4401
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
2318 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
|
2319 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
|
2320 } |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
2321 |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2322 if (conf->upstream.cache_methods == 0) { |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2323 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
|
2324 } |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2325 |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2326 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
|
2327 |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
2328 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
|
2329 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
|
2330 |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2331 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
|
2332 prev->upstream.no_cache, NULL); |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2333 |
3700
e40453e6931b
add warnings for proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3699
diff
changeset
|
2334 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
|
2335 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
|
2336 "\"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
|
2337 "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
|
2338 } |
e40453e6931b
add warnings for proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3699
diff
changeset
|
2339 |
2602 | 2340 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, |
2341 prev->upstream.cache_valid, NULL); | |
2342 | |
2661 | 2343 if (conf->cache_key.value.data == NULL) { |
2344 conf->cache_key = prev->cache_key; | |
2345 } | |
2346 | |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2347 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
|
2348 prev->upstream.cache_lock, 0); |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2349 |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2350 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
|
2351 prev->upstream.cache_lock_timeout, 5000); |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4329
diff
changeset
|
2352 |
2602 | 2353 #endif |
2354 | |
509 | 2355 ngx_conf_merge_value(conf->upstream.pass_request_headers, |
2356 prev->upstream.pass_request_headers, 1); | |
2357 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
2358 prev->upstream.pass_request_body, 1); | |
2359 | |
657 | 2360 ngx_conf_merge_value(conf->upstream.intercept_errors, |
2361 prev->upstream.intercept_errors, 0); | |
509 | 2362 |
1228 | 2363 ngx_conf_merge_ptr_value(conf->catch_stderr, prev->catch_stderr, NULL); |
2364 | |
4122
c7fae0daeb57
Keepalive support in fastcgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
2365 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
|
2366 |
507 | 2367 |
479 | 2368 ngx_conf_merge_str_value(conf->index, prev->index, ""); |
2369 | |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2370 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
|
2371 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
|
2372 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
|
2373 |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1700
diff
changeset
|
2374 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
|
2375 &prev->upstream, ngx_http_fastcgi_hide_headers, &hash) |
649 | 2376 != NGX_OK) |
2377 { | |
2378 return NGX_CONF_ERROR; | |
2379 } | |
2380 | |
884 | 2381 if (conf->upstream.upstream == NULL) { |
2382 conf->upstream.upstream = prev->upstream.upstream; | |
507 | 2383 } |
2384 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2385 if (conf->fastcgi_lengths == NULL) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2386 conf->fastcgi_lengths = prev->fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2387 conf->fastcgi_values = prev->fastcgi_values; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2388 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2389 |
3731
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2390 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
|
2391 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
|
2392 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
|
2393 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
|
2394 } |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2395 } |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2396 |
2443 | 2397 #if (NGX_PCRE) |
2398 if (conf->split_regex == NULL) { | |
2399 conf->split_regex = prev->split_regex; | |
2400 conf->split_name = prev->split_name; | |
2401 } | |
2402 #endif | |
2403 | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2404 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
|
2405 return NGX_CONF_ERROR; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2406 } |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2407 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2408 return NGX_CONF_OK; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2409 } |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2410 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2411 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2412 static ngx_int_t |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2413 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
|
2414 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
|
2415 { |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2416 u_char *p; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2417 size_t size; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2418 uintptr_t *code; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2419 ngx_uint_t i, nsrc; |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2420 ngx_array_t headers_names; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2421 #if (NGX_HTTP_CACHE) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2422 ngx_array_t params_merged; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2423 #endif |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2424 ngx_hash_key_t *hk; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2425 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
|
2426 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
|
2427 ngx_http_script_compile_t sc; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2428 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
|
2429 |
509 | 2430 if (conf->params_source == NULL) { |
573 | 2431 conf->params_source = prev->params_source; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2432 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2433 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
|
2434 #if (NGX_HTTP_CACHE) |
4522 | 2435 && ((conf->upstream.cache == NULL) |
2436 == (prev->upstream.cache == NULL)) | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2437 #endif |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2438 ) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2439 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2440 conf->flushes = prev->flushes; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2441 conf->params_len = prev->params_len; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2442 conf->params = prev->params; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2443 conf->headers_hash = prev->headers_hash; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2444 conf->header_params = prev->header_params; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2445 |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2446 return NGX_OK; |
509 | 2447 } |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2448 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2449 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2450 if (conf->params_source == NULL |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2451 #if (NGX_HTTP_CACHE) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2452 && (conf->upstream.cache == NULL) |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2453 #endif |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2454 ) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2455 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2456 conf->headers_hash.buckets = (void *) 1; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2457 return NGX_OK; |
509 | 2458 } |
2459 | |
2460 conf->params_len = ngx_array_create(cf->pool, 64, 1); | |
2461 if (conf->params_len == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2462 return NGX_ERROR; |
509 | 2463 } |
573 | 2464 |
509 | 2465 conf->params = ngx_array_create(cf->pool, 512, 1); |
2466 if (conf->params == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2467 return NGX_ERROR; |
509 | 2468 } |
2469 | |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2470 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
|
2471 != NGX_OK) |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2472 { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2473 return NGX_ERROR; |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2474 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2475 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2476 if (conf->params_source) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2477 src = conf->params_source->elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2478 nsrc = conf->params_source->nelts; |
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 } else { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2481 src = NULL; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2482 nsrc = 0; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2483 } |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2484 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2485 #if (NGX_HTTP_CACHE) |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2486 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2487 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
|
2488 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
|
2489 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
|
2490 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2491 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
|
2492 sizeof(ngx_http_upstream_param_t)) |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2493 != NGX_OK) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2494 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2495 return NGX_ERROR; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2496 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2497 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2498 for (i = 0; i < nsrc; i++) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2499 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2500 s = ngx_array_push(¶ms_merged); |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2501 if (s == NULL) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2502 return NGX_ERROR; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2503 } |
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 *s = src[i]; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2506 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2507 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2508 h = ngx_http_fastcgi_cache_headers; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2509 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2510 while (h->key.len) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2511 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2512 src = params_merged.elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2513 nsrc = params_merged.nelts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2514 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2515 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
|
2516 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
|
2517 goto next; |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2518 } |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2519 } |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2520 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2521 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
|
2522 if (s == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2523 return NGX_ERROR; |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2524 } |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2525 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2526 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
|
2527 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
|
2528 s->skip_empty = 0; |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2529 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2530 next: |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2531 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2532 h++; |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2533 } |
4278
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 src = params_merged.elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2536 nsrc = params_merged.nelts; |
3563
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2537 } |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2538 |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2539 #endif |
90d7227d47bf
do not pass if-... headers for cacheable fastcgi responses
Igor Sysoev <igor@sysoev.ru>
parents:
3562
diff
changeset
|
2540 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
2541 for (i = 0; i < nsrc; i++) { |
509 | 2542 |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2543 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
|
2544 && 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
|
2545 { |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2546 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
|
2547 if (hk == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2548 return NGX_ERROR; |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2549 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2550 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2551 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
|
2552 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
|
2553 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
|
2554 hk->value = (void *) 1; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2555 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2556 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
|
2557 continue; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2558 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2559 } |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2560 |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2561 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
|
2562 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
|
2563 if (copy == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2564 return NGX_ERROR; |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2565 } |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2566 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2567 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
|
2568 copy->len = src[i].key.len; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2569 |
4329
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2570 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
|
2571 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
|
2572 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
|
2573 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
|
2574 } |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2575 |
31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
2576 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
|
2577 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
|
2578 |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2579 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2580 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
|
2581 + 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
|
2582 & ~(sizeof(uintptr_t) - 1); |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2583 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2584 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
|
2585 if (copy == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2586 return NGX_ERROR; |
3558
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2587 } |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2588 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2589 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
|
2590 copy->len = src[i].key.len; |
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 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
|
2593 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
|
2594 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2595 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2596 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
|
2597 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2598 sc.cf = cf; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2599 sc.source = &src[i].value; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2600 sc.flushes = &conf->flushes; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2601 sc.lengths = &conf->params_len; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2602 sc.values = &conf->params; |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2603 |
83c9a10ec029
remove the special static fastcgi_param values processing,
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
2604 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
|
2605 return NGX_ERROR; |
509 | 2606 } |
2607 | |
2608 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
2609 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2610 return NGX_ERROR; |
509 | 2611 } |
2612 | |
2613 *code = (uintptr_t) NULL; | |
2614 | |
2615 | |
2616 code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); | |
2617 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2618 return NGX_ERROR; |
509 | 2619 } |
2620 | |
2621 *code = (uintptr_t) NULL; | |
2622 } | |
2623 | |
2624 code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t)); | |
2625 if (code == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2626 return NGX_ERROR; |
509 | 2627 } |
2628 | |
2629 *code = (uintptr_t) NULL; | |
2630 | |
3560
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2631 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
|
2632 |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2633 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
|
2634 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
|
2635 hash.max_size = 512; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2636 hash.bucket_size = 64; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2637 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
|
2638 hash.pool = cf->pool; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2639 hash.temp_pool = NULL; |
a36c63c6d26a
allow fastcgi_param to override client headers using HTTP_ parameters
Igor Sysoev <igor@sysoev.ru>
parents:
3559
diff
changeset
|
2640 |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4273
diff
changeset
|
2641 return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); |
479 | 2642 } |
509 | 2643 |
2644 | |
573 | 2645 static ngx_int_t |
2646 ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, | |
2647 ngx_http_variable_value_t *v, uintptr_t data) | |
509 | 2648 { |
2649 u_char *p; | |
2443 | 2650 ngx_http_fastcgi_ctx_t *f; |
509 | 2651 ngx_http_fastcgi_loc_conf_t *flcf; |
2652 | |
2443 | 2653 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); |
2654 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2655 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
|
2656 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2657 if (f == NULL) { |
2443 | 2658 return NGX_ERROR; |
2659 } | |
2660 | |
2661 if (f->script_name.len == 0 | |
2662 || f->script_name.data[f->script_name.len - 1] != '/') | |
2663 { | |
2664 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
|
2665 v->valid = 1; |
1565 | 2666 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
|
2667 v->not_found = 0; |
2443 | 2668 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
|
2669 |
573 | 2670 return NGX_OK; |
509 | 2671 } |
2672 | |
2443 | 2673 v->len = f->script_name.len + flcf->index.len; |
2674 | |
2675 v->data = ngx_pnalloc(r->pool, v->len); | |
2676 if (v->data == NULL) { | |
2677 return NGX_ERROR; | |
2678 } | |
2679 | |
2680 p = ngx_copy(v->data, f->script_name.data, f->script_name.len); | |
2681 ngx_memcpy(p, flcf->index.data, flcf->index.len); | |
2682 | |
573 | 2683 return NGX_OK; |
509 | 2684 } |
2685 | |
2686 | |
2443 | 2687 static ngx_int_t |
2688 ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r, | |
2689 ngx_http_variable_value_t *v, uintptr_t data) | |
2690 { | |
2691 ngx_http_fastcgi_ctx_t *f; | |
2692 ngx_http_fastcgi_loc_conf_t *flcf; | |
2693 | |
2694 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); | |
2695 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2696 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
|
2697 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2698 if (f == NULL) { |
2443 | 2699 return NGX_ERROR; |
2700 } | |
2701 | |
2702 v->len = f->path_info.len; | |
2703 v->valid = 1; | |
2704 v->no_cacheable = 0; | |
2705 v->not_found = 0; | |
2706 v->data = f->path_info.data; | |
2707 | |
2708 return NGX_OK; | |
2709 } | |
2710 | |
2711 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2712 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
|
2713 ngx_http_fastcgi_split(ngx_http_request_t *r, ngx_http_fastcgi_loc_conf_t *flcf) |
2443 | 2714 { |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2715 ngx_http_fastcgi_ctx_t *f; |
2443 | 2716 #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
|
2717 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
|
2718 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
|
2719 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2720 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
|
2721 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2722 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
|
2723 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
|
2724 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
|
2725 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
|
2726 } |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2727 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2728 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
|
2729 } |
2443 | 2730 |
2731 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
|
2732 return f; |
2443 | 2733 } |
2734 | |
2735 if (flcf->split_regex == NULL) { | |
2736 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
|
2737 return f; |
2443 | 2738 } |
2739 | |
2740 n = ngx_regex_exec(flcf->split_regex, &r->uri, captures, (1 + 2) * 3); | |
2741 | |
3325 | 2742 if (n >= 0) { /* match */ |
2743 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
|
2744 f->script_name.data = r->uri.data + captures[2]; |
3325 | 2745 |
2746 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
|
2747 f->path_info.data = r->uri.data + captures[4]; |
3325 | 2748 |
2749 return f; | |
2750 } | |
2751 | |
2443 | 2752 if (n == NGX_REGEX_NO_MATCHED) { |
2753 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
|
2754 return f; |
2443 | 2755 } |
2756 | |
3325 | 2757 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
2758 ngx_regex_exec_n " failed: %i on \"%V\" using \"%V\"", | |
2759 n, &r->uri, &flcf->split_name); | |
2760 return NULL; | |
2443 | 2761 |
2762 #else | |
2763 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2764 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
|
2765 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2766 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
|
2767 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
|
2768 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
|
2769 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
|
2770 } |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2771 |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2772 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
|
2773 } |
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2774 |
2443 | 2775 f->script_name = r->uri; |
2776 | |
2467
84f2bef92007
fix segfault if $fastcgi_script_name or $fastcgi_path_info were used before
Igor Sysoev <igor@sysoev.ru>
parents:
2443
diff
changeset
|
2777 return f; |
2443 | 2778 |
2779 #endif | |
2780 } | |
2781 | |
2782 | |
509 | 2783 static char * |
2784 ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2785 { | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2786 ngx_http_fastcgi_loc_conf_t *flcf = conf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2787 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2788 ngx_url_t u; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2789 ngx_str_t *value, *url; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2790 ngx_uint_t n; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2791 ngx_http_core_loc_conf_t *clcf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2792 ngx_http_script_compile_t sc; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2793 |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2390
diff
changeset
|
2794 if (flcf->upstream.upstream || flcf->fastcgi_lengths) { |
555 | 2795 return "is duplicate"; |
2796 } | |
2797 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2798 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
|
2799 |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2800 clcf->handler = ngx_http_fastcgi_handler; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2801 |
2989
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2927
diff
changeset
|
2802 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
|
2803 clcf->auto_redirect = 1; |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2927
diff
changeset
|
2804 } |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2927
diff
changeset
|
2805 |
509 | 2806 value = cf->args->elts; |
2807 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2808 url = &value[1]; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2809 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2810 n = ngx_http_script_variables_count(url); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2811 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2812 if (n) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2813 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2814 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2815 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2816 sc.cf = cf; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2817 sc.source = url; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2818 sc.lengths = &flcf->fastcgi_lengths; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2819 sc.values = &flcf->fastcgi_values; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2820 sc.variables = n; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2821 sc.complete_lengths = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2822 sc.complete_values = 1; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2823 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2824 if (ngx_http_script_compile(&sc) != NGX_OK) { |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2825 return NGX_CONF_ERROR; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2826 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2827 |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2828 return NGX_CONF_OK; |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2829 } |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2830 |
651 | 2831 ngx_memzero(&u, sizeof(ngx_url_t)); |
2832 | |
2833 u.url = value[1]; | |
884 | 2834 u.no_resolve = 1; |
2835 | |
2390
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2836 flcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); |
27ccc4b54fa6
fastcgi_pass variables support
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
2837 if (flcf->upstream.upstream == NULL) { |
509 | 2838 return NGX_CONF_ERROR; |
2839 } | |
2840 | |
2841 return NGX_CONF_OK; | |
2842 } | |
2843 | |
2844 | |
2845 static char * | |
2443 | 2846 ngx_http_fastcgi_split_path_info(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
2847 { | |
2848 #if (NGX_PCRE) | |
2849 ngx_http_fastcgi_loc_conf_t *flcf = conf; | |
2850 | |
3325 | 2851 ngx_str_t *value; |
2852 ngx_regex_compile_t rc; | |
2853 u_char errstr[NGX_MAX_CONF_ERRSTR]; | |
2443 | 2854 |
2855 value = cf->args->elts; | |
2856 | |
2857 flcf->split_name = value[1]; | |
2858 | |
3325 | 2859 ngx_memzero(&rc, sizeof(ngx_regex_compile_t)); |
2860 | |
2861 rc.pattern = value[1]; | |
2862 rc.pool = cf->pool; | |
2863 rc.err.len = NGX_MAX_CONF_ERRSTR; | |
2864 rc.err.data = errstr; | |
2865 | |
2866 if (ngx_regex_compile(&rc) != NGX_OK) { | |
2867 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V", &rc.err); | |
2443 | 2868 return NGX_CONF_ERROR; |
2869 } | |
2870 | |
3325 | 2871 if (rc.captures != 2) { |
2443 | 2872 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2873 "pattern \"%V\" must have 2 captures", &value[1]); | |
2874 return NGX_CONF_ERROR; | |
2875 } | |
2876 | |
3325 | 2877 flcf->split_regex = rc.regex; |
2878 | |
2443 | 2879 return NGX_CONF_OK; |
2880 | |
2881 #else | |
2882 | |
2883 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2884 "\"%V\" requires PCRE library", &cmd->name); | |
2885 return NGX_CONF_ERROR; | |
2886 | |
2887 #endif | |
2888 } | |
2889 | |
2890 | |
2891 static char * | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2892 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
|
2893 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2894 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
|
2895 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2896 ngx_str_t *value; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2897 ngx_http_script_compile_t sc; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2898 |
2894 | 2899 if (flcf->upstream.store != NGX_CONF_UNSET |
2900 || flcf->upstream.store_lengths) | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2901 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2902 return "is duplicate"; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2903 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2904 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2905 value = cf->args->elts; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2906 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2907 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
|
2908 flcf->upstream.store = 0; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2909 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2910 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2911 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2912 #if (NGX_HTTP_CACHE) |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2913 |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2914 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
|
2915 && flcf->upstream.cache != NULL) |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2916 { |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2917 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
|
2918 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2919 |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2920 #endif |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2921 |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2922 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
|
2923 flcf->upstream.store = 1; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2924 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2925 } |
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 /* include the terminating '\0' into script */ |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2928 value[1].len++; |
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 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
|
2931 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2932 sc.cf = cf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2933 sc.source = &value[1]; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2934 sc.lengths = &flcf->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2935 sc.values = &flcf->upstream.store_values; |
1563
022ec9420f80
style fix: remove double semicolons
Igor Sysoev <igor@sysoev.ru>
parents:
1488
diff
changeset
|
2936 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
|
2937 sc.complete_lengths = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2938 sc.complete_values = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2939 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2940 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
|
2941 return NGX_CONF_ERROR; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2942 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2943 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2944 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2945 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2946 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2947 |
2602 | 2948 #if (NGX_HTTP_CACHE) |
2949 | |
2950 static char * | |
2951 ngx_http_fastcgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2952 { | |
2953 ngx_http_fastcgi_loc_conf_t *flcf = conf; | |
2954 | |
2955 ngx_str_t *value; | |
2956 | |
2957 value = cf->args->elts; | |
2958 | |
2959 if (flcf->upstream.cache != NGX_CONF_UNSET_PTR) { | |
2960 return "is duplicate"; | |
2961 } | |
2962 | |
2963 if (ngx_strcmp(value[1].data, "off") == 0) { | |
2964 flcf->upstream.cache = NULL; | |
2965 return NGX_CONF_OK; | |
2966 } | |
2967 | |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2968 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
|
2969 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
|
2970 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
2971 |
2602 | 2972 flcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0, |
2973 &ngx_http_fastcgi_module); | |
2974 if (flcf->upstream.cache == NULL) { | |
2975 return NGX_CONF_ERROR; | |
2976 } | |
2977 | |
2978 return NGX_CONF_OK; | |
2979 } | |
2980 | |
2981 | |
2982 static char * | |
2983 ngx_http_fastcgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2984 { | |
2985 ngx_http_fastcgi_loc_conf_t *flcf = conf; | |
2986 | |
2987 ngx_str_t *value; | |
2988 ngx_http_compile_complex_value_t ccv; | |
2989 | |
2990 value = cf->args->elts; | |
2991 | |
2992 if (flcf->cache_key.value.len) { | |
2993 return "is duplicate"; | |
2994 } | |
2995 | |
2996 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
2997 | |
2998 ccv.cf = cf; | |
2999 ccv.value = &value[1]; | |
3000 ccv.complex_value = &flcf->cache_key; | |
3001 | |
3002 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
3003 return NGX_CONF_ERROR; | |
3004 } | |
3005 | |
3006 return NGX_CONF_OK; | |
3007 } | |
3008 | |
3009 #endif | |
3010 | |
3011 | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3012 static char * |
509 | 3013 ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data) |
3014 { | |
3015 #if (NGX_FREEBSD) | |
3016 ssize_t *np = data; | |
3017 | |
673 | 3018 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { |
509 | 3019 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3020 "\"fastcgi_send_lowat\" must be less than %d " | |
3021 "(sysctl net.inet.tcp.sendspace)", | |
3022 ngx_freebsd_net_inet_tcp_sendspace); | |
3023 | |
3024 return NGX_CONF_ERROR; | |
3025 } | |
3026 | |
3027 #elif !(NGX_HAVE_SO_SNDLOWAT) | |
3028 ssize_t *np = data; | |
3029 | |
3030 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
3031 "\"fastcgi_send_lowat\" is not supported, ignored"); | |
3032 | |
3033 *np = 0; | |
3034 | |
3035 #endif | |
3036 | |
3037 return NGX_CONF_OK; | |
3038 } |