[HttpFoundation] Add headers arg to RedirectResponse

This commit is contained in:
Jordi Boggiano 2012-03-15 16:27:52 +01:00
parent 873da434cd
commit 1c86ad78ee

View File

@ -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.');
@ -54,7 +55,7 @@ class RedirectResponse extends Response
</body>
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')),
$status,
array('Location' => $url)
array_merge(array('Location' => $url), $headers)
);
if (!$this->isRedirect()) {