diff options
author | Eric Wong <e@80x24.org> | 2015-08-22 08:00:37 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-08-22 08:01:53 +0000 |
commit | 1761fba7befab2681276ac8f123593610ad27e58 (patch) | |
tree | 2725fdbd3691a8f00310e9e9ebf96de2deb321ca /t/common.perl | |
parent | 797ba8046562864a09ed36e6040055babb536615 (diff) | |
download | public-inbox-1761fba7befab2681276ac8f123593610ad27e58.tar.gz |
We will attempt to generate Atom feeds "by hand" as the XML::Atom::SimpleFeed API does not support streaming output. Since email is large and servers are small, this should prevent wasting memory when we generate larger feeds. Of course, we hope clients use SAX parsers capable of handling large streams without slurping.
Diffstat (limited to 't/common.perl')
-rw-r--r-- | t/common.perl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/t/common.perl b/t/common.perl new file mode 100644 index 00000000..a3585bf6 --- /dev/null +++ b/t/common.perl @@ -0,0 +1,16 @@ +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]); + $str; +} |