[mod_python] How to make 307 Temporary Redirect using mod_python ?

Mateusz Korniak mateusz at ant.gliwice.pl
Wed Jul 3 00:57:10 EST 2002


I can't make temporary redirect using mod_python.

I tried code:

def handler(req):
	# some code genereting url - where to redirect
	req.headers_out["Location"] = url
	req.send_http_header()
	return apache.HTTP_TEMPORARY_REDIRECT

but it produces such (not as intended) HTTP talk:

browser:
GET /abbon/advsel/advsel.py?a=1;u=388 HTTP/1.1
Connection: Keep-Alive
User-Agent: Mozilla/5.0 (compatible; Konqueror/2.2-11; Linux)
Pragma: no-cache
Cache-control: no-cache
Accept: text/*, image/jpeg, image/png, image/*, */*
Accept-Encoding: x-gzip, gzip, identity
Accept-Charset: iso-8859-2, utf-8, *
Accept-Language: en_GB, pl_PL, en
Host: appserver.ant.cipe
Cookie: SES=1

server response:
HTTP/1.1 200 OK
Date: Tue, 02 Jul 2002 21:14:01 GMT
Server: Apache/1.3.23 (Unix)  (Red-Hat/Linux) mod_python/2.7.8 Python/1.5.2
Location: http://www.noblisci.bnet.pl
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain

21c
HTTP/1.1 200 OK
Date: Tue, 02 Jul 2002 21:14:01 GMT
Server: Apache/1.3.23 (Unix)  (Red-Hat/Linux) mod_python/2.7.8 Python/1.5.2
Location: http://www.noblisci.bnet.pl
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>200 OK</TITLE>
</HEAD><BODY>
<H1>OK</H1>
The document has moved <A HREF="http://www.noblisci.bnet.pl">here</A>.<P>
<HR>
<ADDRESS>Apache/1.3.23 Server at appserver.ant.cipe Port 80</ADDRESS>
</BODY></HTML>


Server returns HTTP/1.1 200 OK instead of 307 <whatever> ...
What I'm doing wrong ?
TIA for any help.

-- 
Mateusz Korniak




More information about the Mod_python mailing list