Hprose\Swoole\Http\Client::setUri PHP Method

setUri() protected method

protected setUri ( $uri )
    protected function setUri($uri)
    {
        parent::setUri($uri);
        $p = parse_url($uri);
        if ($p) {
            switch (strtolower($p['scheme'])) {
                case 'http':
                    $this->host = $p['host'];
                    $this->port = isset($p['port']) ? $p['port'] : 80;
                    $this->path = isset($p['path']) ? $p['path'] : '/';
                    $this->ssl = false;
                    break;
                case 'https':
                    $this->host = $p['host'];
                    $this->port = isset($p['port']) ? $p['port'] : 443;
                    $this->path = isset($p['path']) ? $p['path'] : '/';
                    $this->ssl = true;
                    break;
                default:
                    throw new Exception("Only support http and https scheme");
            }
        } else {
            throw new Exception("Can't parse this uri: " . $uri);
        }
        $this->header['Host'] = $this->host;
        $this->header['Connection'] = $this->keepAlive ? 'keep-alive' : 'close';
        if ($this->keepAlive) {
            $this->header['Keep-Ailve'] = $this->keepAliveTimeout;
        }
        if (filter_var($this->host, FILTER_VALIDATE_IP) === false) {
            $ip = gethostbyname($this->host);
            if ($ip === $this->host) {
                throw new Exception('DNS lookup failed');
            } else {
                $this->ip = $ip;
            }
        } else {
            $this->ip = $this->host;
        }
    }