function flickr_curl_set_proxy_settings in Flickr 7
Set proxy settings.
Parameters
array $options [reference]: Options array
object $ch [reference]: cURL Object
array $uri [reference]: URI array
1 call to flickr_curl_set_proxy_settings()
- flickr_curl_http_request in ./
flickr.inc - Performs an HTTP request over cURL. Taken from http://cgit.drupalcode.org/chr/tree/chr.module.
File
- ./
flickr.inc, line 2061 - The Flickr API functions.
Code
function flickr_curl_set_proxy_settings(&$options, &$ch, &$uri) {
// Select the right proxy for the right protocol.
$proxy = 'https' == $uri['scheme'] ? $options['https_proxy'] : $options['http_proxy'];
// Nullify the proxy if the host to send the request to is part of the proxy's
// exceptions.
if (!empty($proxy['exceptions']) && in_array($uri['host'], $proxy['exceptions'])) {
$proxy = NULL;
}
if (!empty($proxy)) {
curl_setopt($ch, CURLOPT_PROXY, $proxy['server']);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy['port']);
// For the time being let's just support HTTP proxies with basic
// authentication.
if (isset($proxy['username']) && isset($proxy['password'])) {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, implode(':', array(
$proxy['username'],
$proxy['password'],
)));
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
}
}
}