Returns the mimetype if the client sends */*
170332
def get_wildcard_mimetype(self):
		
		mimetype = self.wildcard_mimetype
		if mimetype is None:	# class inherits from module default
			mimetype = WILDCARD_MIMETYPE
		if mimetype is None:	# module is set to None?
			mimetype = 'application/rdf+xml'
		return mimetype
1101000
private static MimeType getParentMimeType(Resource resource) {
        MimeType result = null;
        if (resource != null && (resource = resource.getParent()) != null) {
            ResourceHandle handle = ResourceHandle.use(resource);
            result = getMimeType(handle.getProperty(ResourceUtil.PROP_MIME_TYPE, ""));
            if (result == null) {
                String filename = getResourceName(resource);
                result = getMimeType(filename);
            }
        }
        return result;
    }
1215734
private String detectBinaryTypes(byte[] bytes) {
		// NB: there are a lot of specific mimetypes we can detect by file
		// magic, but we don't want to make too much effort here.
		// "application/octet-stream" is fine if file looks very much like
		// binary but don't know what exactly. Returned value is not really
		// used beyond being non-null. We're only concerned with file formats
		// frequently sent out with imprecise Content-Type.
		switch (bytes[0]) {
		case (byte)0xFF:
			if (bytes[1] == (byte)0xFE) {
				// UTF-16LE BOM
				return null;
			} else if ((bytes[1] & 0xFE) == (byte)0xFA) {
				// audio/mp3
				return "audio/mp3";
			} else if (bytes[1] == (byte)0xD8) {
				// image/jpeg - commonly <FF><D8><FF><E0> or <FF><D8><FF><E1>
				return "image/jpeg";
			}
			// WordPerfect (<FF>WPC) falls in this category.
			// (WordPerfect also has <D8>WPC
			return BINARY_FILE;
		case (byte)0xFE:
			if (bytes[1] == (byte)0xFF) {
				// UTF-16BE BOM
				return null;
			}
			break;
		case (byte)0xF7:
			if (bytes[1] == 0x02 && bytes[2] == 0x01) {
				// unconfirmed.
				return "application/x-dvi";
			}
			break;
		case (byte)0xEF:
			if (bytes[1] == (byte)0xBB && bytes[2] == (byte)0xBF) {
				// UTF-8 BOM
				return null;
			}
			break;
		case (byte)0xD0:
			if (bytes[1] == (byte)0xCF && bytes[2] == 0x11 && bytes[2] == (byte)0xE1) {
				// MS Word.Document.8
				return BINARY_FILE;
			}
			break;
		case (byte)0xCA:
			if (bytes[1] == (byte)0xFE && bytes[2] == (byte)0xBA && bytes[3] == (byte)0xBE) {
				// application/java (class files)
				return "application/java";
			}
			break;
		case (byte)0x89:
			if (bytes[1] == 'P' && bytes[2] == 'N' && bytes[3] == 'G') {
				return "image/png";
			}
			break;
		case 0x00:
			if (bytes[1] == 0x00) {
				// Windows icon resource falls in this category.
				return BINARY_FILE;
			} else if (bytes[1] == 0x01) {
				// TTF?
				return BINARY_FILE;
			}
			break;
		case 0x01:
			if (bytes[1] == (byte)0xB3 || bytes[1] == (byte)0xBA) {
				return "video/mpeg";
			} else if (bytes[1] == 0x00) {
				// very likely is a binary file
				return BINARY_FILE;
			}
			break;
		case 0x1F:
			if (bytes[1] == (byte)0x8B) {
				return "application/x-gzip";
			} else if (bytes[1] == (byte)0x9D) {
				// followed by 0x90
				return "application/x-compress";
			}
			break;
		case '%':
			if (bytes[1] == 'P' && bytes[2] == 'D' && bytes[3] == 'F' && bytes[4] == '-') {
				return "application/pdf";
			} else if (bytes[1] == '!' && bytes[2] == 'P' && bytes[3] == 'S' && bytes[4] == '-') {
				// application/postscript, Type 1 font.
				return "application/postscript";
			}
			break;
		case 'B':
			if (bytes[1] == 'Z' && bytes[2] == 'h') {
				return "application/x-bzip2";
			}
			break;
		case 'F':
			if (bytes[1] == 'W' && bytes[2] == 'S') {
				// followed by <04> or <05>. Also 'CWS<07>?
				return "application/x-shockwave-flash";
			} else if (bytes[1] == 'L' && bytes[2] == 'V' && bytes[3] == 0x01) {
				return "video/x-flv";
			}
			break;
		case 'G':
			if (bytes[1] == 'I' && bytes[2] == 'F' && bytes[3] == '8') {
				// GIF87a or GIF89a
				return "image/gif";
			}
			break;
		case 'M':
			if (bytes[1] == 'Z') {
				// MS-DOS Executable (MZ <00-FF><00-01>)
				if (bytes[3] == 0x00 || bytes[3] == 0x01) {
					return "application/x-dosexec";
				}
			} else if (bytes[1] == 'S' && bytes[2] == 'C' && bytes[3] == 'F') {
				// MS cab file
				return "application/vnd.ms-cab-compressed";
			} else if (bytes[1] == 'T' && bytes[2] == 'h' && bytes[3] == 'd') {
				// MIDI
				return "audio/midi"; // or "application/x-midi"
			}
			break;
		case 'P':
			if (bytes[1] == 'K' && bytes[2] == 0x03 && bytes[3] == 0x04) {
				return "application/zip";
			} else if (bytes[1] == 'E' && bytes[2] == 0x00 && bytes[3] == 0x00 && bytes[4] == 'M' && bytes[5] == 'S') {
				// Windows PE
				return BINARY_FILE;
			}
			break;
		case 'm':
			if (bytes[1] == 'o' && bytes[2] == 'o' && bytes[3] == 'v') {
				return "video/quicktime";
			} else if (bytes[1] == 'd' && bytes[2] == 'a' && bytes[3] == 't') {
				return "video/quicktime";
			}
			break;
		case '{':
			if (bytes[1] == '\\' && bytes[2] == 'r' && bytes[3] == 't' && bytes[4] == 'f' && bytes[5] == '1') {
				return "application/rtf";
			}
			break;
		}

		if (bytes[2] == '-' && bytes[3] == 'l' && bytes[4] == 'h' && bytes[5] == '5' && bytes[6] == '-') {
			// LZH archive
			return BINARY_FILE;
		}
		// Other formats we may want to add
		// "RIFF" <?><?><?><?> "WAVEfmt " - "audio/wav"
		// <DB><A5><2D><00> - commonly with suffix .doc. files command doesn't know this format.
		// <C5><D0><D3><C6><1E><00><00><00> - some EPS has a binary header starting with this, before "%!PS-"
		return null;
	}
1228846
function mimeMatch (expected, actual) {
  // invalid type
  if (expected === false) {
    return false
  }

  // split types
  var actualParts = actual.split('/')
  var expectedParts = expected.split('/')

  // invalid format
  if (actualParts.length !== 2 || expectedParts.length !== 2) {
    return false
  }

  // validate type
  if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) {
    return false
  }

  // validate suffix wildcard
  if (expectedParts[1].substr(0, 2) === '*+') {
    return expectedParts[1].length <= actualParts[1].length + 1 &&
      expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length)
  }

  // validate subtype
  if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) {
    return false
  }

  return true
}
260592
public static String getMimeType(final byte[] data) {
		String mimeType = null;
		try {
			mimeType = MimeUtil.getMagicMimeType(data);
		} catch (final Exception e) {
		} finally {
			if (mimeType == null) {
				mimeType = UNKNOWN_MIME_TYPE;
			}
		}
		return mimeType;
	}
1140247
def _response_mimetype_based_on_accept_header(self):
        
        response_mimetype = None

        if not request.accept_mimetypes:
            response_mimetype = self.default_mimetype
        else:
            all_media_types_wildcard = '*/*'

            for mimetype, q in request.accept_mimetypes:
                if mimetype == all_media_types_wildcard:
                    response_mimetype = self.default_mimetype
                    break
                if mimetype in self.response_formatters:
                    response_mimetype = mimetype
                    break

        return response_mimetype
