public function __construct($spec)
{
$this->_useMbStrlen = function_exists('mb_strlen') && ini_get('mbstring.func_overload') !== '' && (int) ini_get('mbstring.func_overload') & 2;
$this->_content = $spec['content'];
$this->_headers['Content-Length'] = $this->_useMbStrlen ? (string) mb_strlen($this->_content, '8bit') : (string) strlen($this->_content);
if (isset($spec['type'])) {
$this->_headers['Content-Type'] = $spec['type'];
}
if (isset($spec['method']) && in_array($spec['method'], array('gzip', 'deflate', 'compress', ''))) {
$this->_encodeMethod = array($spec['method'], $spec['method']);
} else {
$this->_encodeMethod = self::getAcceptedEncoding();
}
}