ApplicationBootstrap: Implement and use setupProxy()

refs #9916
This commit is contained in:
Alexander Fuhr 2015-09-01 15:57:59 +02:00
parent 356530de81
commit c008300b86

View File

@ -466,6 +466,7 @@ abstract class ApplicationBootstrap
try {
$this->config = Config::app();
$this->setupProxy();
} catch (NotReadableError $e) {
Logger::error(new IcingaException('Cannot load application configuration. An exception was thrown:', $e));
$this->config = new Config();
@ -626,6 +627,31 @@ abstract class ApplicationBootstrap
return $this;
}
/**
* Set up the proxy
*
* @return $this
*/
protected function setupProxy()
{
if (! (bool) $this->config->get('global', 'use_proxy')) {
return $this;
}
$proxyConfig = $this->config->getSection('proxy');
$defaultOpts = array(
'http' => array(
'proxy' => $proxyConfig->get('http'),
'request_fulluri' => (bool) $proxyConfig->get('http_request_fulluri'),
)
);
stream_context_set_default($defaultOpts);
return $this;
}
/**
* @return string Our locale directory
*/