Zend_Http_Client::_detectFileMimeType PHP Method

_detectFileMimeType() protected method

This method will try to detect the MIME type of a file. If the fileinfo extension is available, it will be used. If not, the mime_magic extension which is deprected but is still available in many PHP setups will be tried. If neither extension is available, the default application/octet-stream MIME type will be returned
protected _detectFileMimeType ( string $file ) : string
$file string File path
return string MIME type
    protected function _detectFileMimeType($file)
    {
        $type = null;
        // First try with fileinfo functions
        if (function_exists('finfo_open')) {
            if (self::$_fileInfoDb === null) {
                self::$_fileInfoDb = @finfo_open(FILEINFO_MIME);
            }
            if (self::$_fileInfoDb) {
                $type = finfo_file(self::$_fileInfoDb, $file);
            }
        } elseif (function_exists('mime_content_type')) {
            $type = mime_content_type($file);
        }
        // Fallback to the default application/octet-stream
        if (!$type) {
            $type = 'application/octet-stream';
        }
        return $type;
    }