Skip to content

Commit

Permalink
Add support for Sec-Purpose header (#48925)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanos authored Nov 6, 2023
1 parent ea4198a commit b9266bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Illuminate/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/Http/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b9266bc

Please sign in to comment.