use bytes (); # only for bytes::length
use Fcntl qw(:seek);
use Plack::HTTPParser qw(parse_http_request); # XS or pure Perl
+use Plack::Util;
use HTTP::Status qw(status_message);
use HTTP::Date qw(time2str);
-use IO::Handle;
+use IO::Handle; # ->write
use PublicInbox::DS qw(msg_more);
use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
use PublicInbox::Tmpfile;
my $env = $self->{env};
$env->{REMOTE_ADDR} = $self->{remote_addr};
$env->{REMOTE_PORT} = $self->{remote_port};
- if (my $host = $env->{HTTP_HOST}) {
+ if (defined(my $host = $env->{HTTP_HOST})) {
$host =~ s/:([0-9]+)\z// and $env->{SERVER_PORT} = $1;
$env->{SERVER_NAME} = $host;
}
}
# note: NOT $self->{sock}, we want our close (+ PublicInbox::DS::close),
# to do proper cleanup:
- $env->{'psgix.io'} = $self; # only for ->close
+ $env->{'psgix.io'} = $self; # for ->close or async_pass
my $res = Plack::Util::run_app($self->{httpd}->{app}, $env);
eval {
if (ref($res) eq 'CODE') {
response_write($self, $env, $res);
}
};
- $self->close if $@;
+ if ($@) {
+ err($self, "response_write error: $@");
+ $self->close;
+ }
}
sub response_header_write {
}
if ($self->{sock}) {
- my $wbuf = $self->{wbuf} //= [];
- push @$wbuf, \&getline_pull;
+ # autovivify wbuf
+ my $new_size = push(@{$self->{wbuf}}, \&getline_pull);
# wbuf may be populated by {chunked,identity}_write()
# above, no need to rearm if so:
- $self->requeue if scalar(@$wbuf) == 1;
+ $self->requeue if $new_size == 1;
return; # likely
}
} elsif ($@) {