protected static function mapRequest(ReactRequest $reactRequest, $content)
{
$method = $reactRequest->getMethod();
$headers = $reactRequest->getHeaders();
$query = $reactRequest->getQuery();
$post = [];
// Parse body?
if (in_array(strtoupper($method), ['POST', 'PUT', 'DELETE', 'PATCH']) && isset($headers['Content-Type']) && 0 === strpos($headers['Content-Type'], 'application/x-www-form-urlencoded')) {
parse_str($content, $post);
}
// Map to a SymfonyRequest
$symfonyRequest = new SymfonyRequest($query, $post, array(), array(), array(), array(), $content);
$symfonyRequest->setMethod($method);
$symfonyRequest->headers->replace($headers);
$symfonyRequest->server->set('REQUEST_URI', $reactRequest->getPath());
if (isset($headers['Host'])) {
$symfonyRequest->server->set('SERVER_NAME', explode(':', $headers['Host'])[0]);
}
return $symfonyRequest;
}