Open Monograph Press  3.3.0
AbstractMessageParser.php
1 <?php
2 
4 
9 {
18  protected function getUrlPartsFromMessage($requestUrl, array $parts)
19  {
20  // Parse the URL information from the message
21  $urlParts = array(
22  'path' => $requestUrl,
23  'scheme' => 'http'
24  );
25 
26  // Check for the Host header
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'] = null;
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  // Check if a query is present
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 }
Guzzle\Parser\Message\MessageParserInterface
Definition: MessageParserInterface.php:8
Guzzle\Parser\Message\AbstractMessageParser
Definition: AbstractMessageParser.php:8
Guzzle\Parser\Message\AbstractMessageParser\getUrlPartsFromMessage
getUrlPartsFromMessage($requestUrl, array $parts)
Definition: AbstractMessageParser.php:18
Guzzle\Parser\Message
Definition: AbstractMessageParser.php:3