in reply to redirect() vs location

There are three types of headers a CGI script can send to the browser: Mixing and matching those will give you strange results, depending on the web browser.

Solution? Just send the location header, if you want to use it. Send a status code header if you want the browser to display its specific error. Send the content-type header if you're returning data to be displayed.

Update: I checked the relevant RFC for HTTP 1.1, and the status line header is sent before the Content-Type. So disregard that information, as BBQ is correct for HTTP 1.1. (Now I have to make a note about this book. Grr.)

Replies are listed 'Best First'.
RE: Re: redirect() vs location
by BBQ (Curate) on Jun 28, 2000 at 09:07 UTC
    I was lead to beleive that after HTTP 1.1 all requests returned a status code, even if it is just a 200... I would suppose that Location would have a status code of its own, like temporarily redirected, or something of the sort. I can't remember where I heard this so please correct me if this is nonsense.

    #!/home/bbq/bin/perl
    # Trust no1!
      like temporarily redirected
      Yeah, that's 302. The specification is available at W3C's site.

      Slightly unrelated, but I read somewhere that the "Location: http://www.foo.com/" method is almost depracted.

      Rather, "URI: http://www.foo.com/" is the new-style approach that everyone should be using.

      And as far as I know, every HTTP request returns a status code.