Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save damiankloip/10289053 to your computer and use it in GitHub Desktop.
Save damiankloip/10289053 to your computer and use it in GitHub Desktop.
/**
* Get an array of default options to apply to the client
*
* @return array
*/
protected function getDefaultOptions()
{
$settings = [
'allow_redirects' => true,
'exceptions' => true,
'verify' => __DIR__ . '/cacert.pem'
];
// Use the bundled cacert if it is a regular file, or set to true if
// using a phar file (because curL and the stream wrapper can't read
// cacerts from the phar stream wrapper). Favor the ini setting over
// the system's cacert.
if (substr(__FILE__, 0, 7) == 'phar://') {
$settings['verify'] = ini_get('openssl.cafile') ?: true;
}
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set
if (isset($_SERVER['HTTP_PROXY'])) {
$settings['proxy']['http'] = $_SERVER['HTTP_PROXY'];
}
if (isset($_SERVER['HTTPS_PROXY'])) {
$settings['proxy']['https'] = $_SERVER['HTTPS_PROXY'];
}
return $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment