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