From c8bae7493d2f2910b57f13ded012e86bdcfb0532 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:47:53 +0200 Subject: Adding upstream version 1:2.39.2. Signed-off-by: Daniel Baumann --- t/t5562/invoke-with-content-length.pl | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 t/t5562/invoke-with-content-length.pl (limited to 't/t5562/invoke-with-content-length.pl') diff --git a/t/t5562/invoke-with-content-length.pl b/t/t5562/invoke-with-content-length.pl new file mode 100644 index 0000000..718dd9b --- /dev/null +++ b/t/t5562/invoke-with-content-length.pl @@ -0,0 +1,36 @@ +use 5.008; +use strict; +use warnings; + +my $body_filename = $ARGV[0]; +my @command = @ARGV[1 .. $#ARGV]; + +# read data +my $body_size = -s $body_filename; +$ENV{"CONTENT_LENGTH"} = $body_size; +open(my $body_fh, "<", $body_filename) or die "Cannot open $body_filename: $!"; +my $body_data; +defined read($body_fh, $body_data, $body_size) or die "Cannot read $body_filename: $!"; +close($body_fh); + +# write data +my $pid = open(my $out, "|-", @command); +{ + # disable buffering at $out + my $old_selected = select; + select $out; + $| = 1; + select $old_selected; +} +print $out $body_data or die "Cannot write data: $!"; + +$SIG{ALRM} = sub { + kill 'KILL', $pid; + die "Command did not exit after reading whole body"; +}; +alarm 60; + +my $ret = waitpid($pid, 0); +if ($ret != $pid) { + die "confusing return from waitpid: $ret"; +} -- cgit v1.2.3