comparison js_headers.t @ 1525:ca0858ef7d3d

Tests: added js keys tests.
author Dmitry Volyntsev <xeioex@nginx.com>
date Tue, 22 Oct 2019 21:05:51 +0300
parents b6699ffd9ddd
children c1d167a13c24
comparison
equal deleted inserted replaced
1524:9bc1ca067449 1525:ca0858ef7d3d
85 js_content hdr_out; 85 js_content hdr_out;
86 } 86 }
87 87
88 location /ihdr_out { 88 location /ihdr_out {
89 js_content ihdr_out; 89 js_content ihdr_out;
90 }
91
92 location /hdr_sorted_keys {
93 js_content hdr_sorted_keys;
90 } 94 }
91 } 95 }
92 } 96 }
93 97
94 EOF 98 EOF
149 } 153 }
150 154
151 r.return(200, s); 155 r.return(200, s);
152 } 156 }
153 157
158 function hdr_sorted_keys(r) {
159 var s = '';
160 var hdr = r.args.in ? r.headersIn : r.headersOut;
161
162 if (!r.args.in) {
163 r.headersOut.b = 'b';
164 r.headersOut.c = 'c';
165 r.headersOut.a = 'a';
166 }
167
168 r.return(200, Object.keys(hdr).sort());
169 }
170
154 function test_foo_in(r) { 171 function test_foo_in(r) {
155 return 'hdr=' + r.headersIn.foo; 172 return 'hdr=' + r.headersIn.foo;
156 } 173 }
157 174
158 function test_ifoo_in(r) { 175 function test_ifoo_in(r) {
194 } 211 }
195 212
196 213
197 EOF 214 EOF
198 215
199 $t->try_run('no njs')->plan(16); 216 $t->try_run('no njs')->plan(18);
200 217
201 ############################################################################### 218 ###############################################################################
202 219
203 like(http_get('/content_length'), qr/Content-Length: 3/, 220 like(http_get('/content_length'), qr/Content-Length: 3/,
204 'set Content-Length'); 221 'set Content-Length');
249 . 'Host: localhost' . CRLF . CRLF 266 . 'Host: localhost' . CRLF . CRLF
250 ), qr/x-forwarded-for: foo1, foo2/, 'r.headersIn xff2'); 267 ), qr/x-forwarded-for: foo1, foo2/, 'r.headersIn xff2');
251 268
252 } 269 }
253 270
254 ############################################################################### 271 TODO: {
272 local $TODO = 'not yet'
273 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.3.7';
274
275 like(http(
276 'GET /hdr_sorted_keys?in=1 HTTP/1.0' . CRLF
277 . 'Cookie: foo1' . CRLF
278 . 'Accept: */*' . CRLF
279 . 'Cookie: foo2' . CRLF
280 . 'Host: localhost' . CRLF . CRLF
281 ), qr/Accept,Cookie,Host/, 'r.headersIn sorted keys');
282
283 like(http(
284 'GET /hdr_sorted_keys HTTP/1.0' . CRLF
285 . 'Host: localhost' . CRLF . CRLF
286 ), qr/a,b,c/, 'r.headersOut sorted keys');
287
288 }
289
290 ###############################################################################