Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_scgi_module.c @ 5908:f8e80f8c7fc7
Upstream: moved header lists to separate structures.
No functional changes.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 19 Nov 2014 17:33:22 +0300 |
parents | 195561ef367f |
children | 8d0cf26ce071 |
rev | line source |
---|---|
3637 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
3637 | 5 * Copyright (C) Manlio Perillo (manlio.perillo@gmail.com) |
6 */ | |
7 | |
8 | |
9 #include <ngx_config.h> | |
10 #include <ngx_core.h> | |
11 #include <ngx_http.h> | |
12 | |
13 | |
14 typedef struct { | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
15 ngx_array_t *flushes; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
16 ngx_array_t *lengths; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
17 ngx_array_t *values; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
18 ngx_uint_t number; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
19 ngx_hash_t hash; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
20 } ngx_http_scgi_params_t; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
21 |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
22 |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
23 typedef struct { |
3637 | 24 ngx_http_upstream_conf_t upstream; |
25 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
26 ngx_http_scgi_params_t params; |
3637 | 27 ngx_array_t *params_source; |
28 | |
29 ngx_array_t *scgi_lengths; | |
30 ngx_array_t *scgi_values; | |
31 | |
32 #if (NGX_HTTP_CACHE) | |
33 ngx_http_complex_value_t cache_key; | |
34 #endif | |
35 } ngx_http_scgi_loc_conf_t; | |
36 | |
37 | |
38 static ngx_int_t ngx_http_scgi_eval(ngx_http_request_t *r, | |
39 ngx_http_scgi_loc_conf_t *scf); | |
40 static ngx_int_t ngx_http_scgi_create_request(ngx_http_request_t *r); | |
41 static ngx_int_t ngx_http_scgi_reinit_request(ngx_http_request_t *r); | |
42 static ngx_int_t ngx_http_scgi_process_status_line(ngx_http_request_t *r); | |
43 static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r); | |
44 static void ngx_http_scgi_abort_request(ngx_http_request_t *r); | |
45 static void ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc); | |
46 | |
47 static void *ngx_http_scgi_create_loc_conf(ngx_conf_t *cf); | |
48 static char *ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, | |
49 void *child); | |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
50 static ngx_int_t ngx_http_scgi_init_params(ngx_conf_t *cf, |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
51 ngx_http_scgi_loc_conf_t *conf, ngx_http_scgi_params_t *params); |
3637 | 52 |
53 static char *ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
54 static char *ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd, | |
55 void *conf); | |
56 | |
57 #if (NGX_HTTP_CACHE) | |
58 static ngx_int_t ngx_http_scgi_create_key(ngx_http_request_t *r); | |
59 static char *ngx_http_scgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, | |
60 void *conf); | |
61 static char *ngx_http_scgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, | |
62 void *conf); | |
63 #endif | |
64 | |
65 | |
66 static ngx_conf_bitmask_t ngx_http_scgi_next_upstream_masks[] = { | |
67 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, | |
68 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, | |
69 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, | |
70 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, | |
71 { 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:
5080
diff
changeset
|
72 { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 }, |
3637 | 73 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, |
74 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING }, | |
75 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, | |
76 { ngx_null_string, 0 } | |
77 }; | |
78 | |
79 | |
80 ngx_module_t ngx_http_scgi_module; | |
81 | |
82 | |
83 static ngx_command_t ngx_http_scgi_commands[] = { | |
84 | |
85 { ngx_string("scgi_pass"), | |
86 NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1, | |
87 ngx_http_scgi_pass, | |
88 NGX_HTTP_LOC_CONF_OFFSET, | |
89 0, | |
90 NULL }, | |
91 | |
92 { ngx_string("scgi_store"), | |
93 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
94 ngx_http_scgi_store, | |
95 NGX_HTTP_LOC_CONF_OFFSET, | |
96 0, | |
97 NULL }, | |
98 | |
99 { ngx_string("scgi_store_access"), | |
100 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, | |
101 ngx_conf_set_access_slot, | |
102 NGX_HTTP_LOC_CONF_OFFSET, | |
103 offsetof(ngx_http_scgi_loc_conf_t, upstream.store_access), | |
104 NULL }, | |
105 | |
4157
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
106 { ngx_string("scgi_buffering"), |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
107 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
108 ngx_conf_set_flag_slot, |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
109 NGX_HTTP_LOC_CONF_OFFSET, |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
110 offsetof(ngx_http_scgi_loc_conf_t, upstream.buffering), |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
111 NULL }, |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
112 |
3637 | 113 { ngx_string("scgi_ignore_client_abort"), |
114 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
115 ngx_conf_set_flag_slot, | |
116 NGX_HTTP_LOC_CONF_OFFSET, | |
117 offsetof(ngx_http_scgi_loc_conf_t, upstream.ignore_client_abort), | |
118 NULL }, | |
119 | |
120 { ngx_string("scgi_bind"), | |
121 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
122 ngx_http_upstream_bind_set_slot, | |
123 NGX_HTTP_LOC_CONF_OFFSET, | |
124 offsetof(ngx_http_scgi_loc_conf_t, upstream.local), | |
125 NULL }, | |
126 | |
127 { ngx_string("scgi_connect_timeout"), | |
128 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
129 ngx_conf_set_msec_slot, | |
130 NGX_HTTP_LOC_CONF_OFFSET, | |
131 offsetof(ngx_http_scgi_loc_conf_t, upstream.connect_timeout), | |
132 NULL }, | |
133 | |
134 { ngx_string("scgi_send_timeout"), | |
135 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
136 ngx_conf_set_msec_slot, | |
137 NGX_HTTP_LOC_CONF_OFFSET, | |
138 offsetof(ngx_http_scgi_loc_conf_t, upstream.send_timeout), | |
139 NULL }, | |
140 | |
141 { ngx_string("scgi_buffer_size"), | |
142 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
143 ngx_conf_set_size_slot, | |
144 NGX_HTTP_LOC_CONF_OFFSET, | |
145 offsetof(ngx_http_scgi_loc_conf_t, upstream.buffer_size), | |
146 NULL }, | |
147 | |
148 { ngx_string("scgi_pass_request_headers"), | |
149 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
150 ngx_conf_set_flag_slot, | |
151 NGX_HTTP_LOC_CONF_OFFSET, | |
152 offsetof(ngx_http_scgi_loc_conf_t, upstream.pass_request_headers), | |
153 NULL }, | |
154 | |
155 { ngx_string("scgi_pass_request_body"), | |
156 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
157 ngx_conf_set_flag_slot, | |
158 NGX_HTTP_LOC_CONF_OFFSET, | |
159 offsetof(ngx_http_scgi_loc_conf_t, upstream.pass_request_body), | |
160 NULL }, | |
161 | |
162 { ngx_string("scgi_intercept_errors"), | |
163 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
164 ngx_conf_set_flag_slot, | |
165 NGX_HTTP_LOC_CONF_OFFSET, | |
166 offsetof(ngx_http_scgi_loc_conf_t, upstream.intercept_errors), | |
167 NULL }, | |
168 | |
169 { ngx_string("scgi_read_timeout"), | |
170 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
171 ngx_conf_set_msec_slot, | |
172 NGX_HTTP_LOC_CONF_OFFSET, | |
173 offsetof(ngx_http_scgi_loc_conf_t, upstream.read_timeout), | |
174 NULL }, | |
175 | |
176 { ngx_string("scgi_buffers"), | |
177 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
178 ngx_conf_set_bufs_slot, | |
179 NGX_HTTP_LOC_CONF_OFFSET, | |
180 offsetof(ngx_http_scgi_loc_conf_t, upstream.bufs), | |
181 NULL }, | |
182 | |
183 { ngx_string("scgi_busy_buffers_size"), | |
184 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
185 ngx_conf_set_size_slot, | |
186 NGX_HTTP_LOC_CONF_OFFSET, | |
187 offsetof(ngx_http_scgi_loc_conf_t, upstream.busy_buffers_size_conf), | |
188 NULL }, | |
189 | |
5874
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
190 { ngx_string("scgi_force_ranges"), |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
191 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:
5832
diff
changeset
|
192 ngx_conf_set_flag_slot, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
193 NGX_HTTP_LOC_CONF_OFFSET, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
194 offsetof(ngx_http_scgi_loc_conf_t, upstream.force_ranges), |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
195 NULL }, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
196 |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
197 { ngx_string("scgi_limit_rate"), |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
198 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
|
199 ngx_conf_set_size_slot, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
200 NGX_HTTP_LOC_CONF_OFFSET, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
201 offsetof(ngx_http_scgi_loc_conf_t, upstream.limit_rate), |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
202 NULL }, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
203 |
3637 | 204 #if (NGX_HTTP_CACHE) |
205 | |
206 { ngx_string("scgi_cache"), | |
3729 | 207 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3637 | 208 ngx_http_scgi_cache, |
209 NGX_HTTP_LOC_CONF_OFFSET, | |
210 0, | |
211 NULL }, | |
212 | |
213 { ngx_string("scgi_cache_key"), | |
3729 | 214 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3637 | 215 ngx_http_scgi_cache_key, |
216 NGX_HTTP_LOC_CONF_OFFSET, | |
217 0, | |
218 NULL }, | |
219 | |
220 { ngx_string("scgi_cache_path"), | |
221 NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE, | |
222 ngx_http_file_cache_set_slot, | |
223 0, | |
224 0, | |
225 &ngx_http_scgi_module }, | |
226 | |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
227 { ngx_string("scgi_cache_bypass"), |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
228 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:
3693
diff
changeset
|
229 ngx_http_set_predicate_slot, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
230 NGX_HTTP_LOC_CONF_OFFSET, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
231 offsetof(ngx_http_scgi_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:
3693
diff
changeset
|
232 NULL }, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
233 |
3637 | 234 { ngx_string("scgi_no_cache"), |
235 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
|
236 ngx_http_set_predicate_slot, |
3637 | 237 NGX_HTTP_LOC_CONF_OFFSET, |
238 offsetof(ngx_http_scgi_loc_conf_t, upstream.no_cache), | |
239 NULL }, | |
240 | |
241 { ngx_string("scgi_cache_valid"), | |
242 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
243 ngx_http_file_cache_valid_set_slot, | |
244 NGX_HTTP_LOC_CONF_OFFSET, | |
245 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_valid), | |
246 NULL }, | |
247 | |
248 { ngx_string("scgi_cache_min_uses"), | |
249 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
250 ngx_conf_set_num_slot, | |
251 NGX_HTTP_LOC_CONF_OFFSET, | |
252 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_min_uses), | |
253 NULL }, | |
254 | |
255 { ngx_string("scgi_cache_use_stale"), | |
256 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
257 ngx_conf_set_bitmask_slot, | |
258 NGX_HTTP_LOC_CONF_OFFSET, | |
259 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_use_stale), | |
260 &ngx_http_scgi_next_upstream_masks }, | |
261 | |
262 { ngx_string("scgi_cache_methods"), | |
263 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
264 ngx_conf_set_bitmask_slot, | |
265 NGX_HTTP_LOC_CONF_OFFSET, | |
266 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_methods), | |
267 &ngx_http_upstream_cache_method_mask }, | |
268 | |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
269 { ngx_string("scgi_cache_lock"), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
270 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:
4373
diff
changeset
|
271 ngx_conf_set_flag_slot, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
272 NGX_HTTP_LOC_CONF_OFFSET, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
273 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
274 NULL }, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
275 |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
276 { ngx_string("scgi_cache_lock_timeout"), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
277 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:
4373
diff
changeset
|
278 ngx_conf_set_msec_slot, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
279 NGX_HTTP_LOC_CONF_OFFSET, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
280 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock_timeout), |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
281 NULL }, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
282 |
5905
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5883
diff
changeset
|
283 { ngx_string("scgi_cache_lock_age"), |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5883
diff
changeset
|
284 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
|
285 ngx_conf_set_msec_slot, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5883
diff
changeset
|
286 NGX_HTTP_LOC_CONF_OFFSET, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5883
diff
changeset
|
287 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_lock_age), |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5883
diff
changeset
|
288 NULL }, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5883
diff
changeset
|
289 |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
290 { ngx_string("scgi_cache_revalidate"), |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
291 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:
5393
diff
changeset
|
292 ngx_conf_set_flag_slot, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
293 NGX_HTTP_LOC_CONF_OFFSET, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
294 offsetof(ngx_http_scgi_loc_conf_t, upstream.cache_revalidate), |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
295 NULL }, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
296 |
3637 | 297 #endif |
298 | |
299 { ngx_string("scgi_temp_path"), | |
300 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | |
301 ngx_conf_set_path_slot, | |
302 NGX_HTTP_LOC_CONF_OFFSET, | |
303 offsetof(ngx_http_scgi_loc_conf_t, upstream.temp_path), | |
304 NULL }, | |
305 | |
306 { ngx_string("scgi_max_temp_file_size"), | |
307 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
308 ngx_conf_set_size_slot, | |
309 NGX_HTTP_LOC_CONF_OFFSET, | |
310 offsetof(ngx_http_scgi_loc_conf_t, upstream.max_temp_file_size_conf), | |
311 NULL }, | |
312 | |
313 { ngx_string("scgi_temp_file_write_size"), | |
314 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
315 ngx_conf_set_size_slot, | |
316 NGX_HTTP_LOC_CONF_OFFSET, | |
317 offsetof(ngx_http_scgi_loc_conf_t, upstream.temp_file_write_size_conf), | |
318 NULL }, | |
319 | |
320 { ngx_string("scgi_next_upstream"), | |
321 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
322 ngx_conf_set_bitmask_slot, | |
323 NGX_HTTP_LOC_CONF_OFFSET, | |
324 offsetof(ngx_http_scgi_loc_conf_t, upstream.next_upstream), | |
325 &ngx_http_scgi_next_upstream_masks }, | |
326 | |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
327 { ngx_string("scgi_next_upstream_tries"), |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
328 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
|
329 ngx_conf_set_num_slot, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
330 NGX_HTTP_LOC_CONF_OFFSET, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
331 offsetof(ngx_http_scgi_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
|
332 NULL }, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
333 |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
334 { ngx_string("scgi_next_upstream_timeout"), |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
335 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
|
336 ngx_conf_set_msec_slot, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
337 NGX_HTTP_LOC_CONF_OFFSET, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
338 offsetof(ngx_http_scgi_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
|
339 NULL }, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
340 |
3637 | 341 { ngx_string("scgi_param"), |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
342 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23, |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
343 ngx_http_upstream_param_set_slot, |
3637 | 344 NGX_HTTP_LOC_CONF_OFFSET, |
345 offsetof(ngx_http_scgi_loc_conf_t, params_source), | |
346 NULL }, | |
347 | |
348 { ngx_string("scgi_pass_header"), | |
3729 | 349 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3637 | 350 ngx_conf_set_str_array_slot, |
351 NGX_HTTP_LOC_CONF_OFFSET, | |
352 offsetof(ngx_http_scgi_loc_conf_t, upstream.pass_headers), | |
353 NULL }, | |
354 | |
355 { ngx_string("scgi_hide_header"), | |
3729 | 356 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3637 | 357 ngx_conf_set_str_array_slot, |
358 NGX_HTTP_LOC_CONF_OFFSET, | |
359 offsetof(ngx_http_scgi_loc_conf_t, upstream.hide_headers), | |
360 NULL }, | |
361 | |
362 { ngx_string("scgi_ignore_headers"), | |
363 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
364 ngx_conf_set_bitmask_slot, | |
365 NGX_HTTP_LOC_CONF_OFFSET, | |
366 offsetof(ngx_http_scgi_loc_conf_t, upstream.ignore_headers), | |
3667
12bd9e26fadb
use shared ngx_http_upstream_ignore_headers_masks[]
Igor Sysoev <igor@sysoev.ru>
parents:
3637
diff
changeset
|
367 &ngx_http_upstream_ignore_headers_masks }, |
3637 | 368 |
369 ngx_null_command | |
370 }; | |
371 | |
372 | |
373 static ngx_http_module_t ngx_http_scgi_module_ctx = { | |
374 NULL, /* preconfiguration */ | |
375 NULL, /* postconfiguration */ | |
376 | |
377 NULL, /* create main configuration */ | |
378 NULL, /* init main configuration */ | |
379 | |
380 NULL, /* create server configuration */ | |
381 NULL, /* merge server configuration */ | |
382 | |
383 ngx_http_scgi_create_loc_conf, /* create location configuration */ | |
384 ngx_http_scgi_merge_loc_conf /* merge location configuration */ | |
385 }; | |
386 | |
387 | |
388 ngx_module_t ngx_http_scgi_module = { | |
389 NGX_MODULE_V1, | |
390 &ngx_http_scgi_module_ctx, /* module context */ | |
391 ngx_http_scgi_commands, /* module directives */ | |
392 NGX_HTTP_MODULE, /* module type */ | |
393 NULL, /* init master */ | |
394 NULL, /* init module */ | |
395 NULL, /* init process */ | |
396 NULL, /* init thread */ | |
397 NULL, /* exit thread */ | |
398 NULL, /* exit process */ | |
399 NULL, /* exit master */ | |
400 NGX_MODULE_V1_PADDING | |
401 }; | |
402 | |
403 | |
404 static ngx_str_t ngx_http_scgi_hide_headers[] = { | |
405 ngx_string("Status"), | |
406 ngx_string("X-Accel-Expires"), | |
407 ngx_string("X-Accel-Redirect"), | |
408 ngx_string("X-Accel-Limit-Rate"), | |
409 ngx_string("X-Accel-Buffering"), | |
410 ngx_string("X-Accel-Charset"), | |
411 ngx_null_string | |
412 }; | |
413 | |
414 | |
415 #if (NGX_HTTP_CACHE) | |
416 | |
417 static ngx_keyval_t ngx_http_scgi_cache_headers[] = { | |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
418 { ngx_string("HTTP_IF_MODIFIED_SINCE"), |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
419 ngx_string("$upstream_cache_last_modified") }, |
3637 | 420 { ngx_string("HTTP_IF_UNMODIFIED_SINCE"), ngx_string("") }, |
5738
c95d7882dfc9
Upstream: cache revalidation using If-None-Match.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
421 { ngx_string("HTTP_IF_NONE_MATCH"), ngx_string("$upstream_cache_etag") }, |
3637 | 422 { ngx_string("HTTP_IF_MATCH"), ngx_string("") }, |
423 { ngx_string("HTTP_RANGE"), ngx_string("") }, | |
424 { ngx_string("HTTP_IF_RANGE"), ngx_string("") }, | |
425 { ngx_null_string, ngx_null_string } | |
426 }; | |
427 | |
428 #endif | |
429 | |
430 | |
431 static ngx_path_init_t ngx_http_scgi_temp_path = { | |
432 ngx_string(NGX_HTTP_SCGI_TEMP_PATH), { 1, 2, 0 } | |
433 }; | |
434 | |
435 | |
436 static ngx_int_t | |
437 ngx_http_scgi_handler(ngx_http_request_t *r) | |
438 { | |
439 ngx_int_t rc; | |
440 ngx_http_status_t *status; | |
441 ngx_http_upstream_t *u; | |
442 ngx_http_scgi_loc_conf_t *scf; | |
443 | |
444 if (ngx_http_upstream_create(r) != NGX_OK) { | |
445 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
446 } | |
447 | |
448 status = ngx_pcalloc(r->pool, sizeof(ngx_http_status_t)); | |
449 if (status == NULL) { | |
450 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
451 } | |
452 | |
453 ngx_http_set_ctx(r, status, ngx_http_scgi_module); | |
454 | |
455 scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module); | |
456 | |
457 if (scf->scgi_lengths) { | |
458 if (ngx_http_scgi_eval(r, scf) != NGX_OK) { | |
459 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
460 } | |
461 } | |
462 | |
463 u = r->upstream; | |
464 | |
465 ngx_str_set(&u->schema, "scgi://"); | |
466 u->output.tag = (ngx_buf_tag_t) &ngx_http_scgi_module; | |
467 | |
468 u->conf = &scf->upstream; | |
469 | |
470 #if (NGX_HTTP_CACHE) | |
471 u->create_key = ngx_http_scgi_create_key; | |
472 #endif | |
473 u->create_request = ngx_http_scgi_create_request; | |
474 u->reinit_request = ngx_http_scgi_reinit_request; | |
475 u->process_header = ngx_http_scgi_process_status_line; | |
476 u->abort_request = ngx_http_scgi_abort_request; | |
477 u->finalize_request = ngx_http_scgi_finalize_request; | |
4615
adcd60233817
Added r->state reset on fastcgi/scgi/uwsgi request start.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
478 r->state = 0; |
3637 | 479 |
4157
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
480 u->buffering = scf->upstream.buffering; |
3637 | 481 |
482 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); | |
483 if (u->pipe == NULL) { | |
484 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
485 } | |
486 | |
487 u->pipe->input_filter = ngx_event_pipe_copy_input_filter; | |
488 u->pipe->input_ctx = r; | |
489 | |
490 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init); | |
491 | |
492 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
493 return rc; | |
494 } | |
495 | |
496 return NGX_DONE; | |
497 } | |
498 | |
499 | |
500 static ngx_int_t | |
501 ngx_http_scgi_eval(ngx_http_request_t *r, ngx_http_scgi_loc_conf_t * scf) | |
502 { | |
503 ngx_url_t url; | |
504 ngx_http_upstream_t *u; | |
505 | |
506 ngx_memzero(&url, sizeof(ngx_url_t)); | |
507 | |
508 if (ngx_http_script_run(r, &url.url, scf->scgi_lengths->elts, 0, | |
509 scf->scgi_values->elts) | |
510 == NULL) | |
511 { | |
512 return NGX_ERROR; | |
513 } | |
514 | |
515 url.no_resolve = 1; | |
516 | |
517 if (ngx_parse_url(r->pool, &url) != NGX_OK) { | |
518 if (url.err) { | |
519 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
520 "%s in upstream \"%V\"", url.err, &url.url); | |
521 } | |
522 | |
523 return NGX_ERROR; | |
524 } | |
525 | |
526 u = r->upstream; | |
527 | |
528 u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t)); | |
529 if (u->resolved == NULL) { | |
530 return NGX_ERROR; | |
531 } | |
532 | |
533 if (url.addrs && url.addrs[0].sockaddr) { | |
534 u->resolved->sockaddr = url.addrs[0].sockaddr; | |
535 u->resolved->socklen = url.addrs[0].socklen; | |
536 u->resolved->naddrs = 1; | |
537 u->resolved->host = url.addrs[0].name; | |
538 | |
539 } else { | |
540 u->resolved->host = url.host; | |
541 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:
3731
diff
changeset
|
542 u->resolved->no_port = url.no_port; |
3637 | 543 } |
544 | |
545 return NGX_OK; | |
546 } | |
547 | |
548 | |
549 #if (NGX_HTTP_CACHE) | |
550 | |
551 static ngx_int_t | |
552 ngx_http_scgi_create_key(ngx_http_request_t *r) | |
553 { | |
554 ngx_str_t *key; | |
555 ngx_http_scgi_loc_conf_t *scf; | |
556 | |
557 key = ngx_array_push(&r->cache->keys); | |
558 if (key == NULL) { | |
559 return NGX_ERROR; | |
560 } | |
561 | |
562 scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module); | |
563 | |
564 if (ngx_http_complex_value(r, &scf->cache_key, key) != NGX_OK) { | |
565 return NGX_ERROR; | |
566 } | |
567 | |
568 return NGX_OK; | |
569 } | |
570 | |
571 #endif | |
572 | |
573 | |
574 static ngx_int_t | |
575 ngx_http_scgi_create_request(ngx_http_request_t *r) | |
576 { | |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
577 off_t content_length_n; |
3637 | 578 u_char ch, *key, *val, *lowcase_key; |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
579 size_t len, key_len, val_len, allocated; |
3637 | 580 ngx_buf_t *b; |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
581 ngx_str_t content_length; |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
582 ngx_uint_t i, n, hash, skip_empty, header_params; |
3637 | 583 ngx_chain_t *cl, *body; |
584 ngx_list_part_t *part; | |
585 ngx_table_elt_t *header, **ignored; | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
586 ngx_http_scgi_params_t *params; |
3637 | 587 ngx_http_script_code_pt code; |
588 ngx_http_script_engine_t e, le; | |
589 ngx_http_scgi_loc_conf_t *scf; | |
590 ngx_http_script_len_code_pt lcode; | |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
591 u_char buffer[NGX_OFF_T_LEN]; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
592 |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
593 content_length_n = 0; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
594 body = r->upstream->request_bufs; |
3637 | 595 |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
596 while (body) { |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
597 content_length_n += ngx_buf_size(body->buf); |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
598 body = body->next; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
599 } |
3637 | 600 |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
601 content_length.data = buffer; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
602 content_length.len = ngx_sprintf(buffer, "%O", content_length_n) - buffer; |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
603 |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
604 len = sizeof("CONTENT_LENGTH") + content_length.len + 1; |
3637 | 605 |
606 header_params = 0; | |
607 ignored = NULL; | |
608 | |
609 scf = ngx_http_get_module_loc_conf(r, ngx_http_scgi_module); | |
610 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
611 params = &scf->params; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
612 |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
613 if (params->lengths) { |
3637 | 614 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); |
615 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
616 ngx_http_script_flush_no_cacheable_variables(r, params->flushes); |
3637 | 617 le.flushed = 1; |
618 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
619 le.ip = params->lengths->elts; |
3637 | 620 le.request = r; |
621 | |
622 while (*(uintptr_t *) le.ip) { | |
623 | |
624 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
625 key_len = lcode(&le); |
3637 | 626 |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
627 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
628 skip_empty = lcode(&le); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
629 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
630 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
3637 | 631 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
632 } | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
633 le.ip += sizeof(uintptr_t); |
4294
56cb2255735a
Fixed incorrect counting the length of headers in a SCGI request.
Valentin Bartenev <vbart@nginx.com>
parents:
4278
diff
changeset
|
634 |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
635 if (skip_empty && val_len == 0) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
636 continue; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
637 } |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
638 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
639 len += key_len + val_len + 1; |
3637 | 640 } |
641 } | |
642 | |
643 if (scf->upstream.pass_request_headers) { | |
644 | |
645 allocated = 0; | |
646 lowcase_key = NULL; | |
647 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
648 if (params->number) { |
4015
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
649 n = 0; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
650 part = &r->headers_in.headers.part; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
651 |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
652 while (part) { |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
653 n += part->nelts; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
654 part = part->next; |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
655 } |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
656 |
e0a435f5f504
Fix ignored headers handling in fastcgi/scgi/uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3976
diff
changeset
|
657 ignored = ngx_palloc(r->pool, n * sizeof(void *)); |
3637 | 658 if (ignored == NULL) { |
659 return NGX_ERROR; | |
660 } | |
661 } | |
662 | |
663 part = &r->headers_in.headers.part; | |
664 header = part->elts; | |
665 | |
666 for (i = 0; /* void */; i++) { | |
667 | |
668 if (i >= part->nelts) { | |
669 if (part->next == NULL) { | |
670 break; | |
671 } | |
672 | |
673 part = part->next; | |
674 header = part->elts; | |
675 i = 0; | |
676 } | |
677 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
678 if (params->number) { |
3637 | 679 if (allocated < header[i].key.len) { |
680 allocated = header[i].key.len + 16; | |
681 lowcase_key = ngx_pnalloc(r->pool, allocated); | |
682 if (lowcase_key == NULL) { | |
683 return NGX_ERROR; | |
684 } | |
685 } | |
686 | |
687 hash = 0; | |
688 | |
689 for (n = 0; n < header[i].key.len; n++) { | |
690 ch = header[i].key.data[n]; | |
691 | |
692 if (ch >= 'A' && ch <= 'Z') { | |
693 ch |= 0x20; | |
694 | |
695 } else if (ch == '-') { | |
696 ch = '_'; | |
697 } | |
698 | |
699 hash = ngx_hash(hash, ch); | |
700 lowcase_key[n] = ch; | |
701 } | |
702 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
703 if (ngx_hash_find(¶ms->hash, hash, lowcase_key, n)) { |
3637 | 704 ignored[header_params++] = &header[i]; |
705 continue; | |
706 } | |
707 } | |
708 | |
709 len += sizeof("HTTP_") - 1 + header[i].key.len + 1 | |
710 + header[i].value.len + 1; | |
711 } | |
712 } | |
713 | |
714 /* netstring: "length:" + packet + "," */ | |
715 | |
716 b = ngx_create_temp_buf(r->pool, NGX_SIZE_T_LEN + 1 + len + 1); | |
717 if (b == NULL) { | |
718 return NGX_ERROR; | |
719 } | |
720 | |
721 cl = ngx_alloc_chain_link(r->pool); | |
722 if (cl == NULL) { | |
723 return NGX_ERROR; | |
724 } | |
725 | |
726 cl->buf = b; | |
727 | |
4929
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
728 b->last = ngx_sprintf(b->last, "%ui:CONTENT_LENGTH%Z%V%Z", |
5a44d638cd27
Request body: recalculate size of a request body in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4615
diff
changeset
|
729 len, &content_length); |
3637 | 730 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
731 if (params->lengths) { |
3637 | 732 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); |
733 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
734 e.ip = params->values->elts; |
3637 | 735 e.pos = b->last; |
736 e.request = r; | |
737 e.flushed = 1; | |
738 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
739 le.ip = params->lengths->elts; |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
740 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
741 while (*(uintptr_t *) le.ip) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
742 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
743 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
744 lcode(&le); /* key length */ |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
745 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
746 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
747 skip_empty = lcode(&le); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
748 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
749 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
750 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
751 } |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
752 le.ip += sizeof(uintptr_t); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
753 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
754 if (skip_empty && val_len == 0) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
755 e.skip = 1; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
756 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
757 while (*(uintptr_t *) e.ip) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
758 code = *(ngx_http_script_code_pt *) e.ip; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
759 code((ngx_http_script_engine_t *) &e); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
760 } |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
761 e.ip += sizeof(uintptr_t); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
762 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
763 e.skip = 0; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
764 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
765 continue; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
766 } |
3637 | 767 |
768 #if (NGX_DEBUG) | |
769 key = e.pos; | |
770 #endif | |
771 code = *(ngx_http_script_code_pt *) e.ip; | |
772 code((ngx_http_script_engine_t *) & e); | |
773 | |
774 #if (NGX_DEBUG) | |
775 val = e.pos; | |
776 #endif | |
777 while (*(uintptr_t *) e.ip) { | |
778 code = *(ngx_http_script_code_pt *) e.ip; | |
779 code((ngx_http_script_engine_t *) &e); | |
780 } | |
781 *e.pos++ = '\0'; | |
782 e.ip += sizeof(uintptr_t); | |
783 | |
784 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
785 "scgi param: \"%s: %s\"", key, val); | |
786 } | |
787 | |
788 b->last = e.pos; | |
789 } | |
790 | |
791 if (scf->upstream.pass_request_headers) { | |
792 | |
793 part = &r->headers_in.headers.part; | |
794 header = part->elts; | |
795 | |
796 for (i = 0; /* void */; i++) { | |
797 | |
798 if (i >= part->nelts) { | |
799 if (part->next == NULL) { | |
800 break; | |
801 } | |
802 | |
803 part = part->next; | |
804 header = part->elts; | |
805 i = 0; | |
806 } | |
807 | |
808 for (n = 0; n < header_params; n++) { | |
809 if (&header[i] == ignored[n]) { | |
810 goto next; | |
811 } | |
812 } | |
813 | |
814 key = b->last; | |
815 b->last = ngx_cpymem(key, "HTTP_", sizeof("HTTP_") - 1); | |
816 | |
817 for (n = 0; n < header[i].key.len; n++) { | |
818 ch = header[i].key.data[n]; | |
819 | |
820 if (ch >= 'a' && ch <= 'z') { | |
821 ch &= ~0x20; | |
822 | |
823 } else if (ch == '-') { | |
824 ch = '_'; | |
825 } | |
826 | |
827 *b->last++ = ch; | |
828 } | |
829 | |
830 *b->last++ = (u_char) 0; | |
831 | |
832 val = b->last; | |
833 b->last = ngx_copy(val, header[i].value.data, header[i].value.len); | |
834 *b->last++ = (u_char) 0; | |
835 | |
836 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
837 "scgi param: \"%s: %s\"", key, val); | |
838 | |
839 next: | |
840 | |
841 continue; | |
842 } | |
843 } | |
844 | |
845 *b->last++ = (u_char) ','; | |
846 | |
847 if (scf->upstream.pass_request_body) { | |
848 body = r->upstream->request_bufs; | |
849 r->upstream->request_bufs = cl; | |
850 | |
851 while (body) { | |
852 b = ngx_alloc_buf(r->pool); | |
853 if (b == NULL) { | |
854 return NGX_ERROR; | |
855 } | |
856 | |
857 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); | |
858 | |
859 cl->next = ngx_alloc_chain_link(r->pool); | |
860 if (cl->next == NULL) { | |
861 return NGX_ERROR; | |
862 } | |
863 | |
864 cl = cl->next; | |
865 cl->buf = b; | |
866 | |
867 body = body->next; | |
868 } | |
869 | |
870 } else { | |
871 r->upstream->request_bufs = cl; | |
872 } | |
873 | |
874 cl->next = NULL; | |
875 | |
876 return NGX_OK; | |
877 } | |
878 | |
879 | |
880 static ngx_int_t | |
881 ngx_http_scgi_reinit_request(ngx_http_request_t *r) | |
882 { | |
883 ngx_http_status_t *status; | |
884 | |
885 status = ngx_http_get_module_ctx(r, ngx_http_scgi_module); | |
886 | |
887 if (status == NULL) { | |
888 return NGX_OK; | |
889 } | |
890 | |
891 status->code = 0; | |
892 status->count = 0; | |
893 status->start = NULL; | |
894 status->end = NULL; | |
895 | |
896 r->upstream->process_header = ngx_http_scgi_process_status_line; | |
4615
adcd60233817
Added r->state reset on fastcgi/scgi/uwsgi request start.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
897 r->state = 0; |
3637 | 898 |
899 return NGX_OK; | |
900 } | |
901 | |
902 | |
903 static ngx_int_t | |
904 ngx_http_scgi_process_status_line(ngx_http_request_t *r) | |
905 { | |
906 size_t len; | |
907 ngx_int_t rc; | |
908 ngx_http_status_t *status; | |
909 ngx_http_upstream_t *u; | |
910 | |
911 status = ngx_http_get_module_ctx(r, ngx_http_scgi_module); | |
912 | |
913 if (status == NULL) { | |
914 return NGX_ERROR; | |
915 } | |
916 | |
917 u = r->upstream; | |
918 | |
919 rc = ngx_http_parse_status_line(r, &u->buffer, status); | |
920 | |
921 if (rc == NGX_AGAIN) { | |
922 return rc; | |
923 } | |
924 | |
925 if (rc == NGX_ERROR) { | |
926 u->process_header = ngx_http_scgi_process_header; | |
927 return ngx_http_scgi_process_header(r); | |
928 } | |
929 | |
5575
d15822784cf9
Upstream: fix $upstream_status variable.
Piotr Sikora <piotr@cloudflare.com>
parents:
5496
diff
changeset
|
930 if (u->state && u->state->status == 0) { |
3637 | 931 u->state->status = status->code; |
932 } | |
933 | |
934 u->headers_in.status_n = status->code; | |
935 | |
936 len = status->end - status->start; | |
937 u->headers_in.status_line.len = len; | |
938 | |
939 u->headers_in.status_line.data = ngx_pnalloc(r->pool, len); | |
940 if (u->headers_in.status_line.data == NULL) { | |
941 return NGX_ERROR; | |
942 } | |
943 | |
944 ngx_memcpy(u->headers_in.status_line.data, status->start, len); | |
945 | |
946 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
947 "http scgi status %ui \"%V\"", | |
948 u->headers_in.status_n, &u->headers_in.status_line); | |
949 | |
950 u->process_header = ngx_http_scgi_process_header; | |
951 | |
952 return ngx_http_scgi_process_header(r); | |
953 } | |
954 | |
955 | |
956 static ngx_int_t | |
957 ngx_http_scgi_process_header(ngx_http_request_t *r) | |
958 { | |
959 ngx_str_t *status_line; | |
960 ngx_int_t rc, status; | |
961 ngx_table_elt_t *h; | |
962 ngx_http_upstream_t *u; | |
963 ngx_http_upstream_header_t *hh; | |
964 ngx_http_upstream_main_conf_t *umcf; | |
965 | |
966 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); | |
967 | |
968 for ( ;; ) { | |
969 | |
970 rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1); | |
971 | |
972 if (rc == NGX_OK) { | |
973 | |
974 /* a header line has been parsed successfully */ | |
975 | |
976 h = ngx_list_push(&r->upstream->headers_in.headers); | |
977 if (h == NULL) { | |
978 return NGX_ERROR; | |
979 } | |
980 | |
981 h->hash = r->header_hash; | |
982 | |
983 h->key.len = r->header_name_end - r->header_name_start; | |
984 h->value.len = r->header_end - r->header_start; | |
985 | |
986 h->key.data = ngx_pnalloc(r->pool, | |
987 h->key.len + 1 + h->value.len + 1 | |
988 + h->key.len); | |
989 if (h->key.data == NULL) { | |
990 return NGX_ERROR; | |
991 } | |
992 | |
993 h->value.data = h->key.data + h->key.len + 1; | |
994 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; | |
995 | |
4529
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4522
diff
changeset
|
996 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
|
997 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
|
998 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
|
999 h->value.data[h->value.len] = '\0'; |
3637 | 1000 |
1001 if (h->key.len == r->lowcase_index) { | |
1002 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1003 | |
1004 } else { | |
1005 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); | |
1006 } | |
1007 | |
1008 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, | |
1009 h->lowcase_key, h->key.len); | |
1010 | |
1011 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | |
1012 return NGX_ERROR; | |
1013 } | |
1014 | |
1015 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1016 "http scgi header: \"%V: %V\"", &h->key, &h->value); | |
1017 | |
1018 continue; | |
1019 } | |
1020 | |
1021 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
1022 | |
1023 /* a whole header has been parsed successfully */ | |
1024 | |
1025 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1026 "http scgi header done"); | |
1027 | |
4371
16ebad9447ee
Fixed incorrect use of r->http_version in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4331
diff
changeset
|
1028 u = r->upstream; |
16ebad9447ee
Fixed incorrect use of r->http_version in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4331
diff
changeset
|
1029 |
16ebad9447ee
Fixed incorrect use of r->http_version in scgi module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4331
diff
changeset
|
1030 if (u->headers_in.status_n) { |
5078
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1031 goto done; |
3637 | 1032 } |
1033 | |
1034 if (u->headers_in.status) { | |
1035 status_line = &u->headers_in.status->value; | |
1036 | |
1037 status = ngx_atoi(status_line->data, 3); | |
1038 if (status == NGX_ERROR) { | |
1039 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1040 "upstream sent invalid status \"%V\"", | |
1041 status_line); | |
1042 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1043 } | |
1044 | |
1045 u->headers_in.status_n = status; | |
1046 u->headers_in.status_line = *status_line; | |
1047 | |
1048 } else if (u->headers_in.location) { | |
1049 u->headers_in.status_n = 302; | |
1050 ngx_str_set(&u->headers_in.status_line, | |
1051 "302 Moved Temporarily"); | |
1052 | |
1053 } else { | |
1054 u->headers_in.status_n = 200; | |
1055 ngx_str_set(&u->headers_in.status_line, "200 OK"); | |
1056 } | |
1057 | |
5575
d15822784cf9
Upstream: fix $upstream_status variable.
Piotr Sikora <piotr@cloudflare.com>
parents:
5496
diff
changeset
|
1058 if (u->state && u->state->status == 0) { |
3637 | 1059 u->state->status = u->headers_in.status_n; |
1060 } | |
1061 | |
5078
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1062 done: |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1063 |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1064 if (u->headers_in.status_n == NGX_HTTP_SWITCHING_PROTOCOLS |
5080
8da37c1b22a4
Trailing whitespace fix.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5078
diff
changeset
|
1065 && r->headers_in.upgrade) |
5078
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1066 { |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1067 u->upgrade = 1; |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1068 } |
10c74d3b15d1
Connection upgrade support in uwsgi and scgi modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
1069 |
3637 | 1070 return NGX_OK; |
1071 } | |
1072 | |
1073 if (rc == NGX_AGAIN) { | |
1074 return NGX_AGAIN; | |
1075 } | |
1076 | |
1077 /* there was error while a header line parsing */ | |
1078 | |
1079 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1080 "upstream sent invalid header"); | |
1081 | |
1082 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1083 } | |
1084 } | |
1085 | |
1086 | |
1087 static void | |
1088 ngx_http_scgi_abort_request(ngx_http_request_t *r) | |
1089 { | |
1090 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1091 "abort http scgi request"); | |
1092 | |
1093 return; | |
1094 } | |
1095 | |
1096 | |
1097 static void | |
1098 ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
1099 { | |
1100 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1101 "finalize http scgi request"); | |
1102 | |
1103 return; | |
1104 } | |
1105 | |
1106 | |
1107 static void * | |
1108 ngx_http_scgi_create_loc_conf(ngx_conf_t *cf) | |
1109 { | |
1110 ngx_http_scgi_loc_conf_t *conf; | |
1111 | |
1112 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_scgi_loc_conf_t)); | |
1113 if (conf == NULL) { | |
1114 return NULL; | |
1115 } | |
1116 | |
1117 conf->upstream.store = NGX_CONF_UNSET; | |
1118 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
|
1119 conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT; |
3637 | 1120 conf->upstream.buffering = NGX_CONF_UNSET; |
1121 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; | |
5874
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
1122 conf->upstream.force_ranges = NGX_CONF_UNSET; |
3637 | 1123 |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4947
diff
changeset
|
1124 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
|
1125 |
3637 | 1126 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
1127 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
1128 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
|
1129 conf->upstream.next_upstream_timeout = NGX_CONF_UNSET_MSEC; |
3637 | 1130 |
1131 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; | |
1132 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
|
1133 conf->upstream.limit_rate = NGX_CONF_UNSET_SIZE; |
3637 | 1134 |
1135 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
1136 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; | |
1137 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; | |
1138 | |
1139 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
1140 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
1141 | |
1142 #if (NGX_HTTP_CACHE) | |
1143 conf->upstream.cache = NGX_CONF_UNSET_PTR; | |
1144 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:
3693
diff
changeset
|
1145 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; |
3693
e3bcc2f4c418
fix scgi_no_cache and uwsgi_no_cache initialization
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
1146 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; |
3637 | 1147 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1148 conf->upstream.cache_lock = NGX_CONF_UNSET; |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1149 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
|
1150 conf->upstream.cache_lock_age = NGX_CONF_UNSET_MSEC; |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
1151 conf->upstream.cache_revalidate = NGX_CONF_UNSET; |
3637 | 1152 #endif |
1153 | |
1154 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; | |
1155 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR; | |
1156 | |
1157 conf->upstream.intercept_errors = NGX_CONF_UNSET; | |
1158 | |
1159 /* "scgi_cyclic_temp_file" is disabled */ | |
1160 conf->upstream.cyclic_temp_file = 0; | |
1161 | |
4157
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1162 conf->upstream.change_buffering = 1; |
9d59a8eda373
Added uwsgi_buffering and scgi_buffering directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4015
diff
changeset
|
1163 |
3976
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3879
diff
changeset
|
1164 ngx_str_set(&conf->upstream.module, "scgi"); |
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3879
diff
changeset
|
1165 |
3637 | 1166 return conf; |
1167 } | |
1168 | |
1169 | |
1170 static char * | |
1171 ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
1172 { | |
1173 ngx_http_scgi_loc_conf_t *prev = parent; | |
1174 ngx_http_scgi_loc_conf_t *conf = child; | |
1175 | |
1176 size_t size; | |
1177 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
|
1178 ngx_http_core_loc_conf_t *clcf; |
3637 | 1179 |
1180 if (conf->upstream.store != 0) { | |
1181 ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0); | |
1182 | |
1183 if (conf->upstream.store_lengths == NULL) { | |
1184 conf->upstream.store_lengths = prev->upstream.store_lengths; | |
1185 conf->upstream.store_values = prev->upstream.store_values; | |
1186 } | |
1187 } | |
1188 | |
1189 ngx_conf_merge_uint_value(conf->upstream.store_access, | |
1190 prev->upstream.store_access, 0600); | |
1191 | |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
1192 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
|
1193 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
|
1194 |
3637 | 1195 ngx_conf_merge_value(conf->upstream.buffering, |
1196 prev->upstream.buffering, 1); | |
1197 | |
1198 ngx_conf_merge_value(conf->upstream.ignore_client_abort, | |
1199 prev->upstream.ignore_client_abort, 0); | |
1200 | |
5874
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
1201 ngx_conf_merge_value(conf->upstream.force_ranges, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
1202 prev->upstream.force_ranges, 0); |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
1203 |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4947
diff
changeset
|
1204 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
|
1205 prev->upstream.local, NULL); |
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4947
diff
changeset
|
1206 |
3637 | 1207 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
1208 prev->upstream.connect_timeout, 60000); | |
1209 | |
1210 ngx_conf_merge_msec_value(conf->upstream.send_timeout, | |
1211 prev->upstream.send_timeout, 60000); | |
1212 | |
1213 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
1214 prev->upstream.read_timeout, 60000); | |
1215 | |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5829
diff
changeset
|
1216 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
|
1217 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
|
1218 |
3637 | 1219 ngx_conf_merge_size_value(conf->upstream.send_lowat, |
1220 prev->upstream.send_lowat, 0); | |
1221 | |
1222 ngx_conf_merge_size_value(conf->upstream.buffer_size, | |
1223 prev->upstream.buffer_size, | |
1224 (size_t) ngx_pagesize); | |
1225 | |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
1226 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
|
1227 prev->upstream.limit_rate, 0); |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
1228 |
3637 | 1229 |
1230 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, | |
1231 8, ngx_pagesize); | |
1232 | |
1233 if (conf->upstream.bufs.num < 2) { | |
1234 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1235 "there must be at least 2 \"scgi_buffers\""); | |
1236 return NGX_CONF_ERROR; | |
1237 } | |
1238 | |
1239 | |
1240 size = conf->upstream.buffer_size; | |
1241 if (size < conf->upstream.bufs.size) { | |
1242 size = conf->upstream.bufs.size; | |
1243 } | |
1244 | |
1245 | |
1246 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, | |
1247 prev->upstream.busy_buffers_size_conf, | |
1248 NGX_CONF_UNSET_SIZE); | |
1249 | |
1250 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { | |
1251 conf->upstream.busy_buffers_size = 2 * size; | |
1252 } else { | |
1253 conf->upstream.busy_buffers_size = | |
1254 conf->upstream.busy_buffers_size_conf; | |
1255 } | |
1256 | |
1257 if (conf->upstream.busy_buffers_size < size) { | |
1258 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
|
1259 "\"scgi_busy_buffers_size\" must be equal to or greater " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
1260 "than the maximum of the value of \"scgi_buffer_size\" and " |
3637 | 1261 "one of the \"scgi_buffers\""); |
1262 | |
1263 return NGX_CONF_ERROR; | |
1264 } | |
1265 | |
1266 if (conf->upstream.busy_buffers_size | |
1267 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
1268 { | |
1269 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1270 "\"scgi_busy_buffers_size\" must be less than " | |
1271 "the size of all \"scgi_buffers\" minus one buffer"); | |
1272 | |
1273 return NGX_CONF_ERROR; | |
1274 } | |
1275 | |
1276 | |
1277 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, | |
1278 prev->upstream.temp_file_write_size_conf, | |
1279 NGX_CONF_UNSET_SIZE); | |
1280 | |
1281 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { | |
1282 conf->upstream.temp_file_write_size = 2 * size; | |
1283 } else { | |
1284 conf->upstream.temp_file_write_size = | |
1285 conf->upstream.temp_file_write_size_conf; | |
1286 } | |
1287 | |
1288 if (conf->upstream.temp_file_write_size < size) { | |
1289 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
|
1290 "\"scgi_temp_file_write_size\" must be equal to or greater than " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
1291 "the maximum of the value of \"scgi_buffer_size\" and " |
3637 | 1292 "one of the \"scgi_buffers\""); |
1293 | |
1294 return NGX_CONF_ERROR; | |
1295 } | |
1296 | |
1297 | |
1298 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, | |
1299 prev->upstream.max_temp_file_size_conf, | |
1300 NGX_CONF_UNSET_SIZE); | |
1301 | |
1302 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { | |
1303 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; | |
1304 } else { | |
1305 conf->upstream.max_temp_file_size = | |
1306 conf->upstream.max_temp_file_size_conf; | |
1307 } | |
1308 | |
1309 if (conf->upstream.max_temp_file_size != 0 | |
5828 | 1310 && conf->upstream.max_temp_file_size < size) |
1311 { | |
3637 | 1312 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1313 "\"scgi_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
|
1314 "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
|
1315 "the maximum of the value of \"scgi_buffer_size\" and " |
3637 | 1316 "one of the \"scgi_buffers\""); |
1317 | |
1318 return NGX_CONF_ERROR; | |
1319 } | |
1320 | |
1321 | |
1322 ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers, | |
1323 prev->upstream.ignore_headers, | |
1324 NGX_CONF_BITMASK_SET); | |
1325 | |
1326 | |
1327 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, | |
1328 prev->upstream.next_upstream, | |
1329 (NGX_CONF_BITMASK_SET | |
1330 |NGX_HTTP_UPSTREAM_FT_ERROR | |
1331 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
1332 | |
1333 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { | |
1334 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
1335 |NGX_HTTP_UPSTREAM_FT_OFF; | |
1336 } | |
1337 | |
1338 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path, | |
1339 prev->upstream.temp_path, | |
1340 &ngx_http_scgi_temp_path) | |
1341 != NGX_OK) | |
1342 { | |
1343 return NGX_CONF_ERROR; | |
1344 } | |
1345 | |
1346 #if (NGX_HTTP_CACHE) | |
1347 | |
1348 ngx_conf_merge_ptr_value(conf->upstream.cache, | |
1349 prev->upstream.cache, NULL); | |
1350 | |
1351 if (conf->upstream.cache && conf->upstream.cache->data == NULL) { | |
1352 ngx_shm_zone_t *shm_zone; | |
1353 | |
1354 shm_zone = conf->upstream.cache; | |
1355 | |
1356 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1357 "\"scgi_cache\" zone \"%V\" is unknown", | |
1358 &shm_zone->shm.name); | |
1359 | |
1360 return NGX_CONF_ERROR; | |
1361 } | |
1362 | |
1363 ngx_conf_merge_uint_value(conf->upstream.cache_min_uses, | |
1364 prev->upstream.cache_min_uses, 1); | |
1365 | |
1366 ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale, | |
1367 prev->upstream.cache_use_stale, | |
1368 (NGX_CONF_BITMASK_SET | |
1369 |NGX_HTTP_UPSTREAM_FT_OFF)); | |
1370 | |
1371 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) { | |
1372 conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET | |
1373 |NGX_HTTP_UPSTREAM_FT_OFF; | |
1374 } | |
1375 | |
4401
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
1376 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
|
1377 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
|
1378 } |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4386
diff
changeset
|
1379 |
3637 | 1380 if (conf->upstream.cache_methods == 0) { |
1381 conf->upstream.cache_methods = prev->upstream.cache_methods; | |
1382 } | |
1383 | |
1384 conf->upstream.cache_methods |= NGX_HTTP_GET|NGX_HTTP_HEAD; | |
1385 | |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
1386 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:
3693
diff
changeset
|
1387 prev->upstream.cache_bypass, NULL); |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3693
diff
changeset
|
1388 |
3637 | 1389 ngx_conf_merge_ptr_value(conf->upstream.no_cache, |
1390 prev->upstream.no_cache, NULL); | |
1391 | |
1392 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, | |
1393 prev->upstream.cache_valid, NULL); | |
1394 | |
1395 if (conf->cache_key.value.data == NULL) { | |
1396 conf->cache_key = prev->cache_key; | |
1397 } | |
1398 | |
5829
906530c9ffd2
Added warning about unset cache keys.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5828
diff
changeset
|
1399 if (conf->upstream.cache && conf->cache_key.value.data == NULL) { |
906530c9ffd2
Added warning about unset cache keys.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5828
diff
changeset
|
1400 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
906530c9ffd2
Added warning about unset cache keys.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5828
diff
changeset
|
1401 "no \"scgi_cache_key\" for \"scgi_cache\""); |
906530c9ffd2
Added warning about unset cache keys.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5828
diff
changeset
|
1402 } |
906530c9ffd2
Added warning about unset cache keys.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5828
diff
changeset
|
1403 |
4386
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1404 ngx_conf_merge_value(conf->upstream.cache_lock, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1405 prev->upstream.cache_lock, 0); |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1406 |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1407 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1408 prev->upstream.cache_lock_timeout, 5000); |
92deb73393f7
Cache lock support for fastcgi, scgi, uwsgi.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4373
diff
changeset
|
1409 |
5905
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5883
diff
changeset
|
1410 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
|
1411 prev->upstream.cache_lock_age, 5000); |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5883
diff
changeset
|
1412 |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
1413 ngx_conf_merge_value(conf->upstream.cache_revalidate, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
1414 prev->upstream.cache_revalidate, 0); |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5393
diff
changeset
|
1415 |
3637 | 1416 #endif |
1417 | |
1418 ngx_conf_merge_value(conf->upstream.pass_request_headers, | |
1419 prev->upstream.pass_request_headers, 1); | |
1420 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
1421 prev->upstream.pass_request_body, 1); | |
1422 | |
1423 ngx_conf_merge_value(conf->upstream.intercept_errors, | |
1424 prev->upstream.intercept_errors, 0); | |
1425 | |
1426 hash.max_size = 512; | |
1427 hash.bucket_size = ngx_align(64, ngx_cacheline_size); | |
1428 hash.name = "scgi_hide_headers_hash"; | |
1429 | |
1430 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:
3668
diff
changeset
|
1431 &prev->upstream, ngx_http_scgi_hide_headers, &hash) |
3637 | 1432 != NGX_OK) |
1433 { | |
1434 return NGX_CONF_ERROR; | |
1435 } | |
1436 | |
1437 if (conf->upstream.upstream == NULL) { | |
1438 conf->upstream.upstream = prev->upstream.upstream; | |
1439 } | |
1440 | |
1441 if (conf->scgi_lengths == NULL) { | |
1442 conf->scgi_lengths = prev->scgi_lengths; | |
1443 conf->scgi_values = prev->scgi_values; | |
1444 } | |
1445 | |
3731
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1446 if (conf->upstream.upstream || conf->scgi_lengths) { |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1447 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1448 if (clcf->handler == NULL && clcf->lmt_excpt) { |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1449 clcf->handler = ngx_http_scgi_handler; |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1450 } |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1451 } |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
1452 |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1453 if (conf->params_source == NULL) { |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1454 conf->params_source = prev->params_source; |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1455 |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1456 #if (NGX_HTTP_CACHE) |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1457 if ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1458 #endif |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1459 { |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1460 conf->params = prev->params; |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1461 } |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1462 } |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1463 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1464 if (ngx_http_scgi_init_params(cf, conf, &conf->params) != NGX_OK) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1465 return NGX_CONF_ERROR; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1466 } |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1467 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1468 return NGX_CONF_OK; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1469 } |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1470 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1471 |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1472 static ngx_int_t |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1473 ngx_http_scgi_init_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf, |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1474 ngx_http_scgi_params_t *params) |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1475 { |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1476 u_char *p; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1477 size_t size; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1478 uintptr_t *code; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1479 ngx_uint_t i, nsrc; |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1480 ngx_array_t headers_names; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1481 #if (NGX_HTTP_CACHE) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1482 ngx_array_t params_merged; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1483 #endif |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1484 ngx_hash_key_t *hk; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1485 ngx_hash_init_t hash; |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1486 ngx_http_upstream_param_t *src; |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1487 ngx_http_script_compile_t sc; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1488 ngx_http_script_copy_code_t *copy; |
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1489 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1490 if (params->hash.buckets) { |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5906
diff
changeset
|
1491 return NGX_OK; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1492 } |
3637 | 1493 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1494 if (conf->params_source == NULL |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1495 #if (NGX_HTTP_CACHE) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1496 && (conf->upstream.cache == NULL) |
3637 | 1497 #endif |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1498 ) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1499 { |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1500 params->hash.buckets = (void *) 1; |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1501 return NGX_OK; |
3637 | 1502 } |
1503 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1504 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
|
1505 if (params->lengths == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1506 return NGX_ERROR; |
3637 | 1507 } |
1508 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1509 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
|
1510 if (params->values == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1511 return NGX_ERROR; |
3637 | 1512 } |
1513 | |
1514 if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t)) | |
1515 != NGX_OK) | |
1516 { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1517 return NGX_ERROR; |
3637 | 1518 } |
1519 | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1520 if (conf->params_source) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1521 src = conf->params_source->elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1522 nsrc = conf->params_source->nelts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1523 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1524 } else { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1525 src = NULL; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1526 nsrc = 0; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1527 } |
3637 | 1528 |
1529 #if (NGX_HTTP_CACHE) | |
1530 | |
1531 if (conf->upstream.cache) { | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1532 ngx_keyval_t *h; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1533 ngx_http_upstream_param_t *s; |
3637 | 1534 |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1535 if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1536 sizeof(ngx_http_upstream_param_t)) |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1537 != NGX_OK) |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1538 { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1539 return NGX_ERROR; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1540 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1541 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1542 for (i = 0; i < nsrc; i++) { |
3637 | 1543 |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1544 s = ngx_array_push(¶ms_merged); |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1545 if (s == NULL) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1546 return NGX_ERROR; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1547 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1548 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1549 *s = src[i]; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1550 } |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1551 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1552 h = ngx_http_scgi_cache_headers; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1553 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1554 while (h->key.len) { |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1555 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1556 src = params_merged.elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1557 nsrc = params_merged.nelts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1558 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1559 for (i = 0; i < nsrc; i++) { |
3637 | 1560 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { |
1561 goto next; | |
1562 } | |
1563 } | |
1564 | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1565 s = ngx_array_push(¶ms_merged); |
3637 | 1566 if (s == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1567 return NGX_ERROR; |
3637 | 1568 } |
1569 | |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1570 s->key = h->key; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1571 s->value = h->value; |
5451
e68af4e3396f
Upstream: skip empty cache headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5441
diff
changeset
|
1572 s->skip_empty = 1; |
3637 | 1573 |
1574 next: | |
1575 | |
1576 h++; | |
1577 } | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1578 |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1579 src = params_merged.elts; |
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1580 nsrc = params_merged.nelts; |
3637 | 1581 } |
1582 | |
1583 #endif | |
1584 | |
4278
f57229cba7ad
Fixed fastcgi/scgi/uwsgi_param inheritance.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4277
diff
changeset
|
1585 for (i = 0; i < nsrc; i++) { |
3637 | 1586 |
1587 if (src[i].key.len > sizeof("HTTP_") - 1 | |
1588 && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0) | |
1589 { | |
1590 hk = ngx_array_push(&headers_names); | |
1591 if (hk == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1592 return NGX_ERROR; |
3637 | 1593 } |
1594 | |
1595 hk->key.len = src[i].key.len - 5; | |
1596 hk->key.data = src[i].key.data + 5; | |
1597 hk->key_hash = ngx_hash_key_lc(hk->key.data, hk->key.len); | |
1598 hk->value = (void *) 1; | |
1599 | |
1600 if (src[i].value.len == 0) { | |
1601 continue; | |
1602 } | |
1603 } | |
1604 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1605 copy = ngx_array_push_n(params->lengths, |
3637 | 1606 sizeof(ngx_http_script_copy_code_t)); |
1607 if (copy == NULL) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1608 return NGX_ERROR; |
3637 | 1609 } |
1610 | |
1611 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; | |
1612 copy->len = src[i].key.len + 1; | |
1613 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1614 copy = ngx_array_push_n(params->lengths, |
4331
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1615 sizeof(ngx_http_script_copy_code_t)); |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1616 if (copy == NULL) { |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1617 return NGX_ERROR; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1618 } |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1619 |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1620 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1621 copy->len = src[i].skip_empty; |
059260de158d
SCGI: added "if_not_empty" flag support to the "scgi_param" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4294
diff
changeset
|
1622 |
3637 | 1623 |
1624 size = (sizeof(ngx_http_script_copy_code_t) | |
1625 + src[i].key.len + 1 + sizeof(uintptr_t) - 1) | |
1626 & ~(sizeof(uintptr_t) - 1); | |
1627 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1628 copy = ngx_array_push_n(params->values, size); |
3637 | 1629 if (copy == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1630 return NGX_ERROR; |
3637 | 1631 } |
1632 | |
1633 copy->code = ngx_http_script_copy_code; | |
1634 copy->len = src[i].key.len + 1; | |
1635 | |
1636 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
1637 (void) ngx_cpystrn(p, src[i].key.data, src[i].key.len + 1); | |
1638 | |
1639 | |
1640 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
1641 | |
1642 sc.cf = cf; | |
1643 sc.source = &src[i].value; | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1644 sc.flushes = ¶ms->flushes; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1645 sc.lengths = ¶ms->lengths; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1646 sc.values = ¶ms->values; |
3637 | 1647 |
1648 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1649 return NGX_ERROR; |
3637 | 1650 } |
1651 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1652 code = ngx_array_push_n(params->lengths, sizeof(uintptr_t)); |
3637 | 1653 if (code == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1654 return NGX_ERROR; |
3637 | 1655 } |
1656 | |
1657 *code = (uintptr_t) NULL; | |
1658 | |
1659 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1660 code = ngx_array_push_n(params->values, sizeof(uintptr_t)); |
3637 | 1661 if (code == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1662 return NGX_ERROR; |
3637 | 1663 } |
1664 | |
1665 *code = (uintptr_t) NULL; | |
1666 } | |
1667 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1668 code = ngx_array_push_n(params->lengths, sizeof(uintptr_t)); |
3637 | 1669 if (code == NULL) { |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1670 return NGX_ERROR; |
3637 | 1671 } |
1672 | |
1673 *code = (uintptr_t) NULL; | |
1674 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1675 params->number = headers_names.nelts; |
3637 | 1676 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1677 hash.hash = ¶ms->hash; |
3637 | 1678 hash.key = ngx_hash_key_lc; |
1679 hash.max_size = 512; | |
1680 hash.bucket_size = 64; | |
1681 hash.name = "scgi_params_hash"; | |
1682 hash.pool = cf->pool; | |
1683 hash.temp_pool = NULL; | |
1684 | |
4277
e4b8255e44c3
Separate functions to merge fastcgi/scgi/uwsgi params.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4157
diff
changeset
|
1685 return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); |
3637 | 1686 } |
1687 | |
1688 | |
1689 static char * | |
1690 ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1691 { | |
1692 ngx_http_scgi_loc_conf_t *scf = conf; | |
1693 | |
1694 ngx_url_t u; | |
1695 ngx_str_t *value, *url; | |
1696 ngx_uint_t n; | |
1697 ngx_http_core_loc_conf_t *clcf; | |
1698 ngx_http_script_compile_t sc; | |
1699 | |
1700 if (scf->upstream.upstream || scf->scgi_lengths) { | |
1701 return "is duplicate"; | |
1702 } | |
1703 | |
5758
f3df4e420ae7
Style: remove whitespace between function name and parentheses.
Piotr Sikora <piotr@cloudflare.com>
parents:
5738
diff
changeset
|
1704 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
3637 | 1705 clcf->handler = ngx_http_scgi_handler; |
1706 | |
1707 value = cf->args->elts; | |
1708 | |
1709 url = &value[1]; | |
1710 | |
1711 n = ngx_http_script_variables_count(url); | |
1712 | |
1713 if (n) { | |
1714 | |
1715 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
1716 | |
1717 sc.cf = cf; | |
1718 sc.source = url; | |
1719 sc.lengths = &scf->scgi_lengths; | |
1720 sc.values = &scf->scgi_values; | |
1721 sc.variables = n; | |
1722 sc.complete_lengths = 1; | |
1723 sc.complete_values = 1; | |
1724 | |
1725 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
1726 return NGX_CONF_ERROR; | |
1727 } | |
1728 | |
1729 return NGX_CONF_OK; | |
1730 } | |
1731 | |
1732 ngx_memzero(&u, sizeof(ngx_url_t)); | |
1733 | |
1734 u.url = value[1]; | |
1735 u.no_resolve = 1; | |
1736 | |
1737 scf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); | |
1738 if (scf->upstream.upstream == NULL) { | |
1739 return NGX_CONF_ERROR; | |
1740 } | |
1741 | |
1742 if (clcf->name.data[clcf->name.len - 1] == '/') { | |
1743 clcf->auto_redirect = 1; | |
1744 } | |
1745 | |
1746 return NGX_CONF_OK; | |
1747 } | |
1748 | |
1749 | |
1750 static char * | |
1751 ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1752 { | |
1753 ngx_http_scgi_loc_conf_t *scf = conf; | |
1754 | |
1755 ngx_str_t *value; | |
1756 ngx_http_script_compile_t sc; | |
1757 | |
1758 if (scf->upstream.store != NGX_CONF_UNSET || scf->upstream.store_lengths) { | |
1759 return "is duplicate"; | |
1760 } | |
1761 | |
1762 value = cf->args->elts; | |
1763 | |
1764 if (ngx_strcmp(value[1].data, "off") == 0) { | |
1765 scf->upstream.store = 0; | |
1766 return NGX_CONF_OK; | |
1767 } | |
1768 | |
1769 #if (NGX_HTTP_CACHE) | |
1770 | |
1771 if (scf->upstream.cache != NGX_CONF_UNSET_PTR | |
1772 && scf->upstream.cache != NULL) | |
1773 { | |
1774 return "is incompatible with \"scgi_cache\""; | |
1775 } | |
1776 | |
1777 #endif | |
1778 | |
1779 if (ngx_strcmp(value[1].data, "on") == 0) { | |
1780 scf->upstream.store = 1; | |
1781 return NGX_CONF_OK; | |
1782 } | |
1783 | |
1784 /* include the terminating '\0' into script */ | |
1785 value[1].len++; | |
1786 | |
1787 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
1788 | |
1789 sc.cf = cf; | |
1790 sc.source = &value[1]; | |
1791 sc.lengths = &scf->upstream.store_lengths; | |
1792 sc.values = &scf->upstream.store_values; | |
5496
9d056f10fb99
Style: removed surplus semicolons.
Valentin Bartenev <vbart@nginx.com>
parents:
5451
diff
changeset
|
1793 sc.variables = ngx_http_script_variables_count(&value[1]); |
3637 | 1794 sc.complete_lengths = 1; |
1795 sc.complete_values = 1; | |
1796 | |
1797 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
1798 return NGX_CONF_ERROR; | |
1799 } | |
1800 | |
1801 return NGX_CONF_OK; | |
1802 } | |
1803 | |
1804 | |
1805 #if (NGX_HTTP_CACHE) | |
1806 | |
1807 static char * | |
1808 ngx_http_scgi_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1809 { | |
1810 ngx_http_scgi_loc_conf_t *scf = conf; | |
1811 | |
1812 ngx_str_t *value; | |
1813 | |
1814 value = cf->args->elts; | |
1815 | |
1816 if (scf->upstream.cache != NGX_CONF_UNSET_PTR) { | |
1817 return "is duplicate"; | |
1818 } | |
1819 | |
1820 if (ngx_strcmp(value[1].data, "off") == 0) { | |
1821 scf->upstream.cache = NULL; | |
1822 return NGX_CONF_OK; | |
1823 } | |
1824 | |
1825 if (scf->upstream.store > 0 || scf->upstream.store_lengths) { | |
1826 return "is incompatible with \"scgi_store\""; | |
1827 } | |
1828 | |
1829 scf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0, | |
1830 &ngx_http_scgi_module); | |
1831 if (scf->upstream.cache == NULL) { | |
1832 return NGX_CONF_ERROR; | |
1833 } | |
1834 | |
1835 return NGX_CONF_OK; | |
1836 } | |
1837 | |
1838 | |
1839 static char * | |
1840 ngx_http_scgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1841 { | |
1842 ngx_http_scgi_loc_conf_t *scf = conf; | |
1843 | |
1844 ngx_str_t *value; | |
1845 ngx_http_compile_complex_value_t ccv; | |
1846 | |
1847 value = cf->args->elts; | |
1848 | |
4947
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4929
diff
changeset
|
1849 if (scf->cache_key.value.data) { |
3637 | 1850 return "is duplicate"; |
1851 } | |
1852 | |
1853 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
1854 | |
1855 ccv.cf = cf; | |
1856 ccv.value = &value[1]; | |
1857 ccv.complex_value = &scf->cache_key; | |
1858 | |
1859 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
1860 return NGX_CONF_ERROR; | |
1861 } | |
1862 | |
1863 return NGX_CONF_OK; | |
1864 } | |
1865 | |
1866 #endif |