Parse an HTTP request message into an associative array of parts.
string $message HTTP request to parse:
array|bool Returns false if the message is invalid
Overrides MessageParserInterface::parseRequest
public function parseRequest($message) {
if (!$message) {
return false;
}
$parts = $this
->parseMessage($message);
// Parse the protocol and protocol version
if (isset($parts['start_line'][2])) {
$startParts = explode('/', $parts['start_line'][2]);
$protocol = strtoupper($startParts[0]);
$version = isset($startParts[1]) ? $startParts[1] : '1.1';
}
else {
$protocol = 'HTTP';
$version = '1.1';
}
$parsed = array(
'method' => strtoupper($parts['start_line'][0]),
'protocol' => $protocol,
'version' => $version,
'headers' => $parts['headers'],
'body' => $parts['body'],
);
$parsed['request_url'] = $this
->getUrlPartsFromMessage($parts['start_line'][1], $parsed);
return $parsed;
}