Hi,

Since I got Fabien on record saying that redirect() is part of the view [1] 
"<fabpot>   redirects are part of the View"

I totally agree and we have already seen that its kind of problematic for 
controllers that want to support multiple output formats, that they have to add 
logic into the controller to handle the different output format cases, using a 
redirect in a few (actually one) cases.

I wanted to discuss how to proceed here. Right now we have a setRedirect() 
method in the Reponse class:

    public function setRedirect($url, $status = 302)
    {
        if (empty($url)) {
            throw new \InvalidArgumentException('Cannot redirect to an empty 
URL.');
        }

        $this->setStatusCode($status);
        if (!$this->isRedirect()) {
            throw new \InvalidArgumentException(sprintf('The HTTP status code 
is not a redirect ("%s" given).', $status));
        }

        $this->headers->set('Location', $url);
        $this->setContent(sprintf('<html><head><meta http-equiv="refresh" 
content="1;url=%s"/></head></html>', htmlspecialchars($url, ENT_QUOTES)));
    }

Interestingly the redirect will be modified via a listener by the web debug 
toolbar:
        if ($response->headers->has('X-Debug-Token') && $response->isRedirect() 
&& $this->interceptRedirects) {
            $r = new Response();
            $r->setContent(
                sprintf('<html><head></head><body><h1>This Request redirects 
to<br /><a href="%s">%s</a>.</h1></body></html>',
                $response->headers->get('location'), 
$response->headers->get('location'))
            );
            $r->headers->set('X-Debug-Token', 
$response->headers->get('X-Debug-Token'));

            $response = $r;
        }

regards,
Lukas Kahwe Smith
[email protected]

[1] http://trac.symfony-project.org/wiki/IRCLogs20101111

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" 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/symfony-devs?hl=en

Reply via email to