|
10 | 10 | namespace Joomla\CMS\Updater; |
11 | 11 |
|
12 | 12 | use Joomla\CMS\Adapter\AdapterInstance; |
| 13 | +use Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent; |
13 | 14 | use Joomla\CMS\Factory; |
14 | 15 | use Joomla\CMS\Http\HttpFactory; |
15 | 16 | use Joomla\CMS\Language\Text; |
16 | 17 | use Joomla\CMS\Log\Log; |
| 18 | +use Joomla\CMS\Plugin\PluginHelper; |
17 | 19 | use Joomla\CMS\Version; |
18 | 20 | use Joomla\Database\ParameterType; |
19 | 21 | use Joomla\Registry\Registry; |
@@ -245,10 +247,21 @@ protected function getUpdateSiteResponse($options = []) |
245 | 247 | $httpOption = new Registry(); |
246 | 248 | $httpOption->set('userAgent', $version->getUserAgent('Joomla', true, false)); |
247 | 249 |
|
248 | | - // JHttp transport throws an exception when there's no response. |
| 250 | + $headers = []; |
| 251 | + $dispatcher = Factory::getApplication()->getDispatcher(); |
| 252 | + PluginHelper::importPlugin('installer', null, true, $dispatcher); |
| 253 | + $event = new BeforeUpdateSiteDownloadEvent('onInstallerBeforeUpdateSiteDownload', [ |
| 254 | + 'url' => $url, |
| 255 | + 'headers' => $headers, |
| 256 | + ]); |
| 257 | + $dispatcher->dispatch('onInstallerBeforeUpdateSiteDownload', $event); |
| 258 | + $url = $event->getArgument('url', $url); |
| 259 | + $headers = $event->getArgument('headers', $headers); |
| 260 | + |
| 261 | + // Http transport throws an exception when there's no response. |
249 | 262 | try { |
250 | 263 | $http = HttpFactory::getHttp($httpOption); |
251 | | - $response = $http->get($url, [], 20); |
| 264 | + $response = $http->get($url, $headers, 20); |
252 | 265 | } catch (\RuntimeException $e) { |
253 | 266 | $response = null; |
254 | 267 | } |
|
0 commit comments