Skip to content

Commit

Permalink
[HttpFoundation] Add headers arg to RedirectResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Mar 15, 2012
1 parent 873da43 commit 1c86ad7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Symfony/Component/HttpFoundation/RedirectResponse.php
Expand Up @@ -25,14 +25,15 @@ class RedirectResponse extends Response
/**
* Creates a redirect response so that it conforms to the rules defined for a redirect status code.
*
* @param string $url The URL to redirect to
* @param integer $status The status code (302 by default)
* @param string $url The URL to redirect to
* @param integer $status The status code (302 by default)
* @param array $headers The headers (Location is added with the given url)
*
* @see http://tools.ietf.org/html/rfc2616#section-10.3
*
* @api
*/
public function __construct($url, $status = 302)
public function __construct($url, $status = 302, $headers = array())
{
if (empty($url)) {
throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
Expand All @@ -54,7 +55,7 @@ public function __construct($url, $status = 302)
</body>
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')),
$status,
array('Location' => $url)
array_merge(array('Location' => $url), $headers)

This comment has been minimized.

Copy link
@vicb

vicb Mar 15, 2012

Contributor

should it be the othe way around ?

This comment has been minimized.

Copy link
@henrikbjorn

henrikbjorn Mar 15, 2012

Contributor

Yes it should

This comment has been minimized.

Copy link
@Seldaek

Seldaek Mar 15, 2012

Author Member

You can argue either way.. But in any case if you use a Redirect and ovrride the location you're doing something stupid. If you want I reverse it.

This comment has been minimized.

Copy link
@vicb

vicb Mar 15, 2012

Contributor

That would be true if the html gets updated, it's not. Please reverse.

This comment has been minimized.

Copy link
@Seldaek

Seldaek Mar 15, 2012

Author Member

See #3606

This comment has been minimized.

Copy link
@vicb

vicb Mar 15, 2012

Contributor

great !

);

if (!$this->isRedirect()) {
Expand Down

0 comments on commit 1c86ad7

Please sign in to comment.