diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index 7ae80267..66a497be 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -874,8 +874,6 @@ class kolab_driver extends calendar_driver
*/
public function get_freebusy_list($email, $start, $end)
{
- require_once('HTTP/Request2.php');
-
if (empty($email)/* || $end < time()*/)
return false;
@@ -888,14 +886,11 @@ class kolab_driver extends calendar_driver
// ask kolab server first
try {
- $rcmail = rcube::get_instance();
- $request = new HTTP_Request2(kolab_storage::get_freebusy_url($email));
- $request->setConfig(array(
+ $request_config = array(
'store_body' => true,
'follow_redirects' => true,
- 'ssl_verify_peer' => $rcmail->config->get('kolab_ssl_verify_peer', true),
- ));
-
+ );
+ $request = libkolab::http_request(kolab_storage::get_freebusy_url($email), 'GET', $request_config);
$response = $request->send();
// authentication required
diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php
index 419dcb0b..fc14e807 100644
--- a/plugins/kolab_files/lib/kolab_files_engine.php
+++ b/plugins/kolab_files/lib/kolab_files_engine.php
@@ -581,35 +581,23 @@ class kolab_files_engine
$url = $this->url . '/api/';
if (!$this->request) {
- require_once 'HTTP/Request2.php';
+ $config = array(
+ 'store_body' => true,
+ 'follow_redirects' => true,
+ );
+ $this->request = libkolab::http_request($url, 'GET', $config);
+ }
+ else {
+ // cleanup
try {
- $request = new HTTP_Request2();
- $request->setConfig(array(
- 'store_body' => true,
- 'follow_redirects' => true,
- 'ssl_verify_peer' => $this->rc->config->get('kolab_ssl_verify_peer', true),
- 'ssl_verify_host' => $this->rc->config->get('kolab_ssl_verify_host', true),
- ));
-
- $this->request = $request;
+ $this->request->setBody('');
+ $this->request->setUrl($url);
+ $this->request->setMethod(HTTP_Request2::METHOD_GET);
}
catch (Exception $e) {
rcube::raise_error($e, true, true);
}
-
- // proxy User-Agent string
- $this->request->setHeader('user-agent', $_SERVER['HTTP_USER_AGENT']);
- }
-
- // cleanup
- try {
- $this->request->setBody('');
- $this->request->setUrl($url);
- $this->request->setMethod(HTTP_Request2::METHOD_GET);
- }
- catch (Exception $e) {
- rcube::raise_error($e, true, true);
}
if ($token) {
diff --git a/plugins/kolab_files/package.xml b/plugins/kolab_files/package.xml
index dbe6e828..8ac6e5b7 100644
--- a/plugins/kolab_files/package.xml
+++ b/plugins/kolab_files/package.xml
@@ -68,6 +68,10 @@
1.7.0
+
+ libkolab
+ http://kolabsys.com
+
diff --git a/plugins/libkolab/config.inc.php.dist b/plugins/libkolab/config.inc.php.dist
index aa0c8d09..6260f52a 100644
--- a/plugins/libkolab/config.inc.php.dist
+++ b/plugins/libkolab/config.inc.php.dist
@@ -12,9 +12,6 @@ $rcmail_config['kolab_format_version'] = '3.0';
// Defaults to https:///freebusy
$rcmail_config['kolab_freebusy_server'] = 'https:///';
-// Set this option to disable SSL certificate checks when triggering Free/Busy (enabled by default)
-$rcmail_config['kolab_ssl_verify_peer'] = false;
-
// Enables listing of only subscribed folders. This e.g. will limit
// folders in calendar view or available addressbooks
$rcmail_config['kolab_use_subscriptions'] = false;
@@ -23,4 +20,7 @@ $rcmail_config['kolab_use_subscriptions'] = false;
// for displaying resource folder names (experimental!)
$rcmail_config['kolab_custom_display_names'] = false;
-?>
+// Configuration of HTTP requests.
+// See http://pear.php.net/manual/en/package.http.http-request2.config.php
+// for list of supported configuration options (array keys)
+$rcmail_config['kolab_http_request'] = array();
diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index ddb5b3c3..7da57ffb 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -1110,9 +1110,7 @@ class kolab_storage_folder
require_once('HTTP/Request2.php');
try {
- $rcmail = rcube::get_instance();
- $request = new HTTP_Request2($url);
- $request->setConfig(array('ssl_verify_peer' => $rcmail->config->get('kolab_ssl_verify_peer', true)));
+ $request = libkolab::http_request($url);
// set authentication credentials
if ($auth_user && $auth_passwd)
diff --git a/plugins/libkolab/libkolab.php b/plugins/libkolab/libkolab.php
index b5ff968a..b5d1db72 100644
--- a/plugins/libkolab/libkolab.php
+++ b/plugins/libkolab/libkolab.php
@@ -27,6 +27,8 @@
class libkolab extends rcube_plugin
{
+ static $http_requests = array();
+
/**
* Required startup method of a Roundcube plugin
*/
@@ -59,4 +61,66 @@ class libkolab extends rcube_plugin
$p['fetch_headers'] = trim($p['fetch_headers'] .' X-KOLAB-TYPE X-KOLAB-MIME-VERSION');
return $p;
}
+
+ /**
+ * Wrapper function to load and initalize the HTTP_Request2 Object
+ *
+ * @param string|Net_Url2 Request URL
+ * @param string Request method ('OPTIONS','GET','HEAD','POST','PUT','DELETE','TRACE','CONNECT')
+ * @param array Configuration for this Request instance, that will be merged
+ * with default configuration
+ *
+ * @return HTTP_Request2 Request object
+ */
+ public static function http_request($url = '', $method = 'GET', $config = array())
+ {
+ $rcube = rcube::get_instance();
+ $http_config = (array) $rcube->config->get('kolab_http_request');
+
+ // deprecated configuration options
+ if (empty($$http_config)) {
+ foreach (array('ssl_verify_peer', 'ssl_verify_host') as $option) {
+ $value = $rcube->config->get('kolab_' . $option, true);
+ if (is_bool($value)) {
+ $http_config[$option] = $value;
+ }
+ }
+ }
+
+ if (!empty($config)) {
+ $http_config = array_merge($http_config, $config);
+ }
+
+ $key = md5(serialize($http_config));
+
+ if (!($request = self::$http_requests[$key])) {
+ // load HTTP_Request2
+ require_once 'HTTP/Request2.php';
+
+ try {
+ $request = new HTTP_Request2();
+ $request->setConfig($http_config);
+ }
+ catch (Exception $e) {
+ rcube::raise_error($e, true, true);
+ }
+
+ // proxy User-Agent string
+ $request->setHeader('user-agent', $_SERVER['HTTP_USER_AGENT']);
+
+ self::$http_requests[$key] = $request;
+ }
+
+ // cleanup
+ try {
+ $request->setBody('');
+ $request->setUrl($url);
+ $request->setMethod($method);
+ }
+ catch (Exception $e) {
+ rcube::raise_error($e, true, true);
+ }
+
+ return $request;
+ }
}