Prepare the request headers
@ignore
array
protected function prepareHeaders($host, $port) {
$headers = array();
// Set the host header
if (!isset($this->headers['host'])) {
// If the port is not default, add it
if ($port !== 80 and $port !== 443) {
$host .= ':' . $port;
}
$headers[] = "Host: {$host}";
}
// Set the connection header
if (!isset($this->headers['connection'])) {
$headers[] = "Connection: close";
}
// Set the user agent header
if (!isset($this->headers['user-agent'])) {
$headers[] = "User-Agent: {$this->config['useragent']}";
}
// If we have _rawPostData set, set the content-length header
if (isset($this->rawPostData)) {
$headers[] = "Content-Length: " . strlen($this->rawPostData);
}
// Add all other user defined headers
foreach ($this->headers as $header) {
list($name, $value) = $header;
if (is_array($value)) {
$value = implode(', ', $value);
}
$headers[] = "{$name}: {$value}";
}
return $headers;
}