From 07561a67abb02688955433db5b4a38b23523a754 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Thu, 22 Dec 2022 14:58:01 +0100 Subject: 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(-) (limited to 'plugins') 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); $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 132c6659..d766ac37 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 ); }; -- cgit v1.2.3-74-g34f1