diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
commit | be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/t/50http2_debug_state.t | |
parent | Initial commit. (diff) | |
download | netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.tar.xz netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.zip |
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/t/50http2_debug_state.t')
-rw-r--r-- | web/server/h2o/libh2o/t/50http2_debug_state.t | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/t/50http2_debug_state.t b/web/server/h2o/libh2o/t/50http2_debug_state.t new file mode 100644 index 00000000..b78dee41 --- /dev/null +++ b/web/server/h2o/libh2o/t/50http2_debug_state.t @@ -0,0 +1,69 @@ +use strict; +use warnings; +use Test::More; +use Test::Exception; +use t::Util; +use JSON; + +plan skip_all => 'curl not found' + unless prog_exists('curl'); + +subtest 'minimum' => sub { + my $server = spawn_h2o(<< "EOT"); +hosts: + default: + http2-debug-state: minimum + paths: + /: + file.dir: @{[ DOC_ROOT ]} +EOT + + run_with_curl($server, sub { + my ($proto, $port, $curl_cmd) = @_; + $curl_cmd .= " --silent --show-error"; + my $url = "$proto://127.0.0.1:$port/.well-known/h2/state"; + + if ($curl_cmd =~ /--http2/) { + subtest "single stream itself" => sub { + my ($headers, $body) = run_prog("$curl_cmd --dump-header /dev/stderr $url"); + like($headers, qr!^HTTP/2(\.0)? 200!); + my $data; + lives_ok { $data = decode_json($body) }; + is($data->{streams}->{1}->{state}, 'HALF_CLOSED_REMOTE'); + }; + } else { + subtest "return_404_when_http1" => sub { + my ($headers, $body) = run_prog("$curl_cmd --dump-header /dev/stderr $url"); + like($headers, qr!^HTTP/1.1 404!); + }; + } + }); +}; + +subtest 'hpack' => sub { + plan skip_all => "curl does not support HTTP/2" + unless curl_supports_http2(); + + my $server = spawn_h2o(<< "EOT"); +hosts: + default: + http2-debug-state: hpack + paths: + /: + file.dir: @{[ DOC_ROOT ]} +EOT + + my ($proto, $port) = ('https', $server->{tls_port}); + my $curl_cmd = 'curl --insecure --http2 --silent --show-error --dump-header /dev/stderr'; + my $url = "$proto://127.0.0.1:$port/.well-known/h2/state"; + + subtest "with hpack state" => sub { + my ($headers, $body) = run_prog("$curl_cmd $url"); + like($headers, qr!^HTTP/2(\.0)? 200!); + my $data; + lives_ok { $data = decode_json($body) }; + ok(exists $data->{hpack}); + }; +}; + +done_testing(); |