> On Jan 14, 2004, at 3:25 AM, Jan Eden wrote:
> 
> > Hi,
> >
> > like this:
> >
> > #!/usr/bin/perl -w
> >
> > use strict;
> > use CGI;
> > use CGI::Carp qw(fatalsToBrowser);
> >
> > my $q = new CGI;
> >
> > print $q->header
> > # do this - do that, using $q
> >
> > print $q->redirect("/thanks.html");
> 
> Unfortunately, this doesn't work.  As Randal already said, it's not 
> possible to do both.  You either print a page, or redirect to another 
> page.  Here's a quote from CGI.pm POD:
> 
>            print $query->redirect('http://somewhere.else/in/movie/land');
> 
>         Sometimes you don't want to produce a document yourself, but 
> simply
>         redirect the browser elsewhere, perhaps choosing a URL based on 
> the
>         time of day or the identity of the user.
> 
>         The redirect() function redirects the browser to a different 
> URL.  If
>         you use redirection like this, you should not print out a header 
> as
>         well.
> 
> Hope that helps.
> 
> James

While this is good documentation and in the end does the right thing,
the part I don't like about it is when it reads:

"You should not print out a header *as well*".

The problem is that, "as well", implies that a header hasn't been
printed, but the fact is that the redirect is a header, or more
precisely is a line of the overall header, and one that specifically (at
least by today's browsers and the HTTP protocol itself) indicates that
there won't be a content type and data coming.  So it isn't that you
can't print multiple headers, but that the client only respects the
first, so you can't print one, have it interpreted, then print another,
and have it interpreted "as well".  The difficult part is that the docs
are written by people who understand the protocol, and back in the day
most developers understood the protocol because HTTP was new and the
client/server model was older so the statement should be obvious (to the
point of not needing it), now days many web developers don't even know
that there is a protocol, let alone anything specific about it, so what
shouldn't need to be there becomes obvious, but the fact that it needs
to be there indicates that there needs to be more description along with
it...

Boy, apparently I am in a rambling mood...

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to