Re: test of new Location header usage

lilley (lilley@afs.mcc.ac.uk)
Wed, 9 Aug 1995 11:57:56 +0100 (BST)


Shel Kaphan said:
>
> Given the new use of the Location header in the HTTP spec, I would be curious
> what happens when you run the following test on your servers. Especially NCSA
> and CERN. Put this in your cgi-bin directory:
>
> #!/bin/sh
> echo "Status:200"
> echo "Location: http://www.yoursite.com/loser.html"
> echo
> echo "<html>"
> echo "<h1>this is only a text</h1>"
> echo "</html>"

I presume your intent by outputting Status:200 is to generate a header? But
the headers are generated by the server, not the script.

Also, you do not output a Content-type which is generally an error; in this
particular case however the Location line is treated specially by the CGI
environment and indeed is the only part of your output to be sent to the client.

If you really wanted to generate your own headers, the script would have to
be called nph-foo.

Since you asked what the NCSA and CERN servers do (an thus presumably cannot test
this for yourself) here are the results.

============ start trace ==========
cguhpc [50]: ll foo
-rwxr-xr-x 1 lilley users 149 Aug 9 11:48 foo
cguhpc [51]: telnet info 80
Trying...
Connected to info.mcc.ac.uk.
Escape character is '^]'.
GET /cgi-bin/foo HTTP/1.0

HTTP/1.0 302 Found
Date: Wednesday, 09-Aug-95 10:49:10 GMT
Server: NCSA/1.3
MIME-version: 1.0
Location: http://www.yoursite.com/loser.html
Content-type: text/html

<HEAD><TITLE>Document moved</TITLE></HEAD>
<BODY><H1>Document moved</H1>
This document has moved <A HREF="http://www.yoursite.com/loser.html">here</A>.<P
>
</BODY>
Connection closed by foreign host.
cguhpc [52]: mv foo ~/web/cern/cgi-bin
cguhpc [53]: telnet info 8080
Trying...
Connected to info.mcc.ac.uk.
Escape character is '^]'.
GET /cgi-bin/foo HTTP/1.0

HTTP/1.0 302 Found
MIME-Version: 1.0
Server: CERN/3.0pre6
Date: Wednesday, 09-Aug-95 10:49:53 GMT
Location: http://www.yoursite.com/loser.html
Content-Type: text/html
Content-Length: 393

Redirection

Redirection

This document can be found elsewhere.

You see this message because your browser doesn't support automatic redirection handeling.


CERN httpd 3.0pre6
Connection closed by foreign host.
============= end trace ========

> What response header do you get? (Would expect either 200 if it
> works, or 302 if it doesn't).

You get a 302 because you output the special string Location:

-- 
Chris Lilley, Technical Author
+-------------------------------------------------------------------+
|       Manchester and North HPC Training & Education Centre        |
+-------------------------------------------------------------------+
| Computer Graphics Unit,             Email: Chris.Lilley@mcc.ac.uk |
| Manchester Computing Centre,        Voice: +44 161 275 6045       |
| Oxford Road, Manchester, UK.          Fax: +44 161 275 6040       |
| M13 9PL                            BioMOO: ChrisL                 |
|     URI: http://info.mcc.ac.uk/CGU/staff/lilley/lilley.html       | 
+-------------------------------------------------------------------+