public function addHeader($name, $value, $append = false)
{
// normalize header names in case of 'Content-type' into 'Content-Type'
$name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name)));
// check if we've a Set-Cookie header to process
if ($this->hasHeader($name) && $append === true) {
// then check if we've already one cookie header available
if (is_array($headerValue = $this->getHeader($name))) {
$headerValue[] = $value;
} else {
$headerValue = array($headerValue, $value);
}
// if no cookie header simple add it
$this->headers[$name] = $headerValue;
} else {
$this->headers[$name] = $value;
}
}