$secret = $conf['facebook']['secret'];
/* Create required objects */
- $context = array('http_client' => $injector->getInstance('Horde_Http_Client'),
+ $context = array('http_client' => $injector->getInstance('Horde_Http_Client')->getClient(),
'http_request' => $injector->getInstance('Horde_Controller_Request_Http'));
return new Horde_Service_Facebook($apikey, $secret, $context);
{
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);
+ return new Horde_Core_Factory_HttpClient($injector);
}
public function equals(Horde_Injector_Binder $binder)
//$twitter->setCache($injector->getInstance('Horde_Cache'));
$twitter->setLogger($injector->getInstance('Horde_Log_Logger'));
- $twitter->setHttpClient($GLOBALS['injector']->getInstance('Horde_Http_Client'));
+ $twitter->setHttpClient($GLOBALS['injector']->getInstance('Horde_Http_Client')->getClient());
return $twitter;
} else {
--- /dev/null
+<?php
+/**
+ * @category Horde
+ * @package Core
+ */
+class Horde_Core_Factory_HttpClient
+{
+ /**
+ * The injector.
+ *
+ * @var Horde_Injector
+ */
+ private $_injector;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Injector $injector The injector to use.
+ */
+ public function __construct(Horde_Injector $injector)
+ {
+ $this->_injector = $injector;
+ }
+
+ public function getClient(array $opts = array())
+ {
+ 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(array_merge($client_opts, $opts));
+ }
+}
\ No newline at end of file
<file name="Db.php" role="php" />
<file name="DbPear.php" role="php" />
<file name="Editor.php" role="php" />
+ <file name="HttpClient.php" role="php" />
<file name="Identity.php" role="php" />
<file name="KolabServer.php" role="php" />
<file name="KolabSession.php" role="php" />
<install as="Horde/Core/Factory/Db.php" name="lib/Horde/Core/Factory/Db.php" />
<install as="Horde/Core/Factory/DbPear.php" name="lib/Horde/Core/Factory/DbPear.php" />
<install as="Horde/Core/Factory/Editor.php" name="lib/Horde/Core/Factory/Editor.php" />
+ <install as="Horde/Core/Factory/HttpClient.php" name="lib/Horde/Core/Factory/HttpClient.php" />
<install as="Horde/Core/Factory/Identity.php" name="lib/Horde/Core/Factory/Identity.php" />
<install as="Horde/Core/Factory/KolabServer.php" name="lib/Horde/Core/Factory/KolabServer.php" />
<install as="Horde/Core/Factory/KolabSession.php" name="lib/Horde/Core/Factory/KolabSession.php" />
}
try {
- if (!empty($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
- Horde_Feed::setHttpClient($GLOBALS['injector']->getInstance('Horde_Http_Client'));
- }
-
- $feed = Horde_Feed::readUri($uri);
+ $client = $GLOBALS['injector']
+ ->getInstance('Horde_Http_Client')
+ ->getClient();
+ $feed = Horde_Feed::readUri($uri, $client);
$GLOBALS['cache']->set($key, serialize($feed));
return $feed;
} catch (Exception $e) {
return $mime_part;
}
- $client = $GLOBALS['injector']->getInstance('Horde_Http_Client');
+ $client = $GLOBALS['injector']
+ ->getInstance('Horde_Http_Client')
+ ->getClient();
$img_data = $img_parts = array();
/* Go through list of results, download the image, and create
{
global $conf;
- $http = $GLOBALS['injector']->getInstance('Horde_Http_Client');
+ $http = $GLOBALS['injector']
+ ->getInstance('Horde_Http_Client')
+ ->getClient();
try {
$response = $http->get($url);