]> Sergey Matveev's repositories - public-inbox.git/commitdiff
http: fix clobbering of $null_io
authorEric Wong <e@80x24.org>
Sun, 25 Dec 2016 09:40:25 +0000 (09:40 +0000)
committerEric Wong <e@80x24.org>
Sun, 25 Dec 2016 09:40:38 +0000 (09:40 +0000)
Oops, this would be disatrous if we started handling
bigger request bodies or slow clients.

Fixes: c008654229a9 ("avoid IO::File for anonymous temporary files")
lib/PublicInbox/HTTP.pm

index cac14be380874b03df90a2cf4e54b9bb816a6c86..c4b74b457ecccabdc000867e2a83f55793b72ce6 100644 (file)
@@ -328,7 +328,7 @@ sub more ($$) {
 
 sub input_prepare {
        my ($self, $env) = @_;
-       my $input = $null_io;
+       my $input;
        my $len = $env->{CONTENT_LENGTH};
        if ($len) {
                if ($len > $MAX_REQUEST_BUFFER) {
@@ -339,6 +339,8 @@ sub input_prepare {
        } elsif (env_chunked($env)) {
                $len = CHUNK_START;
                open($input, '+>', undef);
+       } else {
+               $input = $null_io;
        }
 
        # TODO: expire idle clients on ENFILE / EMFILE