diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php
index 6e56f3a4f..3f7aca0c8 100644
--- a/src/Composer/Command/DiagnoseCommand.php
+++ b/src/Composer/Command/DiagnoseCommand.php
@@ -250,7 +250,7 @@ EOT
*/
private function checkHttp($proto, Config $config)
{
- $result = $this->checkConnectivity();
+ $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
if ($result !== true) {
return $result;
}
@@ -288,7 +288,7 @@ EOT
*/
private function checkHttpProxy()
{
- $result = $this->checkConnectivity();
+ $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
if ($result !== true) {
return $result;
}
@@ -319,7 +319,7 @@ EOT
*/
private function checkGithubOauth($domain, $token)
{
- $result = $this->checkConnectivity();
+ $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
if ($result !== true) {
return $result;
}
@@ -350,7 +350,7 @@ EOT
*/
private function getGithubRateLimit($domain, $token = null)
{
- $result = $this->checkConnectivity();
+ $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
if ($result !== true) {
return $result;
}
@@ -421,7 +421,7 @@ EOT
*/
private function checkVersion(Config $config)
{
- $result = $this->checkConnectivity();
+ $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
if ($result !== true) {
return $result;
}
@@ -749,7 +749,39 @@ EOT
private function checkConnectivity()
{
if (!ini_get('allow_url_fopen')) {
- return 'Skipped because allow_url_fopen is missing.';
+ return 'SKIP> Because allow_url_fopen is missing.>';
+ }
+
+ return true;
+ }
+
+ /**
+ * @return string|true
+ */
+ private function checkConnectivityAndComposerNetworkHttpEnablement()
+ {
+ $result = $this->checkConnectivity();
+ if ($result !== true) {
+ return $result;
+ }
+
+ $result = $this->checkComposerNetworkHttpEnablement();
+ if ($result !== true) {
+ return $result;
+ }
+
+ return true;
+ }
+
+ /**
+ * Check if Composer network is enabled for HTTP/S
+ *
+ * @return string|true
+ */
+ private function checkComposerNetworkHttpEnablement()
+ {
+ if ((bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
+ return 'SKIP> Network is disabled by COMPOSER_DISABLE_NETWORK.>';
}
return true;