From: Michael M Slusarz Date: Mon, 28 Jun 2010 20:09:40 +0000 (-0600) Subject: Add binder for Horde_Http_Client X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=01b53c377117e903316d321159f6a46e40b2c1cd;p=horde.git Add binder for Horde_Http_Client --- diff --git a/framework/Core/lib/Horde/Core/Binder/HttpClient.php b/framework/Core/lib/Horde/Core/Binder/HttpClient.php new file mode 100644 index 000000000..235ceb746 --- /dev/null +++ b/framework/Core/lib/Horde/Core/Binder/HttpClient.php @@ -0,0 +1,33 @@ + new Horde_Core_Binder_DbPear(), 'Horde_Editor' => new Horde_Core_Binder_Editor(), 'Horde_History' => new Horde_Core_Binder_History(), + 'Horde_Http_Client' => new Horde_Core_Binder_HttpClient(), 'Horde_Ldap' => new Horde_Core_Binder_Ldap(), 'Horde_Lock' => new Horde_Core_Binder_Lock(), 'Horde_Log_Logger' => new Horde_Core_Binder_Logger(), diff --git a/framework/Core/package.xml b/framework/Core/package.xml index e171c25b0..5630b9f06 100644 --- a/framework/Core/package.xml +++ b/framework/Core/package.xml @@ -94,6 +94,7 @@ Application Framework. + @@ -251,6 +252,10 @@ Application Framework. pear.horde.org + Http + pear.horde.org + + Kolab_Server pear.horde.org @@ -291,6 +296,7 @@ Application Framework. + diff --git a/horde/lib/Block/feed/reader.php b/horde/lib/Block/feed/reader.php index b6d673624..d2b9e8d01 100644 --- a/horde/lib/Block/feed/reader.php +++ b/horde/lib/Block/feed/reader.php @@ -22,13 +22,7 @@ class Horde_Block_Horde_feed_reader { try { if (!empty($GLOBALS['conf']['http']['proxy']['proxy_host'])) { - $client = new Horde_Http_Client; - $client->proxyServer = $GLOBALS['conf']['http']['proxy']['proxy_host'] . ':' . $GLOBALS['conf']['http']['proxy']['proxy_port']; - if (!empty($GLOBALS['conf']['http']['proxy']['proxy_user'])) { - $client->proxyUser = $GLOBALS['conf']['http']['proxy']['proxy_user']; - $client->proxyPass = empty($GLOBALS['conf']['http']['proxy']['proxy_pass']) ? $GLOBALS['conf']['http']['proxy']['proxy_pass'] : ''; - } - Horde_Feed::setHttpClient($client); + Horde_Feed::setHttpClient($GLOBALS['injector']->getInstance('Horde_Http_Client')); } $feed = Horde_Feed::readUri($uri); diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 98f29bc2e..997628a2d 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -1081,8 +1081,6 @@ class IMP_Compose $textpart->setHeaderCharset($charset); if (empty($options['nofinal'])) { - /* Any image links will be downloaded and appended to the - * message body. */ $textpart->addPart($this->_convertToMultipartRelated($htmlBody)); } else { $textpart->addPart($htmlBody); @@ -2267,19 +2265,11 @@ class IMP_Compose return $mime_part; } - $client_opts = $img_data = $img_parts = array(); + $client = $GLOBALS['injector']->getInstance('Horde_Http_Client'); + $img_data = $img_parts = array(); /* Go through list of results, download the image, and create * Horde_Mime_Part objects with the data. */ - if (!empty($conf['http']['proxy']['proxy_host'])) { - $client_opts['proxyServer'] = $conf['http']['proxy']['proxy_host'] . ':' . $conf['http']['proxy']['proxy_port']; - if (!empty($conf['http']['proxy']['proxy_user'])) { - $client_opts['proxyUser'] = $conf['http']['proxy']['proxy_user']; - $client_opts['proxyPass'] = empty($conf['http']['proxy']['proxy_pass']) ? $conf['http']['proxy']['proxy_pass'] : ''; - } - } - $client = new Horde_Http_Client($client_opts); - foreach ($results[1] as $url) { /* Attempt to download the image data. */ $response = $client->get(str_replace('&', '&', trim($url, '"\''))); diff --git a/jonah/lib/Jonah.php b/jonah/lib/Jonah.php index 715e4c939..3610fcc9c 100644 --- a/jonah/lib/Jonah.php +++ b/jonah/lib/Jonah.php @@ -44,16 +44,8 @@ class Jonah { global $conf; - $factory = new Horde_Http_Request_Factory(); - $request = $factory->create(); - if (!empty($conf['http']['proxy']['proxy_host'])) { - $request->proxyServer = $conf['http']['proxy']['proxy_host']; - $request->proxyPort = $conf['http']['proxy']['proxy_port']; - $request->proxyUsername = $conf['http']['proxy']['proxy_user']; - $request->proxyPassword = $conf['http']['proxy']['proxy_pass']; - } + $http = $GLOBALS['injector']->getInstance('Horde_Http_Client'); - $http = new Horde_Http_Client(array('request' => $request)); try { $response = $http->get($url); } catch (Horde_Http_Exception $e) {