--- /dev/null
+<?php
+/**
+ * @category Horde
+ * @package Core
+ */
+class Horde_Core_Binder_HttpClient implements Horde_Injector_Binder
+{
+ public function create(Horde_Injector $injector)
+ {
+ global $conf;
+
+ $client_opts = array();
+
+ if (!empty($conf['http']['proxy']['proxy_host'])) {
+ $client_opts['request.proxyServer'] = $conf['http']['proxy']['proxy_host'];
+ $client_opts['request.proxyPort'] = $conf['http']['proxy']['proxy_port'];
+ if (!empty($conf['http']['proxy']['proxy_user'])) {
+ $client_opts['request.proxyUsername'] = $conf['http']['proxy']['proxy_user'];
+ if (!empty($conf['http']['proxy']['proxy_pass'])) {
+ $client_opts['request.proxyPassword'] = $conf['http']['proxy']['proxy_pass'];
+ }
+ }
+ }
+
+ return new Horde_Http_Client($client_opts);
+ }
+
+ public function equals(Horde_Injector_Binder $binder)
+ {
+ return false;
+ }
+
+}
'Horde_Db_Pear' => 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(),
<file name="Dns.php" role="php" />
<file name="Editor.php" role="php" />
<file name="History.php" role="php" />
+ <file name="HttpClient.php" role="php" />
<file name="Identity.php" role="php" />
<file name="Ldap.php" role="php" />
<file name="Lock.php" role="php" />
<channel>pear.horde.org</channel>
</package>
<package>
+ <name>Http</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
<name>Kolab_Server</name>
<channel>pear.horde.org</channel>
</package>
<install name="lib/Horde/Core/Binder/Dns.php" as="Horde/Core/Binder/Dns.php" />
<install name="lib/Horde/Core/Binder/Editor.php" as="Horde/Core/Binder/Editor.php" />
<install name="lib/Horde/Core/Binder/History.php" as="Horde/Core/Binder/History.php" />
+ <install name="lib/Horde/Core/Binder/HttpClient.php" as="Horde/Core/Binder/HttpClient.php" />
<install name="lib/Horde/Core/Binder/Identity.php" as="Horde/Core/Binder/Identity.php" />
<install name="lib/Horde/Core/Binder/Ldap.php" as="Horde/Core/Binder/Ldap.php" />
<install name="lib/Horde/Core/Binder/Lock.php" as="Horde/Core/Binder/Lock.php" />
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);
$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);
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, '"\'')));
{
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) {