/**
* Sends an HTTP request.
*
* @param string $method HTTP request method (GET, PUT, etc.)
* @param string|Horde_Url $uri URI to request, if different from
* $this->uri
* @param string|array $data Request data. Array of form data that will
* be encoded automatically, or a raw string.
* @param array $headers Any headers specific to this request. They
* will be combined with $this->_headers, and
* override headers of the same name for this
* request only.
*
* @throws Horde_Http_Exception
* @return Horde_Http_Response_Base
*/
public function request($method, $uri = null, $data = null, $headers = array())
{
if ($method !== null) {
$this->request->method = $method;
}
if ($uri !== null) {
$this->request->uri = $uri;
}
if ($data !== null) {
$this->request->data = $data;
}
if (count($headers)) {
$this->request->setHeaders($headers);
}
$this->_lastRequest = $this->_request;
$this->_lastResponse = $this->_request->send();
return $this->_lastResponse;
}