1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49:
<?php
namespace Guzzle\Parser\Message;
class PeclHttpMessageParser extends AbstractMessageParser
{
public function parseRequest($message)
{
if (!$message) {
return false;
}
$parts = http_parse_message($message);
$parsed = array(
'method' => $parts->requestMethod,
'protocol' => 'HTTP',
'version' => number_format($parts->httpVersion, 1),
'headers' => $parts->headers,
'body' => $parts->body
);
$parsed['request_url'] = $this->getUrlPartsFromMessage($parts->requestUrl, $parsed);
return $parsed;
}
public function parseResponse($message)
{
if (!$message) {
return false;
}
$parts = http_parse_message($message);
return array(
'protocol' => 'HTTP',
'version' => number_format($parts->httpVersion, 1),
'code' => $parts->responseCode,
'reason_phrase' => $parts->responseStatus,
'headers' => $parts->headers,
'body' => $parts->body
);
}
}