HTTP_Encoder::__construct PHP Method

__construct() public method

Get an HTTP Encoder object
public __construct ( array $spec )
$spec array options 'content': (string required) content to be encoded 'type': (string) if set, the Content-Type header will have this value. 'method: (string) only set this if you are forcing a particular encoding method. If not set, the best method will be chosen by getAcceptedEncoding() The available methods are 'gzip', 'deflate', 'compress', and '' (no encoding)
    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();
        }
    }