Workerman\WebServer::initMimeTypeMap PHP Method

initMimeTypeMap() public method

Init mime map.
public initMimeTypeMap ( ) : void
return void
    public function initMimeTypeMap()
    {
        $mime_file = Http::getMimeTypesFile();
        if (!is_file($mime_file)) {
            $this->log("{$mime_file} mime.type file not fond");
            return;
        }
        $items = file($mime_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        if (!is_array($items)) {
            $this->log("get {$mime_file} mime.type content fail");
            return;
        }
        foreach ($items as $content) {
            if (preg_match("/\\s*(\\S+)\\s+(\\S.+)/", $content, $match)) {
                $mime_type = $match[1];
                $workerman_file_extension_var = $match[2];
                $workerman_file_extension_array = explode(' ', substr($workerman_file_extension_var, 0, -1));
                foreach ($workerman_file_extension_array as $workerman_file_extension) {
                    self::$mimeTypeMap[$workerman_file_extension] = $mime_type;
                }
            }
        }
    }