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