Location HTTP Header

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Dec 18 00:47:54 CET 2008


En Wed, 17 Dec 2008 20:52:42 -0200, ptn <tn.pablo at gmail.com> escribió:

> I tried this stupid script on my server:
>
> 	#! /usr/bin/env python
>
> 	print 'Location: http://www.google.com\n'
>
> and it didn't work, I get a blank page.  I first tried the Location
> header in another script, and when execution got to that point, it
> would
> just sort of ignore it, because the script would keep running to the
> end
> of the code (or stop at some unhandled exception).

I assume this is a cgi script. For the Location field to be relevant, the  
Status should be a 3xx (like 307 Temporary Redirect, or 302 Found)
In your case, your server probably has already sent a 200 OK response, so  
Location is ignored.
Try adding a Status line -before Location above- like:
print 'Status: 302 Found"

> Any ideas?

I'd use a different protocol other than CGI...

-- 
Gabriel Genellina




More information about the Python-list mailing list