-sub getline_response {
- my ($self, $body, $write, $close) = @_;
- $self->{forward} = $body;
- weaken($self);
- my $pull = $self->{pull} = sub {
- local $/ = \8192;
- my $forward = $self->{forward};
- # limit our own running time for fairness with other
- # clients and to avoid buffering too much:
- my $n = 100;
- while ($forward && defined(my $buf = $forward->getline)) {
- $write->($buf);
- last if $self->{closed};
- if ($self->{write_buf_size}) {
- $self->write($self->{pull});
- return;
- } elsif ((--$n) <= 0) {
- PublicInbox::EvCleanup::asap($self->{pull});
- return;
- }
+sub getline_pull {
+ my ($self) = @_;
+ my $forward = $self->{forward};
+
+ # limit our own running time for fairness with other
+ # clients and to avoid buffering too much:
+ my $buf = eval {
+ local $/ = \65536;
+ $forward->getline;
+ } if $forward;
+
+ if (defined $buf) {
+ # may close in PublicInbox::DS::write
+ if ($self->{alive} == 2) {
+ chunked_write($self, $buf);
+ } else {
+ identity_write($self, $buf);