function _chr_curl_set_port in cURL HTTP Request 7
Same name and namespace in other branches
- 6 chr.module \_chr_curl_set_port()
Set port options.
Parameters
array $options [reference]: Options array
object $ch [reference]: cURL Object
array $uri [reference]: URI array
Return value
boolean Returns TRUE if they were set properly, FALSE otherwise.
1 call to _chr_curl_set_port()
- chr_curl_http_request in ./
chr.module - Performs an HTTP request.
File
- ./
chr.module, line 480 - cURL HTTP Request methods
Code
function _chr_curl_set_port(&$options, &$ch, &$uri) {
$default_ports = array(
'http' => 80,
'feed' => 80,
'https' => 443,
);
if (array_key_exists($uri['scheme'], $default_ports)) {
if (!isset($uri['port'])) {
$uri['port'] = $default_ports[$uri['scheme']];
}
// RFC 2616: "non-standard ports MUST, default ports MAY be included".
// We don't add the standard port to prevent from breaking rewrite rules
// checking the host that do not take into account the port number.
$options['headers']['Host'] = $uri['host'] . ($uri['port'] != 80 ? ':' . $uri['port'] : '');
return TRUE;
}
else {
return FALSE;
}
}