- my $i = 0;
- my $cb = sub { # called by MboxGz->getline
- while (1) {
- while (my $mi = (($mset->items)[$i++])) {
- my $doc = $mi->get_document;
- my $smsg = $srch->retry_reopen(sub {
- PublicInbox::SearchMsg->load_doc($doc);
- }) or next;
- return $smsg;
- }
- # refill result set
- $mset = $srch->query($query, $opts);
- my $size = $mset->size or return;
- $opts->{offset} += $size;
- $i = 0;
- }
- };
- PublicInbox::MboxGz->response($ctx, $cb, 'results-'.$query);
-}
-
-sub need_gzip {
- my $fh = $_[0]->([501, ['Content-Type' => 'text/html']]);
- my $title = 'gzipped mbox not available';
- $fh->write(<<EOF);
-<html><head><title>$title</title><body><pre>$title
-The administrator needs to install the Compress::Raw::Zlib Perl module
-to support gzipped mboxes.
-<a href="../">Return to index</a></pre></body></html>
-EOF
- $fh->close;
+ $ctx->{iter} = 0;
+ $ctx->{query} = $query;
+ PublicInbox::MboxGz->response($ctx, \&results_cb, 'results-'.$query);