Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Why would you want to print duplicate headers?

by scottstef (Curate)
on Sep 28, 2001 at 00:56 UTC ( [id://115257]=perlquestion: print w/replies, xml ) Need Help??

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

Reading volume 2 of the rat, on page 177 it talks about setting $CGI:HEADERS_ONCE = 1
I understand this will prevent more than one header from being printed. Why would you want to be able to print more than one header? Would that be useful in troubleshooting? I would think that if that was the only time a check to see what header you were printing, that would be the variable you set rather than the default for CGI.pm.

"The social dynamics of the net are a direct consequence of the fact that nobody has yet developed a Remote Strangulation Protocol." -- Larry Wall

  • Comment on Why would you want to print duplicate headers?

Replies are listed 'Best First'.
Re: Why would you want to print duplicate headers?
by Flame (Deacon) on Sep 28, 2001 at 01:03 UTC
    I have to agree, there is no reason to make it the default. However there are circumstances where one would want to have the ability to print the header more than once. For example, if setting cookies and you don't want to shove them all within the same header statement... I cannot think of any other reaons, and I agree that it should default to HEADERS_ONCE = 1...


    "Wierd things happen, get used to it"

    Flame ~ Lead Programmer: GMS
    http://gms.uoe.org
      I assume that bothering to check that CGI hasn't printed the headers already was added as an option recently, I don't think it use to do this.

      It presumably takes a tiny bit more code and hence time to do the check so not checking may make your scripts a fraction faster - though I doubt you'd notice.

      Secondly if for some strange reason you wanted to print headers several times, and you updated your copy of CGI and this was now the default, you'd be unhappy. So I'd guess that Lincon made it an option, and possibly at some point it will become the default. There are other things that CGI.pm does that are better for backwards compatability than actual saftey.

      There are several things you can do to CGI.pm that are wise but not set by default, see Re: CGI::Safe and easy file uploading and Preventing DOS attacks with CGI.pm.

      Finally, as strange as it seems, sometime it's useful to force your headers twice, so you can quickly see what your headers are, well the second set...

Re: Why would you want to print duplicate headers?
by japhy (Canon) on Sep 28, 2001 at 01:01 UTC
    It stops you from accidentally producing two headers. Like, if you're calling some function that prints the header, and you are calling it yourself, you only want the first call to mean anything.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-19 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found