On Sep 2, 5:26 am, Carl Nobile <[email protected]> wrote:
> There is no python API in mod_wsgi like there is in mod_python. WSGI
> is a standardized interface for any type of web application written in
> Python. So the short answer to your question is that you need to
> assemble the correct header. It is the header in the HTTP protocol
> that does this, not something that is sent in your data.
>
> As you can see in the demo below, it is creating its own header and
> passing it to mod_wsgi. You would just set the status to "301 Moved
> Permanently" or any of the 300 group of status codes that you want to
> send. Then, set the Location header to your redirected URI/URL.
>
> Get the RFC-2616 it explains all of this.
>
> def application(environ, start_response):
> status = '200 OK'
> output = "Hello World! (It works.)"
> response_headers = [('Content-Type', 'text/plain'),
> ('Content-Length',
> str(len(output)))]
> start_response(status, response_headers)
> return [output]
>
> -Carl
>
> On Tue, Sep 1, 2009 at 2:59 PM, Joni Töyrylä<[email protected]> wrote:
>
> > How can i do internal redirect in mod_wsgi? Like in mod_python
> > "util.redirect(req,url)".
Part of the reason there is no internal redirect is because of
mod_wsgi daemon mode. Specifically, the daemon mode processes only
handle WSGI requests. Thus, if the internal redirect target actually
mapped to a non WSGI URL it can't be handled. Also, if the target was
a WSGI URL delegated to a different daemon process, or which was
supposed to run in embedded mode context, it again couldn't be
serviced
Using a client side redirect is therefore the only portable way which
will work for any mod_wsgi configuration but also on other WSGI
hosting mechanisms.
That said, in mod_wsgi 3.0, you can use a Location response header
with 200 status where value of location is URI but with 'http://host'
left off, to trigger a sub request evaluated back in context of
original Apache server child process. This can be targeted at any URL
hosted within that virtual host and is akin to a sub request or
internal redirect. This behaviour is the same as how Location/200
works for CGI. This feature will only work though where WSGI
application generating that response is running in daemon mode, it
will not work where WSGI application running in embedded mode.
Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---