public function testReloadAllowsCustomURI() { $uriOverride = 'http://www.example.org'; $etag = 'ABCD1234'; $this->service->setMajorProtocolVersion(2); $this->adapter->setResponse($this->httpEntrySample); $entry = $this->service->newEntry(); $entry->link = array(new Extension\Link('http://www.example.com', 'edit', 'application/atom+xml')); $entry->setEtag($etag); $newEntry = $entry->reload($uriOverride); $requestUri = $this->adapter->popRequest()->uri; $uriOverrideObject = new URI\URL($uriOverride); $uriOverrideObject->setPort('80'); $this->assertEquals($uriOverrideObject, $requestUri); }
/** * Set the URI for the next request * * @param \Zend\URI\URL|string $uri * @return \Zend\HTTP\Client\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; }