Skip to content

Commit 155a7ae

Browse files
bug #107 Ignore invalid HTTP headers when creating PSR7 objects (nicolas-grekas)
This PR was merged into the 2.1-dev branch. Discussion ---------- Ignore invalid HTTP headers when creating PSR7 objects Fixes e.g. Nyholm/psr7#167 Commits ------- 9a78a16 Ignore invalid HTTP headers when creating PSR7 objects
2 parents bdb2871 + 9a78a16 commit 155a7ae

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy