http://qs321.pair.com?node_id=561808

willyyam has asked for the wisdom of the Perl Monks concerning the following question:

I am attempting to get DC-Dot to run on a Windows 2003 Server, so that I can run it on the pages of the corporate Intranet. However, I am running into challenges that I don't know enough about with respect to CGI scripts on Windows.

Here are the technical details:

There error I'm getting is this:

CGI Error The specified CGI application misbehaved by not returning a complete s +et of HTTP headers.

I've tried adding a

HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8
line to the output, but no joy.

Do any esteemed Monks have any experience with porting *nix-oriented web Perl scripts to Windows? Thanks.

Replies are listed 'Best First'.
Re: Porting DC-Dot to Windows
by Ieronim (Friar) on Jul 17, 2006 at 20:00 UTC
    Try to leave only
    print "Content-Type: text/html; charset=UTF-8\n\n";
    before the actual output. The HTTP headers are sent by the webserver itself.

    UPD:
    If this does not help, try the following script:

    print "Content-Type: text/plain; charset=UTF-8\n\n"; print "Hello, world!\n";
    and describe what happens. Of course you may need to add a proper shebang line to the top of your script.


         s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print

      The first suggestion, to leave off the HTTP response header, didn't change my result.

      The second suggestion provides meaningful feedback though. I built the Hello World script as you suggested, and it would not execute with the name "test.pl" - I got the same error as before. However, when I changed the extension to cgi, I got a web page with the content "Hello, world!", which is very exciting. I changed the extention of dcdot.pl to dcdot.cgi, but I get the same error. I cleared the cache and tried again, in case, but still not joy. Still, this confirms that I have IIS configured to interpret Perl scripts, which is a good first step.

        1. Your script can die from an unexpected error. Try CGI::Carp qw(fatalsToBrowser).
        2. Your script can generate warnings before the headers are printed. Some webservers break the execution of the script in this case.
        3. Check the output of your script again! Content/type... must be the first line it prints.

             s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print
Re: Porting DC-Dot to Windows
by NetWallah (Canon) on Jul 17, 2006 at 19:59 UTC
    There are several possible causes of this error, a few of which are documented at this site. Here are some things to look for:
    • Verify your virtual directory. The CGI script may expect to be running in a directory and Windows may run it in a different one.
    • Make sure you have 2 sets of CRLF (\n) after the headers
    • Windows is not rfc2616 compliant.(Some PHP settings compensate for this)

         "For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken

Re: Porting DC-Dot to Windows
by Anonymous Monk on Jul 18, 2006 at 07:54 UTC