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