diff options
author | Sven Nierlein <sven@nierlein.de> | 2022-12-22 13:06:08 (GMT) |
---|---|---|
committer | Sven Nierlein <sven@nierlein.org> | 2023-01-07 17:34:46 (GMT) |
commit | c256af44fb23a4749faa5f3fce167a9d9a4367d7 (patch) | |
tree | b6b1deb40845ebd6547b5d1d9ee22c461b7d1f8b /plugins | |
parent | 6ed7a75c3b4565af54b8fd4d96225a36a705a0fd (diff) | |
download | monitoring-plugins-c256af44fb23a4749faa5f3fce167a9d9a4367d7.tar.gz |
check_http/check_curl: add chunked encoding test
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/tests/check_curl.t | 18 | ||||
-rwxr-xr-x | plugins/tests/check_http.t | 18 |
2 files changed, 34 insertions, 2 deletions
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t index aa72ef6..86bfb53 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 = 72; | 24 | my $common_tests = 74; |
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,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 | } |
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index ea11b2a..132c665 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
@@ -12,7 +12,7 @@ use FindBin qw($Bin); | |||
12 | 12 | ||
13 | $ENV{'LC_TIME'} = "C"; | 13 | $ENV{'LC_TIME'} = "C"; |
14 | 14 | ||
15 | my $common_tests = 70; | 15 | my $common_tests = 72; |
16 | my $virtual_port_tests = 8; | 16 | my $virtual_port_tests = 8; |
17 | my $ssl_only_tests = 12; | 17 | my $ssl_only_tests = 12; |
18 | # Check that all dependent modules are available | 18 | # Check that all dependent modules are available |
@@ -190,6 +190,17 @@ sub run_server { | |||
190 | $c->send_basic_header; | 190 | $c->send_basic_header; |
191 | $c->send_crlf; | 191 | $c->send_crlf; |
192 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); | 192 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); |
193 | } elsif ($r->url->path eq "/chunked") { | ||
194 | $c->send_basic_header; | ||
195 | $c->send_header('Transfer-Encoding', "chunked"); | ||
196 | $c->send_crlf; | ||
197 | my $chunks = ["chunked", "encoding", "test\n"]; | ||
198 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub { | ||
199 | my $chunk = shift @{$chunks}; | ||
200 | return unless $chunk; | ||
201 | sleep(1); | ||
202 | return($chunk); | ||
203 | })); | ||
193 | } else { | 204 | } else { |
194 | $c->send_error(HTTP::Status->RC_FORBIDDEN); | 205 | $c->send_error(HTTP::Status->RC_FORBIDDEN); |
195 | } | 206 | } |
@@ -497,4 +508,9 @@ sub run_common_tests { | |||
497 | }; | 508 | }; |
498 | is( $@, "", $cmd ); | 509 | is( $@, "", $cmd ); |
499 | 510 | ||
511 | $cmd = "$command -u /chunked -s 'chunkedencodingtest'"; | ||
512 | eval { | ||
513 | $result = NPTest->testCmd( $cmd, 5 ); | ||
514 | }; | ||
515 | is( $@, "", $cmd ); | ||
500 | } | 516 | } |