summaryrefslogtreecommitdiffstats
path: root/plugins/tests/check_curl.t
diff options
context:
space:
mode:
authorSven Nierlein <sven@nierlein.de>2022-12-22 14:06:08 +0100
committerSven Nierlein <sven@nierlein.org>2023-01-07 18:34:46 +0100
commitc256af44fb23a4749faa5f3fce167a9d9a4367d7 (patch)
treeb6b1deb40845ebd6547b5d1d9ee22c461b7d1f8b /plugins/tests/check_curl.t
parent6ed7a75c3b4565af54b8fd4d96225a36a705a0fd (diff)
downloadmonitoring-plugins-c256af4.tar.gz
check_http/check_curl: add chunked encoding test
Diffstat (limited to 'plugins/tests/check_curl.t')
-rwxr-xr-xplugins/tests/check_curl.t18
1 files changed, 17 insertions, 1 deletions
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
index aa72ef67..86bfb538 100755
--- a/plugins/tests/check_curl.t
+++ b/plugins/tests/check_curl.t
@@ -21,7 +21,7 @@ use FindBin qw($Bin);
21 21
22$ENV{'LC_TIME'} = "C"; 22$ENV{'LC_TIME'} = "C";
23 23
24my $common_tests = 72; 24my $common_tests = 74;
25my $ssl_only_tests = 8; 25my $ssl_only_tests = 8;
26# Check that all dependent modules are available 26# Check that all dependent modules are available
27eval "use HTTP::Daemon 6.01;"; 27eval "use HTTP::Daemon 6.01;";
@@ -200,6 +200,17 @@ sub run_server {
200 $c->send_basic_header; 200 $c->send_basic_header;
201 $c->send_crlf; 201 $c->send_crlf;
202 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); 202 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
203 } elsif ($r->url->path eq "/chunked") {
204 $c->send_basic_header;
205 $c->send_header('Transfer-Encoding', "chunked");
206 $c->send_crlf;
207 my $chunks = ["chunked", "encoding", "test\n"];
208 $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
209 my $chunk = shift @{$chunks};
210 return unless $chunk;
211 sleep(1);
212 return($chunk);
213 }));
203 } else { 214 } else {
204 $c->send_error(HTTP::Status->RC_FORBIDDEN); 215 $c->send_error(HTTP::Status->RC_FORBIDDEN);
205 } 216 }
@@ -508,4 +519,9 @@ sub run_common_tests {
508 }; 519 };
509 is( $@, "", $cmd ); 520 is( $@, "", $cmd );
510 521
522 $cmd = "$command -u /chunked -s 'chunkedencodingtest'";
523 eval {
524 $result = NPTest->testCmd( $cmd, 5 );
525 };
526 is( $@, "", $cmd );
511} 527}