/*
Sets the given mime type, so that it maps to the given extension(s)
501722
public function addMimeTypeToExtension($mime_type, $extension)
    {
        if (is_array($extension)) {
            $this->mime_type_to_extensions[$mime_type] = $extension;
        } else {
            $this->mime_type_to_extensions[$mime_type] = array($extension);
        }

        return true;
    }
206116
def setDerivedTypeContents(self, extensions=None, restrictions=None):
        
        if extensions:
            ofwhat = list(self.ofwhat)
            if type(extensions) in _seqtypes:
                ofwhat += list(extensions)
            else:
                ofwhat.append(extensions)
        elif restrictions:
            if type(restrictions) in _seqtypes:
                ofwhat = restrictions
            else:
                ofwhat = (restrictions,)
        else:
            return
        self.ofwhat = tuple(ofwhat)
        self.lenofwhat = len(self.ofwhat)
1372462
public static function getExtensionForType($mime_type) {
		static::ensureDataLoaded();

		if (!static::hasType($mime_type)) {
			return;
		}

		$extensions = static::$mime_types[$mime_type];
		if (is_array($extensions)) {
			return $extensions[0];
		}

		return $extensions;
	}
1020029
public function MapExtensionToMimeType($mime_type, $extension)
    {
        if (!isset($this->mime_type_to_extensions[$mime_type])) {
            $this->mime_type_to_extensions[$mime_type] = array($extension);
        } else {
            $this->mime_type_to_extensions[$mime_type][] = $extension;
        }

        return true;
    }
283328
def plugin_name_by_mime_type(mime_type, mime_name, file_extension):
    ""

    return MIME_TYPE_TO_PLUGIN_NAME.get(
        normalize_mime_type(mime_type, mime_name, file_extension), None
    )
672277
void writeExtensionByte(int extensionType, int value) throws IOException {
        output.write(FIX_EXT_1);
        output.write(extensionType);
        output.write(value);
    }
840603
function setMimeType( $mime )
    {
        $this->Type = $mime;
        list ( $this->MimeCategory, $this->MimePart ) = explode( '/', $mime, 2 );
    }
434834
public void addMimeMapping(String extension, String type) {
        handler.getMimeTypes().addMimeMapping(extension, type);
    }
850245
public function addExtensionToMimeType($extension, $mime_type)
    {
        if (is_array($mime_type)) {
            $this->extension_to_mime_types[$extension] = $mime_type;
        } else {
            $this->extension_to_mime_types[$extension] = array($mime_type);
        }

        return true;
    }
122674
def add_mimetype(mimedb, mimetype, extension):
    """"""
    # If extension is already a common type, strict=True must be used.
    strict = extension in mimedb.types_map[True]
    mimedb.add_type(mimetype, extension, strict=strict)
1005863
private static void parseMimeMappings(final MimeMappingType mimeMappingType, final WebApp webApp) {
		final WebAppMimeMapping mimeMapping = new WebAppMimeMapping();
		mimeMapping.setExtension(mimeMappingType.getExtension().getValue());
		mimeMapping.setMimeType(mimeMappingType.getMimeType().getValue());
		webApp.addMimeMapping(mimeMapping);
	}
147624
function mimeTypeOverride( $mimeData )
    {
        if ( $this->hasMIMETypeSetting( $mimeData ) )
        {
            $settings = $this->mimeTypeSetting( $mimeData );
            if ( $settings )
            {
                return $settings['override_mime_type'];
            }
        }
        return false;
    }
252487
public function setContentType( $mimeType, $charset = 'UTF-8', $format = self::FORMAT_FIXED )
	{
		$value	= trim( $mimeType ).'; charset='.trim( $charset ).'; format='.trim( $format );
		$this->headers->setFieldPair( 'Content-Type', $value );
	}
660493
function setContentType( $type = false, $charset = false,
                             $transferEncoding = false, $disposition = false, $boundary = false )
    {
        if ( $type )
        {
            $this->ContentType['type'] = $type;
        }
        if ( $charset )
            $this->ContentType['charset'] = $charset;
        if ( $transferEncoding )
            $this->ContentType['transfer-encoding'] = $transferEncoding;
        if ( $disposition )
            $this->ContentType['disposition'] = $disposition;
        if ( $boundary )
            $this->ContentType['boundary'] = $boundary;

        // if the body was already defined
        if ( $this->Mail->body instanceof ezcMailText )
        {
            // if the content-type is in the form of e.g. 'text/plain'
            if ( strpos( $this->ContentType['type'] ,'/' ) !== false )
            {
                list( $type, $subType ) = explode( '/', $this->ContentType['type'] );
                $this->Mail->body->subType = $subType;
            }
        }
    }
475794
public static boolean hasMimeType(String mimeType) {
        if (mimeType == null || mimeType.isEmpty()) {
            return false;
        }
        return mimeTypeToExtensionMap.containsKey(mimeType);
    }
1048445
public void set(String name, Object obj) throws IOException {
        if (obj instanceof Extension) {
            map.put(name, (Extension)obj);
        } else {
            throw new IOException("Unknown extension type.");
        }
    }
871092
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;
                }
            }
        }
    }