1
0
Fork 0

Fix handling of origin url in composer repository class

pull/2993/merge
Jordi Boggiano 2014-05-07 18:38:58 +02:00
parent 39c8d3e6e1
commit b6981d09e8
4 changed files with 11 additions and 8 deletions

View File

@ -207,10 +207,10 @@ EOT
$url = 'https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0'; $url = 'https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0';
try { try {
$rfcResult = $this->rfs->getContents('api.github.com', $url, false); $rfcResult = $this->rfs->getContents('github.com', $url, false);
} catch (TransportException $e) { } catch (TransportException $e) {
try { try {
$this->rfs->getContents('api.github.com', $url, false, array('http' => array('request_fulluri' => false))); $this->rfs->getContents('github.com', $url, false, array('http' => array('request_fulluri' => false)));
} catch (TransportException $e) { } catch (TransportException $e) {
return 'Unable to assert the situation, maybe github is down ('.$e->getMessage().')'; return 'Unable to assert the situation, maybe github is down ('.$e->getMessage().')';
} }

View File

@ -121,10 +121,6 @@ class FileDownloader implements DownloaderInterface
} }
$rfs = $preFileDownloadEvent->getRemoteFilesystem(); $rfs = $preFileDownloadEvent->getRemoteFilesystem();
if (strpos($hostname, '.github.com') === (strlen($hostname) - 11)) {
$hostname = 'github.com';
}
try { try {
$checksum = $package->getDistSha1Checksum(); $checksum = $package->getDistSha1Checksum();
$cacheKey = $this->getCacheKey($package); $cacheKey = $this->getCacheKey($package);

View File

@ -160,7 +160,8 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) { if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
$url = str_replace('%query%', $query, $this->searchUrl); $url = str_replace('%query%', $query, $this->searchUrl);
$json = $this->rfs->getContents($url, $url, false); $hostname = parse_url($url, PHP_URL_HOST) ?: $url;
$json = $this->rfs->getContents($hostname, $url, false);
$results = JsonFile::parseJson($json, $url); $results = JsonFile::parseJson($json, $url);
return $results['results']; return $results['results'];
@ -604,7 +605,9 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
if ($this->eventDispatcher) { if ($this->eventDispatcher) {
$this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent); $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
} }
$json = $preFileDownloadEvent->getRemoteFilesystem()->getContents($filename, $filename, false);
$hostname = parse_url($filename, PHP_URL_HOST) ?: $filename;
$json = $preFileDownloadEvent->getRemoteFilesystem()->getContents($hostname, $filename, false);
if ($sha256 && $sha256 !== hash('sha256', $json)) { if ($sha256 && $sha256 !== hash('sha256', $json)) {
if ($retries) { if ($retries) {
usleep(100000); usleep(100000);

View File

@ -118,6 +118,10 @@ class RemoteFilesystem
*/ */
protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true) protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
{ {
if (strpos($originUrl, '.github.com') === (strlen($originUrl) - 11)) {
$originUrl = 'github.com';
}
$this->bytesMax = 0; $this->bytesMax = 0;
$this->originUrl = $originUrl; $this->originUrl = $originUrl;
$this->fileUrl = $fileUrl; $this->fileUrl = $fileUrl;