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