diff --git a/src/Illuminate/Http/Request.php b/src/Illuminate/Http/Request.php index 251bb2c7c940..1a36ec2d0f1e 100644 --- a/src/Illuminate/Http/Request.php +++ b/src/Illuminate/Http/Request.php @@ -297,7 +297,8 @@ public function pjax() public function prefetch() { return strcasecmp($this->server->get('HTTP_X_MOZ') ?? '', 'prefetch') === 0 || - strcasecmp($this->headers->get('Purpose') ?? '', 'prefetch') === 0; + strcasecmp($this->headers->get('Purpose') ?? '', 'prefetch') === 0 || + strcasecmp($this->headers->get('Sec-Purpose') ?? '', 'prefetch') === 0; } /** diff --git a/tests/Http/HttpRequestTest.php b/tests/Http/HttpRequestTest.php index 124f0bdbd33a..75a0cf5571af 100644 --- a/tests/Http/HttpRequestTest.php +++ b/tests/Http/HttpRequestTest.php @@ -254,6 +254,15 @@ public function testPrefetchMethod() $this->assertTrue($request->prefetch()); $request->headers->set('Purpose', 'Prefetch'); $this->assertTrue($request->prefetch()); + + $request->headers->remove('Purpose'); + + $request->headers->set('Sec-Purpose', ''); + $this->assertFalse($request->prefetch()); + $request->headers->set('Sec-Purpose', 'prefetch'); + $this->assertTrue($request->prefetch()); + $request->headers->set('Sec-Purpose', 'Prefetch'); + $this->assertTrue($request->prefetch()); } public function testPjaxMethod()