> The http_header() is a straw man intended to demonstrate that there
> are issues with shoving all of the outgoing HTTP headers into a simple
> variable. Not insoluable problems, but problems.
Agreed.
> I do like the idea of stacking HTTP headers and queueing them up
> before the first print statement, where that print is a little
> more magical than every subsequent print. I'd imagine that if the
> HTTP headers were blank, it would Do The Right Thing (tm) and emit
> a "Content-type: text/html\n\n", before replacing itself with the
> standard print builtin.
Don't get me wrong, I like this idea too.
> And if HTTP headers are segregated from document content, it's
> easier to determine when the headers are finished and when the
> content starts. That aids in determining when '\n\n' is appropriate.
Yes.
> Robust input parsing: yes.
>
> General purpose output formatting: no, nyet, nein, non, "over my dead body".
I'm guessing you mean "nyet" to "general purpose formatting *only*". :-)
After sending that last email, I was sitting here drinking a beer, and
it occured to me that tons of headers all the use same format
Tag-With-Hyphens: unspecified value of some type
This is true for HTTP, Mail, and lots of other applications.
Maybe what we need is a general "headers()" function, which could
produce a stack of these headers, something like:
@http_headers = headers(content-type => 'text/html',
last-modified => $date);
@mail_headers = headers(from => '[EMAIL PROTECTED]',
to => '[EMAIL PROTECTED]');
This function could always be present in Perl. I could see *lots* of
uses for such a function. Then, perhaps the "use cgi" pragma could
simply alter the semantics of this builtin to stack the headers given to
it by the headers() function and auto-output them on print.
That way, we're changing the semantics of headers(), not importing it.
Just like 'use tristate' changes the semantics of undef() without
importing a new function. And 'headers()' makes just as much sense as
having 'quotemeta()' in core - there's many potential uses for it.
How's something like that sound?
-Nate