1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Use RemoteFilesystem everywhere we do http requests

This commit is contained in:
Jordi Boggiano 2012-03-18 21:04:15 +01:00
parent d291d65faf
commit 7f65dd7409
7 changed files with 40 additions and 28 deletions

View file

@ -23,6 +23,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\Json\JsonFile;
use Composer\Util\RemoteFilesystem;
/**
* Install a package as new project into new directory.
@ -86,7 +87,7 @@ EOT
if (null === $repositoryUrl) {
$sourceRepo = new ComposerRepository(array('url' => 'http://packagist.org'));
} elseif (".json" === substr($repositoryUrl, -5)) {
$sourceRepo = new FilesystemRepository(new JsonFile($repositoryUrl));
$sourceRepo = new FilesystemRepository(new JsonFile($repositoryUrl, new RemoteFilesystem($io)));
} elseif (0 === strpos($repositoryUrl, 'http')) {
$sourceRepo = new ComposerRepository(array('url' => $repositoryUrl));
} else {

View file

@ -13,7 +13,7 @@
namespace Composer\Command;
use Composer\Composer;
use Composer\Util\StreamContextFactory;
use Composer\Util\RemoteFilesystem;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -40,9 +40,8 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output)
{
$ctx = StreamContextFactory::getContext();
$latest = trim(file_get_contents('http://getcomposer.org/version', false, $ctx));
$rfs = new RemoteFilesystem($this->getIO());
$latest = trim($rfs->getContents('getcomposer.org', 'http://getcomposer.org/version', false));
if (Composer::VERSION !== $latest) {
$output->writeln(sprintf("Updating to version <info>%s</info>.", $latest));
@ -50,7 +49,7 @@ EOT
$remoteFilename = 'http://getcomposer.org/composer.phar';
$localFilename = $_SERVER['argv'][0];
copy($remoteFilename, $localFilename, $ctx);
$rfs->copy('getcomposer.org', $remoteFilename, $localFilename);
} else {
$output->writeln("<info>You are using the latest composer version.</info>");
}

View file

@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\Json\JsonFile;
use Composer\Json\JsonValidationException;
use Composer\Util\RemoteFilesystem;
/**
* @author Robert Schönthal <seroscho@googlemail.com>
@ -55,7 +56,7 @@ EOT
$laxValid = false;
try {
$json = new JsonFile($file);
$json = new JsonFile($file, new RemoteFilesystem($this->getIO()));
$json->read();
$json->validateSchema(JsonFile::LAX_SCHEMA);