From c256af44fb23a4749faa5f3fce167a9d9a4367d7 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Thu, 22 Dec 2022 14:06:08 +0100 Subject: check_http/check_curl: add chunked encoding test 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); $ENV{'LC_TIME'} = "C"; -my $common_tests = 72; +my $common_tests = 74; my $ssl_only_tests = 8; # Check that all dependent modules are available eval "use HTTP::Daemon 6.01;"; @@ -200,6 +200,17 @@ 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); + })); } else { $c->send_error(HTTP::Status->RC_FORBIDDEN); } @@ -508,4 +519,9 @@ sub run_common_tests { }; is( $@, "", $cmd ); + $cmd = "$command -u /chunked -s 'chunkedencodingtest'"; + eval { + $result = NPTest->testCmd( $cmd, 5 ); + }; + is( $@, "", $cmd ); } 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); $ENV{'LC_TIME'} = "C"; -my $common_tests = 70; +my $common_tests = 72; my $virtual_port_tests = 8; my $ssl_only_tests = 12; # Check that all dependent modules are available @@ -190,6 +190,17 @@ 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); + })); } else { $c->send_error(HTTP::Status->RC_FORBIDDEN); } @@ -497,4 +508,9 @@ sub run_common_tests { }; is( $@, "", $cmd ); + $cmd = "$command -u /chunked -s 'chunkedencodingtest'"; + eval { + $result = NPTest->testCmd( $cmd, 5 ); + }; + is( $@, "", $cmd ); } -- cgit v0.10-9-g596f