mirror of
https://github.com/composer/composer
synced 2025-05-10 09:02:59 +00:00
Allow PreFileDownloadEvent to carry transport options for metadata (#9831)
This commit is contained in:
parent
c3b76a8532
commit
e291aa1d12
2 changed files with 39 additions and 3 deletions
|
@ -1088,13 +1088,16 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
$retries = 3;
|
||||
while ($retries--) {
|
||||
try {
|
||||
$options = $this->options;
|
||||
if ($this->eventDispatcher) {
|
||||
$preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
|
||||
$preFileDownloadEvent->setTransportOptions($this->options);
|
||||
$this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
|
||||
$filename = $preFileDownloadEvent->getProcessedUrl();
|
||||
$options = $preFileDownloadEvent->getTransportOptions();
|
||||
}
|
||||
|
||||
$response = $this->httpDownloader->get($filename, $this->options);
|
||||
$response = $this->httpDownloader->get($filename, $options);
|
||||
$json = $response->getBody();
|
||||
if ($sha256 && $sha256 !== hash('sha256', $json)) {
|
||||
// undo downgrade before trying again if http seems to be hijacked or modifying content somehow
|
||||
|
@ -1180,13 +1183,15 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
$retries = 3;
|
||||
while ($retries--) {
|
||||
try {
|
||||
$options = $this->options;
|
||||
if ($this->eventDispatcher) {
|
||||
$preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
|
||||
$preFileDownloadEvent->setTransportOptions($this->options);
|
||||
$this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
|
||||
$filename = $preFileDownloadEvent->getProcessedUrl();
|
||||
$options = $preFileDownloadEvent->getTransportOptions();
|
||||
}
|
||||
|
||||
$options = $this->options;
|
||||
if (isset($options['http']['header'])) {
|
||||
$options['http']['header'] = (array) $options['http']['header'];
|
||||
}
|
||||
|
@ -1254,13 +1259,15 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
}
|
||||
|
||||
$httpDownloader = $this->httpDownloader;
|
||||
$options = $this->options;
|
||||
if ($this->eventDispatcher) {
|
||||
$preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
|
||||
$preFileDownloadEvent->setTransportOptions($this->options);
|
||||
$this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
|
||||
$filename = $preFileDownloadEvent->getProcessedUrl();
|
||||
$options = $preFileDownloadEvent->getTransportOptions();
|
||||
}
|
||||
|
||||
$options = $this->options;
|
||||
if ($lastModifiedTime) {
|
||||
if (isset($options['http']['header'])) {
|
||||
$options['http']['header'] = (array) $options['http']['header'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue