public function testHeaders() { if (!$this->_remoteEnabled) { return; } $http = new Zend_HttpClient(TESTS_ZEND_HTTPCLIENT_REMOTE_URI); $result = $http->get(); $this->assertType('array', $result->getHeaders(), 'Headers not returned; Zend_HttpClient_Response::$_requestHeaders is not an array'); $this->assertTrue(in_array('Content-Type', array_keys($result->getHeaders())), 'Required Content-Type header not found'); }
public function testBadUri() { if (!$this->_remoteEnabled) { return; } try { $http = new Zend_HttpClient('http://baduri.org'); $http->setTimeout(1); $response = $http->get(); } catch (Exception $e) { $this->assertRegExp('/^Unable to Connect to (.*)/', $e->getMessage()); } }
/** * Send a XML-RPC request to the service (for a specific method) * * @param string $method Name of the method we want to call * @param array $params Array of Zend_XmlRpc_Value objects, parameters for the method * @throws Zend_HttpClient_Exception */ protected function _sendRequest($method, $params = null) { $request_data = $this->_buildRequest($method, $params); // @todo pluggable client? $http = new Zend_HttpClient($this->_serverAddress, array('Content-Type: text/xml')); $response = $http->post($request_data); /* @var $response ZHttpClientResponse */ return $this->_parseResponse($response->getBody()); }