]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Git.pm
allow HTTP_HOST to be '0' via defined() checks
[public-inbox.git] / lib / PublicInbox / Git.pm
index af3a5712cf79dec86c90e4f92eb9a2df87a3683e..2aaf1866b5965169e4abcec87f1fdaed9b6fb47c 100644 (file)
@@ -10,7 +10,7 @@ package PublicInbox::Git;
 use strict;
 use warnings;
 use POSIX qw(dup2);
-require IO::Handle;
+use IO::Handle; # ->autoflush
 use PublicInbox::Spawn qw(spawn popen_rd);
 use PublicInbox::Tmpfile;
 use base qw(Exporter);
@@ -114,12 +114,12 @@ sub _bidi_pipe {
 
        my @cmd = (qw(git), "--git-dir=$self->{git_dir}",
                        qw(-c core.abbrev=40 cat-file), $batch);
-       my $redir = { 0 => fileno($out_r), 1 => fileno($in_w) };
+       my $redir = { 0 => $out_r, 1 => $in_w };
        if ($err) {
                my $id = "git.$self->{git_dir}$batch.err";
                my $fh = tmpfile($id) or fail($self, "tmpfile($id): $!");
                $self->{$err} = $fh;
-               $redir->{2} = fileno($fh);
+               $redir->{2} = $fh;
        }
        my $p = spawn(\@cmd, undef, $redir);
        defined $p or fail($self, "spawn failed: $!");
@@ -300,7 +300,7 @@ sub host_prefix_url ($$) {
        my ($env, $url) = @_;
        return $url if index($url, '//') >= 0;
        my $scheme = $env->{'psgi.url_scheme'};
-       my $host_port = $env->{HTTP_HOST} ||
+       my $host_port = $env->{HTTP_HOST} //
                "$env->{SERVER_NAME}:$env->{SERVER_PORT}";
        "$scheme://$host_port". ($env->{SCRIPT_NAME} || '/') . $url;
 }