1373969
def parse(cls, mimetype):
        
        plist = mimetype.split(';')

        main_type, _, sub_type = plist.pop(0).lower().strip().partition('/')
        params = {}

        for p in plist:
            kv = p.split('=')
            if len(kv) != 2:
                continue
            v = kv[1].strip()
            if v:
                params[kv[0].strip()] = v

        return MimeType(main_type, sub_type, params)
641121
def mime_type(filename, mime_tab)
      suffix1 = (/\.(\w+)$/ =~ filename && $1.downcase)
      suffix2 = (/\.(\w+)\.[\w\-]+$/ =~ filename && $1.downcase)
      mime_tab[suffix1] || mime_tab[suffix2] || "application/octet-stream"
    end
973120
function getMime(path) {
          var index = String(path).lastIndexOf(".");
          if (index < 0) {
              return defaultMime;
          }
          var type = exports.mime.types[path.substring(index).toLowerCase()] || defaultMime;
          return (/(text|javascript)/).test(type)
            ? type + "; charset=utf-8"
            : type;
      }
1263572
def mime_type(type, value)
      type = ".#{type}" unless type.to_s[0] == '.'
      ::Rack::Mime::MIME_TYPES[type] = value
    end
44200
def get_content_type(*names):
    """"""
    for name in names:
        if name is not None:
            mimetype, encoding = mimetypes.guess_type(name)
            if mimetype is not None:
                if isinstance(mimetype, bytes):
                    return mimetype.decode("ascii")
                else:
                    return mimetype
    else:
        return "application/octet-stream"
1346073
def mime_type(self, type_: Optional[MimeType] = None) -> str:
        
        key = self._validate_enum(item=type_, enum=MimeType)
        types = MIME_TYPES[key]
        return self.random.choice(types)
1343719
@OverrideOnDemand
  @Nullable
  protected String determineMimeType (@Nonnull final String sFilename, @Nonnull final IReadableResource aResource)
  {
    return MimeTypeInfoManager.getDefaultInstance ().getPrimaryMimeTypeStringForFilename (sFilename);
  }
430586
public static String getMimeTypeForFile(URL url) {
        if (url == null) {
            //The input url is null so we can't retrieve a mimetype, therefore we return null.
            return null;
        }
        String external = url.toExternalForm();
        if (external.indexOf('.') == -1) {
            return BINARY;
        } else {
            String ext = external.substring(external.lastIndexOf('.') + 1);
            String mime = KnownMimeTypes.getMimeTypeByExtension(ext);
            if (mime == null) {
                return BINARY;
            } else {
                return mime;
            }
        }
    }
420736
def get_content_type(self):
        """"""
        ctype = self.part.get_content_type()
        # replace underspecified mime description by a better guess
        if ctype in ['octet/stream', 'application/octet-stream',
                     'application/octetstream']:
            ctype = guess_mimetype(self.get_data())
        return ctype
1353966
def mimetype_from_path(path):
    
    extension = file_extension(path)
    if extension is not None:
        extension = extension.lower()
        if extension in gc.MIMETYPE_MAP:
            return gc.MIMETYPE_MAP[extension]
    return None
270940
function(value) {
      if (!arguments.length) return mimeType;
      mimeType = value == null ? null : value + "";
      return request;
    }