1: <?php
2:
3: namespace Guzzle\Parser\Message;
4:
5: 6: 7:
8: abstract class AbstractMessageParser implements MessageParserInterface
9: {
10: 11: 12: 13: 14: 15: 16: 17:
18: protected function getUrlPartsFromMessage($requestUrl, array $parts)
19: {
20:
21: $urlParts = array(
22: 'path' => $requestUrl,
23: 'scheme' => 'http'
24: );
25:
26:
27: if (isset($parts['headers']['Host'])) {
28: $urlParts['host'] = $parts['headers']['Host'];
29: } elseif (isset($parts['headers']['host'])) {
30: $urlParts['host'] = $parts['headers']['host'];
31: } else {
32: $urlParts['host'] = '';
33: }
34:
35: if (false === strpos($urlParts['host'], ':')) {
36: $urlParts['port'] = '';
37: } else {
38: $hostParts = explode(':', $urlParts['host']);
39: $urlParts['host'] = trim($hostParts[0]);
40: $urlParts['port'] = (int) trim($hostParts[1]);
41: if ($urlParts['port'] == 443) {
42: $urlParts['scheme'] = 'https';
43: }
44: }
45:
46:
47: $path = $urlParts['path'];
48: $qpos = strpos($path, '?');
49: if ($qpos) {
50: $urlParts['query'] = substr($path, $qpos + 1);
51: $urlParts['path'] = substr($path, 0, $qpos);
52: } else {
53: $urlParts['query'] = '';
54: }
55:
56: return $urlParts;
57: }
58: }
59: