Skip to content

Commit f5bbe1a

Browse files
committed
fix: default redirect code for HEAD/OPTION request
1 parent 6c7dcd3 commit f5bbe1a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

system/HTTP/ResponseTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public function redirect(string $uri, string $method = 'auto', ?int $code = null
516516
isset($_SERVER['SERVER_PROTOCOL'], $_SERVER['REQUEST_METHOD'])
517517
&& $this->getProtocolVersion() >= 1.1
518518
) {
519-
$code = ($_SERVER['REQUEST_METHOD'] !== 'GET')
519+
$code = (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT', 'DELETE'], true))
520520
? 303 // reference: https://en.wikipedia.org/wiki/Post/Redirect/Get
521521
: 307;
522522
}

tests/system/HTTP/ResponseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,10 @@ public function provideForRedirect()
300300
['Apache/2.4.17', 'HTTP/1.1', 'POST', null, 303],
301301
['Apache/2.4.17', 'HTTP/1.1', 'POST', 307, 307],
302302
['Apache/2.4.17', 'HTTP/1.1', 'POST', 302, 302],
303-
['Apache/2.4.17', 'HTTP/1.1', 'HEAD', null, 303],
303+
['Apache/2.4.17', 'HTTP/1.1', 'HEAD', null, 307],
304304
['Apache/2.4.17', 'HTTP/1.1', 'HEAD', 307, 307],
305305
['Apache/2.4.17', 'HTTP/1.1', 'HEAD', 302, 302],
306-
['Apache/2.4.17', 'HTTP/1.1', 'OPTION', null, 303],
306+
['Apache/2.4.17', 'HTTP/1.1', 'OPTION', null, 307],
307307
['Apache/2.4.17', 'HTTP/1.1', 'OPTION', 307, 307],
308308
['Apache/2.4.17', 'HTTP/1.1', 'OPTION', 302, 302],
309309
['Apache/2.4.17', 'HTTP/1.1', 'PUT', null, 303],

0 commit comments

Comments
 (0)