diff options
author | Sven Nierlein <sven@nierlein.de> | 2022-12-22 14:58:01 +0100 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.org> | 2023-01-07 18:34:46 +0100 |
commit | 07561a67abb02688955433db5b4a38b23523a754 (patch) | |
tree | 7a2dd12a4db03132e79d8fbf6a8ae7e25c3985b3 /plugins/tests/check_curl.t | |
parent | c256af44fb23a4749faa5f3fce167a9d9a4367d7 (diff) | |
download | monitoring-plugins-07561a67abb02688955433db5b4a38b23523a754.tar.gz |
tests: fix chunked encoding test server
Diffstat (limited to 'plugins/tests/check_curl.t')
-rwxr-xr-x | plugins/tests/check_curl.t | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t index 86bfb538..72f2b7c2 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 | ||
24 | my $common_tests = 74; | 24 | my $common_tests = 73; |
25 | my $ssl_only_tests = 8; | 25 | my $ssl_only_tests = 8; |
26 | # Check that all dependent modules are available | 26 | # Check that all dependent modules are available |
27 | eval "use HTTP::Daemon 6.01;"; | 27 | eval "use HTTP::Daemon 6.01;"; |
@@ -200,17 +200,14 @@ 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") { | 203 | } elsif ($r->url->path eq "/chunked") { |
204 | $c->send_basic_header; | 204 | my $chunks = ["chunked", "encoding", "test\n"]; |
205 | $c->send_header('Transfer-Encoding', "chunked"); | 205 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub { |
206 | $c->send_crlf; | 206 | my $chunk = shift @{$chunks}; |
207 | my $chunks = ["chunked", "encoding", "test\n"]; | 207 | return unless $chunk; |
208 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub { | 208 | sleep(1); |
209 | my $chunk = shift @{$chunks}; | 209 | return($chunk); |
210 | return unless $chunk; | 210 | })); |
211 | sleep(1); | ||
212 | return($chunk); | ||
213 | })); | ||
214 | } else { | 211 | } else { |
215 | $c->send_error(HTTP::Status->RC_FORBIDDEN); | 212 | $c->send_error(HTTP::Status->RC_FORBIDDEN); |
216 | } | 213 | } |
@@ -483,7 +480,8 @@ sub run_common_tests { | |||
483 | local $SIG{ALRM} = sub { die "alarm\n" }; | 480 | local $SIG{ALRM} = sub { die "alarm\n" }; |
484 | alarm(2); | 481 | alarm(2); |
485 | $result = NPTest->testCmd( $cmd ); | 482 | $result = NPTest->testCmd( $cmd ); |
486 | alarm(0); }; | 483 | }; |
484 | alarm(0); | ||
487 | isnt( $@, "alarm\n", $cmd ); | 485 | isnt( $@, "alarm\n", $cmd ); |
488 | is( $result->return_code, 0, $cmd ); | 486 | is( $result->return_code, 0, $cmd ); |
489 | 487 | ||
@@ -493,7 +491,8 @@ sub run_common_tests { | |||
493 | local $SIG{ALRM} = sub { die "alarm\n" }; | 491 | local $SIG{ALRM} = sub { die "alarm\n" }; |
494 | alarm(2); | 492 | alarm(2); |
495 | $result = NPTest->testCmd( $cmd ); | 493 | $result = NPTest->testCmd( $cmd ); |
496 | alarm(0); }; | 494 | }; |
495 | alarm(0); | ||
497 | isnt( $@, "alarm\n", $cmd ); | 496 | isnt( $@, "alarm\n", $cmd ); |
498 | isnt( $result->return_code, 0, $cmd ); | 497 | isnt( $result->return_code, 0, $cmd ); |
499 | 498 | ||
@@ -519,7 +518,7 @@ sub run_common_tests { | |||
519 | }; | 518 | }; |
520 | is( $@, "", $cmd ); | 519 | is( $@, "", $cmd ); |
521 | 520 | ||
522 | $cmd = "$command -u /chunked -s 'chunkedencodingtest'"; | 521 | $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'"; |
523 | eval { | 522 | eval { |
524 | $result = NPTest->testCmd( $cmd, 5 ); | 523 | $result = NPTest->testCmd( $cmd, 5 ); |
525 | }; | 524 | }; |