[monitoring-plugins] tests: fix chunked encoding test server
Sven Nierlein
git at monitoring-plugins.org
Sat Jan 7 18:40:14 CET 2023
Module: monitoring-plugins
Branch: master
Commit: 07561a67abb02688955433db5b4a38b23523a754
Author: Sven Nierlein <sven at nierlein.de>
Committer: Sven Nierlein <sven at nierlein.org>
Date: Thu Dec 22 14:58:01 2022 +0100
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=07561a6
tests: fix chunked encoding test server
---
plugins/tests/check_curl.t | 29 ++++++++++++++---------------
plugins/tests/check_http.t | 7 ++-----
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
index 86bfb53..72f2b7c 100755
--- a/plugins/tests/check_curl.t
+++ b/plugins/tests/check_curl.t
@@ -21,7 +21,7 @@ use FindBin qw($Bin);
$ENV{'LC_TIME'} = "C";
-my $common_tests = 74;
+my $common_tests = 73;
my $ssl_only_tests = 8;
# Check that all dependent modules are available
eval "use HTTP::Daemon 6.01;";
@@ -200,17 +200,14 @@ sub run_server {
$c->send_basic_header;
$c->send_crlf;
$c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
- } elsif ($r->url->path eq "/chunked") {
- $c->send_basic_header;
- $c->send_header('Transfer-Encoding', "chunked");
- $c->send_crlf;
- my $chunks = ["chunked", "encoding", "test\n"];
- $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
- my $chunk = shift @{$chunks};
- return unless $chunk;
- sleep(1);
- return($chunk);
- }));
+ } elsif ($r->url->path eq "/chunked") {
+ my $chunks = ["chunked", "encoding", "test\n"];
+ $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
+ my $chunk = shift @{$chunks};
+ return unless $chunk;
+ sleep(1);
+ return($chunk);
+ }));
} else {
$c->send_error(HTTP::Status->RC_FORBIDDEN);
}
@@ -483,7 +480,8 @@ sub run_common_tests {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm(2);
$result = NPTest->testCmd( $cmd );
- alarm(0); };
+ };
+ alarm(0);
isnt( $@, "alarm\n", $cmd );
is( $result->return_code, 0, $cmd );
@@ -493,7 +491,8 @@ sub run_common_tests {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm(2);
$result = NPTest->testCmd( $cmd );
- alarm(0); };
+ };
+ alarm(0);
isnt( $@, "alarm\n", $cmd );
isnt( $result->return_code, 0, $cmd );
@@ -519,7 +518,7 @@ sub run_common_tests {
};
is( $@, "", $cmd );
- $cmd = "$command -u /chunked -s 'chunkedencodingtest'";
+ $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
eval {
$result = NPTest->testCmd( $cmd, 5 );
};
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index 132c665..d766ac3 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -12,7 +12,7 @@ use FindBin qw($Bin);
$ENV{'LC_TIME'} = "C";
-my $common_tests = 72;
+my $common_tests = 71;
my $virtual_port_tests = 8;
my $ssl_only_tests = 12;
# Check that all dependent modules are available
@@ -191,9 +191,6 @@ sub run_server {
$c->send_crlf;
$c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
} elsif ($r->url->path eq "/chunked") {
- $c->send_basic_header;
- $c->send_header('Transfer-Encoding', "chunked");
- $c->send_crlf;
my $chunks = ["chunked", "encoding", "test\n"];
$c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
my $chunk = shift @{$chunks};
@@ -508,7 +505,7 @@ sub run_common_tests {
};
is( $@, "", $cmd );
- $cmd = "$command -u /chunked -s 'chunkedencodingtest'";
+ $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
eval {
$result = NPTest->testCmd( $cmd, 5 );
};
More information about the Commits
mailing list