8000 Ignore invalid HTTP headers when creating PSR7 objects · symfony/symfony@9a78a16 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a78a16

Browse files
Ignore invalid HTTP headers when creating PSR7 objects
1 parent bdb2871 commit 9a78a16

File tree

5 files changed

+229
-237
lines changed

5 files changed

+229
-237
lines changed

Factory/PsrHttpFactory.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ public function createRequest(Request $symfonyRequest)
5858
);
5959

6060
foreach ($symfonyRequest->headers->all() as $name => $value) {
61-
$request = $request->withHeader($name, $value);
61+
try {
62+
$request = $request->withHeader($name, $value);
63+
} catch (\InvalidArgumentException $e) {
64+
// ignore invalid header
65+
}
6266
}
6367

6468
$body = $this->streamFactory->createStreamFromResource($symfonyRequest->getContent(true));
@@ -160,7 +164,11 @@ public function createResponse(Response $symfonyResponse)
160164
}
161165

162166
foreach ($headers as $name => $value) {
163-
$response = $response->withHeader($name, $value);
167+
try {
168+
$response = $response->withHeader($name, $value);
169+
} catch (\InvalidArgumentException $e) {
170+
// ignore invalid header
171+
}
164172
}
165173

166174
$protocolVersion = $symfonyResponse->getProtocolVersion();

Tests/Factory/AbstractHttpMessageFactoryTest.php

Lines changed: 0 additions & 234 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0