public function MessageParser::parseRequest

Parse an HTTP request message into an associative array of parts.

Parameters

string $message HTTP request to parse:

Return value

array|bool Returns false if the message is invalid

Overrides MessageParserInterface::parseRequest

File

drupal/core/vendor/guzzle/parser/Guzzle/Parser/Message/MessageParser.php, line 13

Class

MessageParser
Default request and response parser used by Guzzle. Optimized for speed.

Namespace

Guzzle\Parser\Message

Code

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;
}