Composer在安装包时显示传输异常

I wanted to install Guzzle HTTP package for my Laravel 5.3 project.

But when I ran the specific install command, composer shows the following:

[Composer\Downloader\TransportException]
The "http://packagist.org/p/cordoval/hamcrest-php%249e26dffac4ed896eb042373003ee127ad49377842601ba5bd833d00e135a3c62.json" file could not be downloaded: failed to open stream: HTTP request failed!

Tried composer diagnose and checked that all ok. Also tried composer self-update but that's no help, too.

Try to force HTTPS for all resources by running composer config -g repo.packagist composer https://packagist.org

Finally, after adding the following code at the end of composer.json, it worked!

"repositories": [ { "type": "composer", "url": "https://packagist.org" }, { "packagist": false } ]