Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Why would you want to print duplicate headers?

by scottstef (Curate)
on Sep 28, 2001 at 00:56 UTC ( #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

"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
      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 does that are better for backwards compatability than actual saftey.

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

      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?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2022-09-29 20:07 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (125 votes). Check out past polls.