function StreamContextFactory::getContext
Creates a context supporting HTTP proxies
@phpstan-param array{http?: array{follow_location?: int, max_redirects?: int, header?: string|array<string>}} $defaultOptions
Parameters
non-empty-string $url URL the context is to be used for:
mixed[] $defaultOptions Options to merge with the default:
mixed[] $defaultParams Parameters to specify on the context:
Return value
resource Default context
Throws
\RuntimeException if https proxy required and OpenSSL uninstalled
1 call to StreamContextFactory::getContext()
- RemoteFilesystem::get in vendor/
composer/ composer/ src/ Composer/ Util/ RemoteFilesystem.php - Get file content or copy action.
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ StreamContextFactory.php, line 40
Class
- StreamContextFactory
- Allows the creation of a basic context supporting http proxy
Namespace
Composer\UtilCode
public static function getContext(string $url, array $defaultOptions = [], array $defaultParams = []) {
$options = [
'http' => [
// specify defaults again to try and work better with curlwrappers enabled
'follow_location' => 1,
'max_redirects' => 20,
],
];
$options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
unset($defaultOptions['http']['header']);
$options = array_replace_recursive($options, $defaultOptions);
if (isset($options['http']['header'])) {
$options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
}
return stream_context_create($options, $defaultParams);
}