Skip to content

Commit 1ac726f

Browse files
authored
Merge pull request #77 from blubolt/decorate-with-redirect
Decorate responses created by withRedirect helper
2 parents fcd422c + ad36d82 commit 1ac726f

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/Response.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,17 +364,18 @@ public function withJson($data, int $status = null, int $options = 0, int $depth
364364
*
365365
* @param string $url The redirect destination.
366366
* @param int|null $status The redirect HTTP status code.
367-
* @return ResponseInterface
367+
* @return Response
368368
*/
369369
public function withRedirect(string $url, $status = null): ResponseInterface
370370
{
371371
$response = $this->response->withHeader('Location', $url);
372372

373-
if (!is_null($status)) {
374-
return $response->withStatus($status);
373+
if ($status === null) {
374+
$status = 302;
375375
}
376+
$response = $response->withStatus($status);
376377

377-
return $response->withStatus(302);
378+
return new Response($response, $this->streamFactory);
378379
}
379380

380381
/**

0 commit comments

Comments
 (0)