protected function EasyRdf_Http_Client::prepareHeaders in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Client.php \EasyRdf_Http_Client::prepareHeaders()
Prepare the request headers
@ignore
Return value
array
1 call to EasyRdf_Http_Client::prepareHeaders()
- EasyRdf_Http_Client::request in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Http/ Client.php - Send the HTTP request and return an HTTP response object
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Http/ Client.php, line 518
Class
- EasyRdf_Http_Client
- This class is an implemetation of an HTTP client in PHP. It supports basic HTTP 1.0 and 1.1 requests. For a more complete implementation try Zend_Http_Client.
Code
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;
}