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