my $buf;
my $in;
my $err = $env->{'psgi.errors'};
- if (fileno($input) >= 0) {
+ my $fd = eval { fileno($input) };
+ if (defined $fd && $fd >= 0) {
$in = $input;
- } else { # FIXME untested
+ } else {
$in = input_to_file($env) or return r(500);
}
my ($rpipe, $wpipe);
if ($fh) { # stream body from git-http-backend to HTTP client
$fh->write($buf);
$buf = '';
- } elsif ($buf =~ s/\A(.*?)\r?\n\r?\n//s) { # parse headers
+ } elsif ($buf =~ s/\A(.*?)\r\n\r\n//s) { # parse headers
my $h = $1;
my $code = 200;
my @h;
- foreach my $l (split(/\r?\n/, $h)) {
+ foreach my $l (split(/\r\n/, $h)) {
my ($k, $v) = split(/:\s*/, $l, 2);
if ($k =~ /\AStatus\z/i) {
- $code = int($v);
+ ($code) = ($v =~ /\b(\d+)\b/);
} else {
push @h, $k, $v;
}
}
}
-# FIXME: untested, our -httpd _always_ gives a real file handle
sub input_to_file {
my ($env) = @_;
my $in = IO::File->new_tmpfile;