public function testGetters() { $request = new Zym_Couch_Request('/foo/bar', Zym_Couch_Request::GET, 'myDataGoesHere'); $this->assertEquals('/foo/bar', $request->getUrl()); $this->assertEquals(Zym_Couch_Request::GET, $request->getMethod()); $this->assertEquals('myDataGoesHere', $request->getData()); }
/** * Send the request and return the response * * @param Zym_Couch_Request * @return Zym_Couch_Response */ public function send(Zym_Couch_Request $request) { $errorString = ''; $errorNumber = ''; $response = ''; $socket = fsockopen($this->_host, $this->_port, $errorNumber, $errorString); if (!$socket) { /** * @see Zym_Couch_Exception */ require_once 'Zym/Couch/Exception.php'; throw new Zym_Couch_Exception('Failed to open connection to ' . $this->_host . ':' . $this->_port . ' (Error number ' . $errorNumber . ': ' . $errorString . ')'); } fwrite($socket, $request->getRawRequest()); while (!feof($socket)) { $response .= fgets($socket); } fclose($socket); $socket = null; return new Zym_Couch_Response($response); }