comparison js_headers.t @ 1566:5cf2f4da8bd5

Tests: added js tests for multi-values headers in r.headersIn.
author Dmitry Volyntsev <xeioex@nginx.com>
date Wed, 29 Apr 2020 12:33:06 +0000
parents 84a1e16819e5
children 4cc012205ac5
comparison
equal deleted inserted replaced
1565:84a1e16819e5 1566:5cf2f4da8bd5
301 } 301 }
302 302
303 303
304 EOF 304 EOF
305 305
306 $t->try_run('no njs')->plan(34); 306 $t->try_run('no njs')->plan(37);
307 307
308 ############################################################################### 308 ###############################################################################
309 309
310 like(http_get('/content_length'), qr/Content-Length: 3/, 310 like(http_get('/content_length'), qr/Content-Length: 3/,
311 'set Content-Length'); 311 'set Content-Length');
378 like(http( 378 like(http(
379 'GET /hdr_in HTTP/1.0' . CRLF 379 'GET /hdr_in HTTP/1.0' . CRLF
380 . 'Cookie: foo1' . CRLF 380 . 'Cookie: foo1' . CRLF
381 . 'Cookie: foo2' . CRLF 381 . 'Cookie: foo2' . CRLF
382 . 'Host: localhost' . CRLF . CRLF 382 . 'Host: localhost' . CRLF . CRLF
383 ), qr/cookie: foo1; foo2/, 'r.headersIn cookie2'); 383 ), qr/cookie: foo1;\s?foo2/, 'r.headersIn cookie2');
384 384
385 like(http( 385 like(http(
386 'GET /hdr_in HTTP/1.0' . CRLF 386 'GET /hdr_in HTTP/1.0' . CRLF
387 . 'X-Forwarded-For: foo1' . CRLF 387 . 'X-Forwarded-For: foo1' . CRLF
388 . 'X-Forwarded-For: foo2' . CRLF 388 . 'X-Forwarded-For: foo2' . CRLF
389 . 'Host: localhost' . CRLF . CRLF 389 . 'Host: localhost' . CRLF . CRLF
390 ), qr/x-forwarded-for: foo1, foo2/, 'r.headersIn xff2'); 390 ), qr/x-forwarded-for: foo1,\s?foo2/, 'r.headersIn xff2');
391
392 like(http(
393 'GET /hdr_in HTTP/1.0' . CRLF
394 . 'ETag: bar1' . CRLF
395 . 'ETag: bar2' . CRLF
396 . 'Host: localhost' . CRLF . CRLF
397 ), qr/etag: bar1(?!,\s?bar2)/, 'r.headersIn duplicate single');
398
399 like(http(
400 'GET /hdr_in HTTP/1.0' . CRLF
401 . 'Content-Type: bar1' . CRLF
402 . 'Content-Type: bar2' . CRLF
403 . 'Host: localhost' . CRLF . CRLF
404 ), qr/content-type: bar1(?!,\s?bar2)/, 'r.headersIn duplicate single 2');
405
406 TODO: {
407 local $TODO = 'not yet'
408 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.4.1';
409
410 like(http(
411 'GET /hdr_in HTTP/1.0' . CRLF
412 . 'Foo: bar1' . CRLF
413 . 'Foo: bar2' . CRLF
414 . 'Host: localhost' . CRLF . CRLF
415 ), qr/foo: bar1,bar2/, 'r.headersIn duplicate generic');
416
417 }
391 418
392 like(http( 419 like(http(
393 'GET /hdr_sorted_keys?in=1 HTTP/1.0' . CRLF 420 'GET /hdr_sorted_keys?in=1 HTTP/1.0' . CRLF
394 . 'Cookie: foo1' . CRLF 421 . 'Cookie: foo1' . CRLF
395 . 'Accept: */*' . CRLF 422 . 'Accept: */*' . CRLF