Mercurial > hg > nginx-tests
comparison h2_request_body.t @ 1597:36d69685605e
Tests: added HTTP/2 tests for DATA frames after 400 errors.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 01 Oct 2020 12:28:34 +0100 |
parents | b5620655b506 |
children | 5ac6efbe5552 |
comparison
equal
deleted
inserted
replaced
1596:f42d82b114cd | 1597:36d69685605e |
---|---|
21 ############################################################################### | 21 ############################################################################### |
22 | 22 |
23 select STDERR; $| = 1; | 23 select STDERR; $| = 1; |
24 select STDOUT; $| = 1; | 24 select STDOUT; $| = 1; |
25 | 25 |
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(44); | 26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(45); |
27 | 27 |
28 $t->write_file_expand('nginx.conf', <<'EOF'); | 28 $t->write_file_expand('nginx.conf', <<'EOF'); |
29 | 29 |
30 %%TEST_GLOBALS%% | 30 %%TEST_GLOBALS%% |
31 | 31 |
39 | 39 |
40 server { | 40 server { |
41 listen 127.0.0.1:8080 http2; | 41 listen 127.0.0.1:8080 http2; |
42 listen 127.0.0.1:8081; | 42 listen 127.0.0.1:8081; |
43 server_name localhost; | 43 server_name localhost; |
44 | |
45 error_page 400 /proxy2/t.html; | |
44 | 46 |
45 location / { | 47 location / { |
46 add_header X-Length $http_content_length; | 48 add_header X-Length $http_content_length; |
47 } | 49 } |
48 location /slow { | 50 location /slow { |
459 | 461 |
460 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | 462 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
461 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 463 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
462 isnt($frame->{headers}->{'x-body'}, 'xxxx', 'sync buffer'); | 464 isnt($frame->{headers}->{'x-body'}, 'xxxx', 'sync buffer'); |
463 | 465 |
466 # request body after 400 errors redirected to a proxied location | |
467 | |
468 TODO: { | |
469 todo_skip 'leaves coredump', 1 unless $ENV{TEST_NGINX_UNSAFE} | |
470 or $t->has_version('1.19.3'); | |
471 | |
472 $s = Test::Nginx::HTTP2->new(); | |
473 $sid = $s->new_stream({ body => "", headers => [ | |
474 { name => ':method', value => "" }]}); | |
475 | |
476 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | |
477 ($frame) = grep { $_->{type} eq 'DATA' } @$frames; | |
478 is($frame->{data}, 'SEE-THIS', 'request body after 400 redirect'); | |
479 | |
480 } | |
481 | |
464 ############################################################################### | 482 ############################################################################### |
465 | 483 |
466 sub read_body_file { | 484 sub read_body_file { |
467 my ($path) = @_; | 485 my ($path) = @_; |
468 open FILE, $path or return "$!"; | 486 open FILE, $path or return "$!"; |