function parse_request in Lockr 7.3
Parses a request message string into a request object.
Parameters
string $message Request message string.:
Return value
File
- vendor/
guzzlehttp/ psr7/ src/ functions.php, line 467
Namespace
GuzzleHttp\Psr7Code
function parse_request($message) {
$data = _parse_message($message);
$matches = [];
if (!preg_match('/^[\\S]+\\s+([a-zA-Z]+:\\/\\/|\\/).*/', $data['start-line'], $matches)) {
throw new \InvalidArgumentException('Invalid request string');
}
$parts = explode(' ', $data['start-line'], 3);
$version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1';
$request = new Request($parts[0], $matches[1] === '/' ? _parse_request_uri($parts[1], $data['headers']) : $parts[1], $data['headers'], $data['body'], $version);
return $matches[1] === '/' ? $request : $request
->withRequestTarget($parts[1]);
}