diff --git a/src/Composer/Util/HttpDownloader.php b/src/Composer/Util/HttpDownloader.php index 9bd1cb6f0..8f3d606d8 100644 --- a/src/Composer/Util/HttpDownloader.php +++ b/src/Composer/Util/HttpDownloader.php @@ -73,6 +73,16 @@ class HttpDownloader $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls); } + /** + * Download a file synchronously + * + * @param string $url URL to download + * @param array $options Stream context options e.g. https://www.php.net/manual/en/context.http.php + * although not all options are supported when using the default curl downloader + * @return Response + * + * @throws TransportException + */ public function get($url, $options = array()) { list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true); @@ -101,6 +111,16 @@ class HttpDownloader return $response; } + /** + * Create an async download operation + * + * @param string $url URL to download + * @param array $options Stream context options e.g. https://www.php.net/manual/en/context.http.php + * although not all options are supported when using the default curl downloader + * @return Promise + * + * @throws TransportException + */ public function add($url, $options = array()) { list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false)); @@ -108,6 +128,17 @@ class HttpDownloader return $promise; } + /** + * Copy a file synchronously + * + * @param string $url URL to download + * @param string $to Path to copy to + * @param array $options Stream context options e.g. https://www.php.net/manual/en/context.http.php + * although not all options are supported when using the default curl downloader + * @return Response + * + * @throws TransportException + */ public function copy($url, $to, $options = array()) { list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true); @@ -116,6 +147,17 @@ class HttpDownloader return $this->getResponse($job['id']); } + /** + * Create an async copy operation + * + * @param string $url URL to download + * @param string $to Path to copy to + * @param array $options Stream context options e.g. https://www.php.net/manual/en/context.http.php + * although not all options are supported when using the default curl downloader + * @return Promise + * + * @throws TransportException + */ public function addCopy($url, $to, $options = array()) { list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to)); @@ -287,6 +329,11 @@ class HttpDownloader $this->runningJobs--; } + /** + * Wait for current async download jobs to complete + * + * @param int|null $index For internal use only, the job id + */ public function wait($index = null) { while (true) { @@ -309,7 +356,8 @@ class HttpDownloader /** * @internal * - * @return int number of active (queued or started) jobs + * @param int|null $index For internal use only, the job id + * @return int number of active (queued or started) jobs */ public function countActiveJobs($index = null) { @@ -362,6 +410,9 @@ class HttpDownloader return $resp; } + /** + * @internal + */ public static function outputWarnings(IOInterface $io, $url, $data) { foreach (array('warning', 'info') as $type) { @@ -382,6 +433,9 @@ class HttpDownloader } } + /** + * @internal + */ public static function getExceptionHints(\Exception $e) { if (!$e instanceof TransportException) { @@ -427,6 +481,9 @@ class HttpDownloader return true; } + /** + * @internal + */ public static function isCurlEnabled() { return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');