public static function getHttpClient($type = "Zend_Http_Client", $options = [])
{
$config = Config::getSystemConfig();
$clientConfig = $config->httpclient->toArray();
$clientConfig["adapter"] = isset($clientConfig["adapter"]) && !empty($clientConfig["adapter"]) ? $clientConfig["adapter"] : "Zend_Http_Client_Adapter_Socket";
$clientConfig["maxredirects"] = isset($options["maxredirects"]) ? $options["maxredirects"] : 2;
$clientConfig["timeout"] = isset($options["timeout"]) ? $options["timeout"] : 3600;
$type = empty($type) ? "Zend_Http_Client" : $type;
$type = "\\" . ltrim($type, "\\");
if (self::classExists($type)) {
$client = new $type(null, $clientConfig);
// workaround/for ZF (Proxy-authorization isn't added by ZF)
if ($clientConfig['proxy_user']) {
$client->setHeaders('Proxy-authorization', \Zend_Http_Client::encodeAuthHeader($clientConfig['proxy_user'], $clientConfig['proxy_pass'], \Zend_Http_Client::AUTH_BASIC));
}
} else {
throw new \Exception("Pimcore_Tool::getHttpClient: Unable to create an instance of {$type}");
}
return $client;
}