8000 [HttpFoundation] Add headers arg to RedirectResponse · symfony/symfony@1c86ad7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c86ad7

Browse files
committed
[HttpFoundation] Add headers arg to RedirectResponse
1 parent 873da43 commit 1c86ad7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Symfony/Component/HttpFoundation/RedirectResponse.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ class RedirectResponse extends Response
2525
/**
2626
* Creates a redirect response so that it conforms to the rules defined for a redirect status code.
2727
*
28-
* @param string $url The URL to redirect to
29-
* @param integer $status The status code (302 by default)
28+
* @param string $url The URL to redirect to
29+
* @param integer $status The status code (302 by default)
30+
* @param array $headers The headers (Location is added with the given url)
3031
*
3132
* @see http://tools.ietf.org/html/rfc2616#section-10.3
3233
*
3334
* @api
3435
*/
35-
public function __construct($url, $status = 302)
36+
public function __construct($url, $status = 302, $headers = array())
3637
{
3738
if (empty($url)) {
3839
throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
@@ -54,7 +55,7 @@ public function __construct($url, $status = 302)
5455
</body>
5556
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')),
5657
$status,
57-
array('Location' => $url)
58+
array_merge(array('Location' => $url), $headers)
5859
);
5960

6061
if (!$this->isRedirect()) {

0 commit comments

Comments
 (0)
0