Skip to content

Commit 9ac2593

Browse files
author
Greg Bowler
authored
tweak: pass request to response to redirect to current path (#173)
1 parent 2cf71d3 commit 9ac2593

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Response.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Response implements ResponseInterface {
1919
public function __construct(
2020
private ?int $statusCode = null,
2121
ResponseHeaders $headers = null,
22+
private ?Request $request = null,
2223
) {
2324
$this->headers = $headers ?? new ResponseHeaders();
2425
$this->stream = new Stream();
@@ -29,7 +30,8 @@ public function setExitCallback(callable $callback):void {
2930
}
3031

3132
public function reload():void {
32-
$this->redirect("./");
33+
$uri = $this->request?->getUri() ?? new Uri();
34+
$this->redirect($uri->withPath("./"));
3335
}
3436

3537
public function redirect(string|UriInterface $uri, int $statusCode = 303):void {

src/Uri.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected function rawurlencodeMatchZero(array $match):string {
152152
protected function filterUserInfo(string $user, string $pass = null):string {
153153
$userInfo = $user;
154154

155-
if(strlen($pass) > 0) {
155+
if(strlen($pass ?? "") > 0) {
156156
$userInfo .= ":";
157157
$userInfo .= $pass;
158158
}

0 commit comments

Comments
 (0)