[mod_python] Returning a Apache return code

Nick nick at dd.revealed.net
Tue Nov 30 12:39:33 EST 2004


Note that you should almost always use 307 (moved temporarily) for a web 
application, because 301 tells the client to always go to the new location 
when the URL is requested without even asking for the original page.  I.e., 
the page has moved permanently, don't look here anymore.

Nick

Jorey Bump wrote:
> Golawala, Moiz M (GE Infrastructure) wrote:
> 
>> I have am newbie and I seems to be having a problem return a
>> different apache return code. In my httpd.conf file I am using
>> PythonHandler mod_python.publisher.
>>
>> In my index.py file.
>>
>> index(req): req.header_out['Location'] = "http://someurl:8080/ 
> 
>  > return apache.HTTP_PERMANENTLY_MOVED
> 
> Try this:
> 
> from mod_python import apache
> 
> index(req)
>     status = apache.HTTP_MOVED_PERMANENTLY
>     req.headers_out['Location'] = url
>     req.status = status
>     raise apache.SERVER_RETURN, status
> 
> More info:
> 
>  http://www.modpython.org/live/current/doc-html/pyapi-handler.html
> 
>> my problem is that this returns:
>>
>> HTTP/1.1 200 OK Date: Tue, 30 Nov 2004 01:12:06 GMT Server:
>> Apache/2.0.49 (Fedora) Location:  "http://someurl:8080/" Connection:
>> close Transfer-Encoding: chunked Content-Type: text/html;
>> charset=UTF-8
>>
>> 3 301 0
>>
>>
>> I would like to return HTTP/1.1 301.. instead of HTTP/1.1 200 OK.
>>
>> For some reason anything that the method return the publisher handler
>> puts it in the body of the request I cannot return a different return
>> code other than the default apache.OK
>>
>> Could some one please help me with this.
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list