1 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # Wrap a pipe or file for PSGI streaming response bodies and calls the
5 # end callback when the object goes out-of-scope.
6 # This depends on rpipe being _blocking_ on getline.
7 package PublicInbox::GetlineBody;
12 my ($class, $rpipe, $end, $buf) = @_;
13 bless { rpipe => $rpipe, end => $end, buf => $buf }, $class;
16 sub DESTROY { $_[0]->close }
20 my $buf = delete $self->{buf};
21 defined $buf ? $buf : $self->{rpipe}->getline;
26 delete $self->{rpipe};
27 my $end = delete $self->{end} or return;