Skip to content

Commit

Permalink
Merge pull request #37 from reactphp/nitpicking
Browse files Browse the repository at this point in the history
Naming, immutable array manipulation
  • Loading branch information
WyriHaximus committed Aug 24, 2015
2 parents b36fb25 + 2ab98d2 commit 7d47a8e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/RequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace React\Http;

use Evenement\EventEmitter;
use GuzzleHttp\Psr7 as g7;
use GuzzleHttp\Psr7 as gPsr;

/**
* @event headers
Expand Down Expand Up @@ -91,20 +91,21 @@ protected function headerSizeExceeded()

public function parseHeaders($data)
{
$psrRequest = g7\parse_request($data);
$psrRequest = gPsr\parse_request($data);

$parsedQuery = [];
$queryString = $psrRequest->getUri()->getQuery();
if ($queryString) {
parse_str($queryString, $parsedQuery);
}

$headers = $psrRequest->getHeaders();
array_walk($headers, function(&$val) {
$headers = array_map(function(&$val) {
if (1 === count($val)) {
$val = $val[0];
}
});

return $val;
}, $psrRequest->getHeaders());

return new Request(
$psrRequest->getMethod(),
Expand Down

0 comments on commit 7d47a8e

Please sign in to comment.