Skip to content
Permalink
Browse files

MiddlewareApplication: Prevent content-type header to be sent multipl…

…e times
  • Loading branch information...
mabar authored and f3l1x committed Apr 16, 2019
1 parent f2606e3 commit a7e81c9da403ea7dee47a7ccab162fe7bf4ee841
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/Application/MiddlewareApplication.php
@@ -10,6 +10,10 @@
class MiddlewareApplication extends AbstractApplication
{
private const UNIQUE_HEADERS = [
'content-type',
];
protected function createInitialRequest(): ServerRequestInterface
{
return Psr7ServerRequestFactory::fromGlobal();
@@ -52,8 +56,9 @@ protected function sendHeader(string $name, array $values): void
$name = str_replace('-', ' ', $name);
$name = ucwords($name);
$name = str_replace(' ', '-', $name);
$replace = in_array(strtolower($name), self::UNIQUE_HEADERS, true) ? true : false;
foreach ($values as $value) {
header(sprintf('%s: %s', $name, $value), false);
header(sprintf('%s: %s', $name, $value), $replace);
}
}

0 comments on commit a7e81c9

Please sign in to comment.
You can’t perform that action at this time.