public function __construct(array $config = array())
{
$defaults = array('message' => null, 'status' => null, 'type' => null, 'cookies' => array());
parent::__construct($config + $defaults);
if ($this->_config['message']) {
$this->body = $this->_parseMessage($this->_config['message']);
}
if ($this->headers('Transfer-Encoding')) {
$this->body = $this->_httpChunkedDecode($this->body);
}
if ($status = $this->_config['status']) {
$this->status($status);
}
if ($cookies = $this->headers('Set-Cookie')) {
$this->_parseCookies($cookies);
}
if ($cookies = $this->_config['cookies']) {
$this->cookies($cookies);
}
if ($type = $this->_config['type']) {
$this->type($type);
}
if (!($header = $this->headers('Content-Type'))) {
return;
}
$header = is_array($header) ? end($header) : $header;
preg_match('/([-\\w\\/\\.+]+)(;\\s*?charset=(.+))?/i', $header, $match);
if (isset($match[1])) {
$this->type(trim($match[1]));
}
if (isset($match[3])) {
$this->encoding = strtoupper(trim($match[3]));
}
}