From c008300b860b1a821d810106d3178d3ba1984a46 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 1 Sep 2015 15:57:59 +0200 Subject: [PATCH] ApplicationBootstrap: Implement and use setupProxy() refs #9916 --- .../Application/ApplicationBootstrap.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index a8d185023..b05d7f4ca 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -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 */