diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:20:02 +0000 |
commit | 58daab21cd043e1dc37024a7f99b396788372918 (patch) | |
tree | 96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /web/server/h2o/libh2o/t/50file-file.t | |
parent | Releasing debian version 1.43.2-1. (diff) | |
download | netdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz netdata-58daab21cd043e1dc37024a7f99b396788372918.zip |
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/t/50file-file.t')
-rw-r--r-- | web/server/h2o/libh2o/t/50file-file.t | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/t/50file-file.t b/web/server/h2o/libh2o/t/50file-file.t new file mode 100644 index 000000000..7dd3b9228 --- /dev/null +++ b/web/server/h2o/libh2o/t/50file-file.t @@ -0,0 +1,54 @@ +use strict; +use warnings; +use Test::More; +use t::Util; + +plan skip_all => 'curl not found' + unless prog_exists('curl'); + +subtest 'static' => sub { + my $server = spawn_h2o(<< "EOT"); +hosts: + default: + paths: + /favicon.ico: + file.file: @{[DOC_ROOT]}/halfdome.jpg +EOT + run_with_curl($server, sub { + my ($proto, $port, $cmd) = @_; + my $fetch = sub { + my $path = shift; + return `$cmd --silent --dump-header /dev/stderr --max-redirs 0 $proto://127.0.0.1:$port$path 2>&1 > /dev/null`; + }; + my $resp = $fetch->("/"); + like $resp, qr{^HTTP/[0-9\.]+ 404}is; + $resp = $fetch->("/favicon.ico"); + like $resp, qr{^HTTP/[0-9\.]+ 200}is; + like $resp, qr{^content-type:\s*image/jpeg\r$}im; # type is inferred from the extension of the real file + like $resp, qr{^content-length:\s*@{[(stat "@{[DOC_ROOT]}/halfdome.jpg")[7]]}\r$}im; + }); +}; + +subtest 'dynamic' => sub { + eval q{use CGI; 1} + or plan skip_all => 'CGI.pm not found'; + + # spawn h2o + my $server = spawn_h2o(<< "EOT"); +file.custom-handler: + extension: .cgi + fastcgi.spawn: "exec \$H2O_ROOT/share/h2o/fastcgi-cgi" +hosts: + default: + paths: + /robots.txt: + file.file: @{[DOC_ROOT]}/hello.cgi +EOT + run_with_curl($server, sub { + my ($proto, $port, $cmd) = @_; + my $resp = `$cmd --silent $proto://127.0.0.1:$port/robots.txt?name=Tobor`; + is $resp, "Hello Tobor"; + }); +}; + +done_testing; |