2

i set the content-type to text/xml and want to get a xml file, but the response of the cgi program is a PL file and it forces the browser to open the download dialog. I download the file and open it with a textediter. At the beginning of the file it shows the http header, i think it's strange. Here is the URL of the file: "http://23.23.123.93/watergrid/dma/j796/hydro" Can anyone help me please?

if(defined($result)) {
#imitate nph- cgi for IIS
my $status = defined($ENV{'SERVER_SOFTWARE'}) && $ENV{'SERVER_SOFTWARE'}=~/IIS/ ? $ENV{SERVER_PROTOCOL} || 'HTTP/1.0' : 'Status:';
my $code = $result->code;
binmode(STDOUT);

print STDOUT "$status $code ", HTTP::Status::status_message($code),
"\015\012", $result->headers_as_string, "\015\012", $result->content;}
Juneyee
  • 389
  • 2
  • 6
  • 15
  • 3
    sounds likely to be a problem with your webserver config, not your script. can you get a simple script `print "Content-type: text/plain\n\nhello, world!\n` to work? – ysth Jul 16 '12 at 03:07
  • What's the least amount of code you could post that would exhibit the same behavior? If you make a simple "Hello World!" CGI script, do you still see the same problem? – DavidO Jul 16 '12 at 05:44
  • You have to configure the web server (what are you using?) to execute CGI at this path. In general, the common way is to place your cgi at cgi-bin folder – Miguel Prz Jul 16 '12 at 06:28
  • 1
    From the [Stack Overflow Perl FAQ](http://stackoverflow.com/questions/tagged/perl?sort=faq): [How can I troubleshoot my Perl CGI script?](http://stackoverflow.com/questions/2165022/how-can-i-troubleshoot-my-perl-cgi-script) – daxim Jul 16 '12 at 07:01
  • I use apache server and the print "Content-type: text/plain\n\nhello, world!\n" can work well. – Juneyee Jul 16 '12 at 11:13

1 Answers1

1

You have an " o Retrieving network data" string before headers output. So try to search this string in perl sources and remove it.

MajestiC
  • 26
  • 1