[mod_python] Making an absolute URL

Mike Looijmans mike.looijmans at asml.com
Thu Aug 21 11:06:09 EST 2003


As usual, there are many ways that lead to the same point.

I'm sending a 302 or 303 response to some queries to quickly redirect the
client to the 'next' page (for example after logging in is successful it
immediately proceeds to the 'calling' page by sending a "303 See Other").

I did this previously with a Refresh header, but that doesn't work in Lynx
for example, it "flashes" the screen, and the 303 was specifically meant for
this purpose.

Only trouble now is that the "Location" header in a 30x response must be an
absolute URL instead of a relative one. If I just supply a relative URL, the
browsers grudgingly accept it, but it's just not right. So if the user
request http://myhost:8080/foo/ i send a redirection to
http://myhost:8080/foo/bar by returning 302 (moved permanently) and add a
header "Location: bar". But accoring to HTTP spec (RFC2068), the location
header should be "Location: http://myhost:8080/foo/bar" instead.

It should be easy to turn the URL into an absolute one. However, there are
many ways to do this, and I wonder what is the one that will work for all
client and server configurations.

For example, i want the URL to remain as the user typed it, so that there's
a difference between using http://localhost/foo/bar or
http://localhost:80/foo/bar, between http://myhost.mydomain.com/ and
http://myhost/ etc, etc.

Probably, the "Host" header from the client is a good thing for this, but it
is only mandatory for HTTP/1.1 and not for 1.0 which many browsers still
use.

Mike.





-- 
The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt.




More information about the Mod_python mailing list