- # I do not understand why this is necessary.
- $ENV{DEBBUGS_CONFIG_FILE} = "$config{config_dir}/debbugs_config";
- my $content = qx(perl -I. -T cgi/bugreport.cgi);
- $content =~ s/^\s*Content-Type:[^\n]+\n*//si;
- print $content;
+ # I do not understand why this is necessary.
+ $ENV{DEBBUGS_CONFIG_FILE} = "$config{config_dir}/debbugs_config";
+ my $fh;
+ open($fh,'-|',-e './cgi/version.cgi'? 'perl -Ilib -T ./cgi/bugreport.cgi' : 'perl -Ilib -T ../cgi/bugreport.cgi');
+ my $headers;
+ my $status = 200;
+ while (<$fh>) {
+ if (/^\s*$/ and $status) {
+ print "HTTP/1.1 $status OK\n";
+ print $headers;
+ $status = 0;
+ print $_;
+ } elsif ($status) {
+ $headers .= $_;
+ if (/^Status:\s*(\d+)/i) {
+ $status = $1;
+ }
+ } else {
+ print $_;
+ }
+ }