Skip to content

Commit

Permalink
Small simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Mar 17, 2016
1 parent dcad567 commit c3cc4b4
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/ServerRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,18 @@ public static function marshalHeaders(array $server)
{
$headers = [];
foreach ($server as $key => $value) {
if ($value && strpos($key, 'HTTP_') === 0) {
$name = strtr(substr($key, 5), '_', ' ');
$name = strtr(ucwords(strtolower($name)), ' ', '-');
$name = strtolower($name);

$headers[$name] = $value;
continue;
}

if ($value && strpos($key, 'CONTENT_') === 0) {
$name = substr($key, 8); // Content-
$name = 'Content-' . (($name == 'MD5') ? $name : ucfirst(strtolower($name)));
$name = strtolower($name);
$headers[$name] = $value;
continue;
if ($value) {
if (strpos($key, 'HTTP_') === 0) {
$name = substr($key, 5);
$name = strtr($name, '_', '-');
$name = strtolower($name);
$headers[$name] = $value;
} elseif (strpos($key, 'CONTENT_') === 0) {
$name = $key;
$name = strtr($name, '_', '-');
$name = strtolower($name);
$headers[$name] = $value;
}
}
}

Expand Down

0 comments on commit c3cc4b4

Please sign in to comment.