Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • AbstractMessageParser
  • MessageParser
  • PeclHttpMessageParser

Interfaces

  • MessageParserInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Parser\Message;
 4: 
 5: /**
 6:  * Implements shared message parsing functionality
 7:  */
 8: abstract class AbstractMessageParser implements MessageParserInterface
 9: {
10:     /**
11:      * Create URL parts from HTTP message parts
12:      *
13:      * @param string $requestUrl Associated URL
14:      * @param array  $parts      HTTP message parts
15:      *
16:      * @return array
17:      */
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'] = '';
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: }
59: 
php-coveralls API documentation generated by ApiGen 2.8.0