protected function getHeader(array $headers, $name) {
        if (!is_string($name))                           throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
        if (!preg_match('/^[a-z]+(-[a-z]+)*$/i', $name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'"');

        // reversely iterate over the array to find the last of duplicate headers
        for (end($headers); key($headers)!==null; prev($headers)){
            $header = current($headers);
            if (strStartsWithI($header, $name.':'))
                return trim(substr($header, strlen($name)+1));
        }
        return null;
    }