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