Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HttpFoundation] Add headers arg to RedirectResponse
- Loading branch information
Showing
1 changed file
with
5 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 @@ 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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Seldaek
Author
Member
|
||
); | ||
|
||
if (!$this->isRedirect()) { | ||
|
should it be the othe way around ?