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

Peter McA'Nulty peter at webreply.com
Tue Jul 2 19:21:37 EST 2002


before you call req.send_http_header(), you have to set the req.status
field:
req.status = HTTP_TEMPORARY_REDIRECT

peter

----- Original Message -----
From: "Mateusz Korniak" <mateusz at ant.gliwice.pl>
To: <mod_python at modpython.org>
Sent: Tuesday, July 02, 2002 6:57 PM
Subject: [mod_python] How to make 307 Temporary Redirect using mod_python ?


> 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
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python
>





More information about the Mod_python mailing list