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

I am using Activestate perl on XP Pro with IIS 5 using Perlis.dll.

A perl script as simple as :

print "Location: http://www.microsoft.com\n\n";

prints on my screen, instead of forcing forwarding. This is because I am getting a "Content-Type: text/html; charset=ISO-8859-1 \n\n" line before it.
Here is a more monkish program and it's results:
use strict; use CGI; my $page = new CGI; my $msg = "Hello from ActivePerl CGI!"; # print header and start the markup output print $page->header( "text/html" ), $page->start_html( $msg ); print $page->h2($msg); print $page->end_html; # end code
This prints:
Content-Type: text/html; charset=ISO-8859-1
Hello from ActivePerl CGI!

Needless to say, this stops cookies from working (they print instead), and so on. I have deleted IIS, reinstalled it and reinstalled perl, and it still does this annoying brain dead thing.

It all started when I deleted and reset the IIS configuration setting. There doesn't seem to be any setting I can find anywhere in IIS that causes or affects this, though it obviously started then. Searching around the net, I located some comments about a registry setting in Activestate that always prints headers, but the keys doesn't exist, and if I create them, it does nothing.

Any ideas?
fred.b@mitsi.com

Replies are listed 'Best First'.
Re: Activestate on IIS 5
by beachbum (Beadle) on Jan 31, 2006 at 18:47 UTC

    A quick super search for "Content-Type:" returned several results; 521635, specifically abcde's response, may contain what you're looking for.

    update: The basic idea of the linked node is that the header may be already written by IIS causing your header to be a duplicate./update

    You could test this using telnet to connect to your webserver to view the headers:

    telnet localhost 80 GET /
Re: Activestate on IIS 5
by Discipulus (Canon) on Feb 01, 2006 at 09:13 UTC
    hello
    may be I'm wrong but, is not for this reason i put
    use CGI qw /:standard -nph/;

    at the top of my CGI?
    -nph stands for non parsed headers, I never well understood it but it works fine on IIS5 and IIS6.

    Lorenzo
Re: Activestate on IIS 5
by twobucks (Initiate) on Jan 31, 2006 at 19:30 UTC
    I've looked thru those suggestions before - they don't actually show a solution for 521635's problem, which is basically the same as mine.
    I had this problem once before on XP, and it went away when I removed perl and IIS, then reinstalled everything from scratch. That doesn't seem to work on this machine.
    A file with just print "Location: http://www.mitsi.com\n\n"; should print standard HTTP headers, then the Location line, then two new lines. If two blank lines come first, it won't forward the browser.

    Here is what happens when viewed via telnet on port 80:

    HTTP/1.0 302 Moved Temporarily Date: Tue, 31 Jan 2006 19:17:55 GMT Server: Microsoft-IIS/5.1 Location: http://www.mitsi.com

    Note the extra blank line between Server and Location: this is not correct, and I can't figure out what it takes to stop it.

    =======================================
    More info follows:
    It's definately perlis.dll doing it. When I run the scripts with perl.exe %s %s, it runs okay. So somehow perlis.dll from activestate is broken. Unfortunately, this doesn't help me, I have to run in perlis.dll for performance reasons and to install soem services. If I install them with the command line perl, it breaks things.
    <still making rummaging noises>
    =======================================