about summary refs log tree commit homepage
path: root/t/common.perl
diff options
context:
space:
mode:
Diffstat (limited to 't/common.perl')
-rw-r--r--t/common.perl21
1 files changed, 9 insertions, 12 deletions
diff --git a/t/common.perl b/t/common.perl
index bec57699..1251333d 100644
--- a/t/common.perl
+++ b/t/common.perl
@@ -1,18 +1,15 @@
 # Copyright (C) 2015 all contributors <meta@public-inbox.org>
 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
-require IO::File;
-use POSIX qw/dup/;
 
 sub stream_to_string {
-        my ($cb) = @_;
-        my $headers;
-        my $io = IO::File->new_tmpfile;
-        my $dup = dup($io->fileno);
-        my $response = sub { $headers = \@_, $io };
-        $cb->($response);
-        $io = IO::File->new;
-        $io->fdopen($dup, 'r+');
-        $io->seek(0, 0);
-        $io->read(my $str, ($io->stat)[7]);
+        my ($res) = @_;
+        my $body = $res->[2];
+        my $str = '';
+        while (defined(my $chunk = $body->getline)) {
+                $str .= $chunk;
+        }
+        $body->close;
         $str;
 }
+
+1;