Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DiagnoseCommand.php

function DiagnoseCommand::checkHttpProxy

Return value

string|\Exception

1 call to DiagnoseCommand::checkHttpProxy()
DiagnoseCommand::execute in vendor/composer/composer/src/Composer/Command/DiagnoseCommand.php
Executes the current command.

File

vendor/composer/composer/src/Composer/Command/DiagnoseCommand.php, line 403

Class

DiagnoseCommand
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Command

Code

private function checkHttpProxy(RequestProxy $proxy, string $protocol) {
    $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
    if ($result !== true) {
        return $result;
    }
    try {
        $proxyStatus = $proxy->getStatus();
        if ($proxy->isExcludedByNoProxy()) {
            return '<info>SKIP</> <comment>Because repo.packagist.org is ' . $proxyStatus . '</>';
        }
        $json = $this->httpDownloader
            ->get($protocol . '://repo.packagist.org/packages.json')
            ->decodeJson();
        if (isset($json['provider-includes'])) {
            $hash = reset($json['provider-includes']);
            $hash = $hash['sha256'];
            $path = str_replace('%hash%', $hash, key($json['provider-includes']));
            $provider = $this->httpDownloader
                ->get($protocol . '://repo.packagist.org/' . $path)
                ->getBody();
            if (hash('sha256', $provider) !== $hash) {
                return '<warning>It seems that your proxy (' . $proxyStatus . ') is modifying ' . $protocol . ' traffic on the fly</>';
            }
        }
        return '<info>OK</> <comment>' . $proxyStatus . '</>';
    } catch (\Exception $e) {
        return $e;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal