$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;
-use PublicInbox::MID qw(mid2path);
-
-sub new {
- my ($class, $ctx, $cb) = @_;
- my $buf;
- bless {
- buf => \$buf,
- gz => IO::Compress::Gzip->new(\$buf),
- cb => $cb,
- ctx => $ctx,
- msgs => [],
- opts => { asc => 1, offset => 0 },
- }, $class;
-}
-
-sub _flush_buf {
- my ($self) = @_;
- my $ret = $self->{buf};
- $ret = $$ret;
- ${$self->{buf}} = undef;
- $ret;
-}
-# called by Plack::Util::foreach or similar
-sub getline {
- my ($self) = @_;
- my $res;
- my $ctx = $self->{ctx};
- my $git = $ctx->{git};
- do {
- while (defined(my $smsg = shift @{$self->{msgs}})) {
- my $msg = eval {
- my $p = 'HEAD:'.mid2path($smsg->mid);
- Email::Simple->new($git->cat_file($p));
- };
- $msg or next;
-
- PublicInbox::Mbox::emit_msg($ctx, $self->{gz}, $msg);
- my $ret = _flush_buf($self);
- return $ret if $ret;
- }
- $res = $self->{cb}->($self->{opts});
- $self->{msgs} = $res->{msgs};
- $res = scalar @{$self->{msgs}};
- $self->{opts}->{offset} += $res;
- } while ($res);
- $self->{gz}->close;
- _flush_buf($self);
+ [501,[qw(Content-Type text/html Content-Length), bytes::length($body)],
+ [ $body ] ];
}
-sub close {} # noop
-
1;