Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

How can I remove HTTP Header

by TwitchyEye (Initiate)
on Oct 19, 2002 at 23:33 UTC ( #206583=perlquestion: print w/ replies, xml ) Need Help??
TwitchyEye has asked for the wisdom of the Perl Monks concerning the following question:

I just changed servers. My new server prints out HTTP headers when ever a perl script is run.

This info is printed before the text from the perl script:

HTTP/1.1 200 OK Date: Sat, 19 Oct 2002 15:41:59 GMT Server: Microsoft-IIS/5.0 Content-type: text/html

My scripts look like this: #!/usr/bin/perl

print "Content-Type: text/html\n\n"; # output http header ## etc..

Even if I remove the content-type line I still get the header. Is this a problem with the server settings or do I need to add something else to my perl script??

Comment on How can I remove HTTP Header
Replies are listed 'Best First'.
Re: How can I remove HTTP Header
by Aristotle (Chancellor) on Oct 20, 2002 at 02:14 UTC
    It seems you have to add your own HTTP request status, or IIS will generate its own headers and treat yours as text. Try print "HTTP/1.0 200 OK\nContent-Type: text/html\n\n";
    Note I'm just concluding from a bit of googling. I had seen something about header handling being broken on IIS in various CGI scripts, but I haven't ever actually dealt with that problem, so YMMV.

    Makeshifts last the longest.

      That's a bit better. It printed out less text. It only printed out that specific information:
      HTTP/1.1 200 OK Content-Type: text/html
      instead of :
      HTTP/1.1 200 OK Date: Sun, 20 Oct 2002 17:54:06 GMT Server: Microsoft-IIS/5.0 Content-type: text/html
        Here's the fix. It is a problem with the server settings. Here is how to fix the settings: http://perl.xotechnologies.net/tutorials/SSI/SSI.htm
        Basically you must associate perl.exe with SSI instead of PerlIS.dll otherwise the HTTP header will show up in your browser
        Thanks for all the help.
        TE
Re: How can I remove HTTP Header
by fruiture (Curate) on Oct 19, 2002 at 23:40 UTC
    Is this a problem with the server settings or do I need to add something else to my perl script?

    Yes, it is a problem with the server settings, the server should not dictate your Content-type header. Check http://w3.org/CGI.

    P.S.: consider using code tags in the future ;)

    --
    http://fruiture.de
Re: How can I remove HTTP Header
by nothingmuch (Priest) on Oct 19, 2002 at 23:41 UTC
    Perhaps the server is ignoring your header because it does not end with CRLFs.

    use Socket qw(:crlf); print "Content-Type: text/html$CRLF$CRLF";
    may help. If not, then it must be a server configuration.

    Update: code tag fixed. sorry!

    -nuffin
    zz zZ Z Z #!perl
      Thanks for the suggestion. I tried it but the header is still being printed before my document information.
      Twitchy Eye

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://206583]
Approved by tadman
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2015-07-30 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls