summaryrefslogtreecommitdiffstats
path: root/debian/vendor-h2o/t/40protocol.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:12:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:12:02 +0000
commit77e50caaf2ef81cd91075cf836fed0e75718ffb4 (patch)
tree53b7b411290b63192fc9e924a3b6b65cdf67e9d0 /debian/vendor-h2o/t/40protocol.t
parentAdding upstream version 1.8.3. (diff)
downloaddnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.tar.xz
dnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.zip
Adding debian version 1.8.3-2.debian/1.8.3-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/vendor-h2o/t/40protocol.t')
-rw-r--r--debian/vendor-h2o/t/40protocol.t63
1 files changed, 63 insertions, 0 deletions
diff --git a/debian/vendor-h2o/t/40protocol.t b/debian/vendor-h2o/t/40protocol.t
new file mode 100644
index 0000000..e12f016
--- /dev/null
+++ b/debian/vendor-h2o/t/40protocol.t
@@ -0,0 +1,63 @@
+use strict;
+use warnings;
+use Digest::MD5 qw(md5_hex);
+use Test::More;
+use t::Util;
+
+my %files = map { do {
+ my $fn = DOC_ROOT . "/$_";
+ +($_ => { size => +(stat $fn)[7], md5 => md5_file($fn) });
+} } qw(index.txt halfdome.jpg);
+
+my $server = spawn_h2o(<< "EOT");
+hosts:
+ default:
+ paths:
+ /:
+ file.dir: @{[ DOC_ROOT ]}
+EOT
+
+my $port = $server->{port};
+my $tls_port = $server->{tls_port};
+
+subtest 'curl' => sub {
+ run_with_curl($server, sub {
+ my ($proto, $port, $curl) = @_;
+ for my $file (sort keys %files) {
+ my $content = `$curl --silent --show-error $proto://127.0.0.1:$port/$file`;
+ is length($content), $files{$file}->{size}, "$file (size)";
+ is md5_hex($content), $files{$file}->{md5}, "$file (md5)";
+ }
+ });
+};
+
+subtest 'nghttp' => sub {
+ plan skip_all => 'nghttp not found'
+ unless prog_exists('nghttp');
+ my $doit = sub {
+ my ($proto, $port) = @_;
+ my $opt = $proto eq 'http' ? '-u' : '';
+ for my $file (sort keys %files) {
+ my $content = `nghttp $opt $proto://127.0.0.1:$port/$file`;
+ is length($content), $files{$file}->{size}, "$proto://127.0.0.1/$file (size)";
+ is md5_hex($content), $files{$file}->{md5}, "$proto://127.0.0.1/$file (md5)";
+ }
+ my $out = `nghttp -u -m 100 $proto://127.0.0.1:$port/index.txt`;
+ is $out, "hello\n" x 100, "$proto://127.0.0.1/index.txt x 100 times";
+ };
+ $doit->('http', $port);
+ subtest 'https' => sub {
+ plan skip_all => 'OpenSSL does not support protocol negotiation; it is too old'
+ unless openssl_can_negotiate();
+ $doit->('https', $tls_port);
+ };
+};
+
+subtest 'ab' => sub {
+ plan skip_all => 'ab not found'
+ unless prog_exists('ab');
+ ok(system("ab -c 10 -n 10000 -k http://127.0.0.1:$port/index.txt") == 0);
+ ok(system("ab -f tls1 -c 10 -n 10000 -k https://127.0.0.1:$tls_port/index.txt") == 0);
+};
+
+done_testing;