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