-
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HttpFoundation] Prevent duplicated headers when using Early Hints
- Loading branch information
1 parent
d68e699
commit ebc713b
Showing
3 changed files
with
69 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
// Requires FrankenPHP | ||
|
||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
$parent = __DIR__; | ||
while (!@file_exists($parent.'/vendor/autoload.php')) { | ||
if (!@file_exists($parent)) { | ||
// open_basedir restriction in effect | ||
break; | ||
} | ||
if ($parent === dirname($parent)) { | ||
echo "vendor/autoload.php not found\n"; | ||
exit(1); | ||
} | ||
|
||
$parent = dirname($parent); | ||
} | ||
|
||
require $parent.'/vendor/autoload.php'; | ||
|
||
$r = new Response(); | ||
$r->headers->set('Link', '</css/style.css>; rel="preload"; as="style"'); | ||
$r->sendHeaders(103); | ||
|
||
$r->headers->set('Link', '</js/app.js>; rel="preload"; as="script"', false); | ||
$r->sendHeaders(103); | ||
|
||
$r->setContent('Hello, Early Hints'); | ||
$r->send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters