$title$title
-The administrator needs to install the IO::Compress::Gzip Perl module
+The administrator needs to install the Compress::Raw::Zlib Perl module
to support gzipped mboxes.
Return to index
EOF
- $fh->close;
-}
-
-1;
-package PublicInbox::MboxGz;
-use strict;
-use warnings;
-
-sub new {
- my ($class, $ctx, $cb) = @_;
- my $buf = '';
- bless {
- buf => \$buf,
- gz => IO::Compress::Gzip->new(\$buf, Time => 0),
- cb => $cb,
- ctx => $ctx,
- msgs => [],
- opts => { asc => 1, offset => 0 },
- }, $class;
-}
-
-# called by Plack::Util::foreach or similar
-sub getline {
- my ($self) = @_;
- my $ctx = $self->{ctx} or return;
- my $res;
- my $ibx = $ctx->{-inbox};
- my $gz = $self->{gz};
- do {
- while (defined(my $smsg = shift @{$self->{msgs}})) {
- my $msg = eval { $ibx->msg_by_mid($smsg->mid) } or next;
- $msg = Email::Simple->new($msg);
- $gz->write(PublicInbox::Mbox::msg_str($ctx, $msg));
- my $bref = $self->{buf};
- if (length($$bref) >= 8192) {
- my $ret = $$bref; # copy :<
- ${$self->{buf}} = '';
- return $ret;
- }
- }
- $res = $self->{cb}->($self->{opts});
- $self->{msgs} = $res->{msgs};
- $res = scalar @{$self->{msgs}};
- $self->{opts}->{offset} += $res;
- } while ($res);
- $gz->close;
- delete $self->{ctx};
- ${delete $self->{buf}};
+ [501,[qw(Content-Type text/html Content-Length), bytes::length($body)],
+ [ $body ] ];
}
-sub close {} # noop
-
1;