]> Sergey Matveev's repositories - public-inbox.git/commitdiff
http: ensure errors are printable before PSGI env
authorEric Wong <e@80x24.org>
Sun, 6 Mar 2016 02:09:21 +0000 (02:09 +0000)
committerEric Wong <e@80x24.org>
Sun, 6 Mar 2016 02:10:27 +0000 (02:10 +0000)
We cannot rely on a client socket having a PSGI env before headers
are fully-parsed as we seek to avoid storing hashes for idle
clients.  Sso print errors to the psgi.errors value which belongs to
the httpd listener, instead.

lib/PublicInbox/HTTP.pm

index 8988e7d22ef17534ea83d1f2293e501c44493fe7..15db1390f78530832c302cf519facc41b93d9b3d 100644 (file)
@@ -251,7 +251,7 @@ sub env_chunked { ($_[0]->{HTTP_TRANSFER_ENCODING} || '') =~ /\bchunked\b/i }
 
 sub write_err {
        my ($self) = @_;
-       my $err = $self->{env}->{'psgi.errors'};
+       my $err = $self->{httpd}->{env}->{'psgi.errors'};
        my $msg = $! || '(zero write)';
        $err->print("error buffering to input: $msg\n");
        quit($self, 500);
@@ -264,7 +264,7 @@ sub recv_err {
                $self->{input_left} = $len;
                return;
        }
-       my $err = $self->{env}->{'psgi.errors'};
+       my $err = $self->{httpd}->{env}->{'psgi.errors'};
        $err->print("error reading for input: $! ($len bytes remaining)\n");
        quit($self, 500);
 }