-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #53733 [HttpFoundation] Prevent duplicated headers when using Ear…
…ly Hints (dunglas) This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [HttpFoundation] Prevent duplicated headers when using Early Hints | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | n/a | License | MIT Currently, headers are being duplicated in the final response if a 103 response has previously been sent. This patch fixes the issue. Before: ``` < HTTP/2 103 < alt-svc: h3=":443"; ma=2592000 < cache-control: no-cache, private < date: Fri, 02 Feb 2024 15:21:00 GMT < link: </style.css>; rel=preload; as=style < server: Caddy < x-powered-by: PHP/8.3.1 < HTTP/2 200 < cache-control: no-cache, private < cache-control: no-cache, private < content-type: text/html; charset=UTF-8 < date: Fri, 02 Feb 2024 15:21:00 GMT < date: Fri, 02 Feb 2024 15:21:00 GMT < link: </style.css>; rel=preload; as=style < link: </style.css>; rel=preload; as=style ``` Commits ------- ca5db79 [HttpFoundation] Prevent duplicated headers when using Early Hints
- Loading branch information
Showing
4 changed files
with
79 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
31 changes: 31 additions & 0 deletions
31
src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/early_hints.php
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