/** * Set the URI for the next request * * @param \Zend\Uri\Url|string $uri * @return \Zend\Http\Client * @throws \Zend\Http\Client\Exception */ public function setUri($uri) { if (is_string($uri)) { try { $uri = new Uri\Url($uri); } catch (URI\Exception $e) { throw new Client\Exception('Passed parameter is not a valid HTTP URI.'); } } $scheme = strtolower($uri->getScheme()); if (!empty($scheme) && !in_array($scheme, array('http', 'https'))) { throw new Client\Exception('Passed parameter is not a valid HTTP URI.'); } // Set auth if username and password has been specified in the uri if ($uri->getUsername() && $uri->getPassword()) { $this->setAuth($uri->getUsername(), $uri->getPassword()); } // We have no ports, set the defaults if (!$uri->getPort()) { $uri->setPort($uri->getScheme() == 'https' ? 443 : 80); } $this->uri = $uri; return $this; }