private static String getMimeType(ServletContext context, String path) {

        // If mimetype is known, use defined mimetype
        String mimetype = context.getMimeType(path);
        if (mimetype != null)
            return mimetype;

        // Otherwise, default to application/octet-stream
        return "application/octet-stream";

    }
Derives a mimetype from the filename within the given path using the
given ServletContext, if possible.

@param context
    The ServletContext to use to derive the mimetype.

@param path
    The path to derive the mimetype from.

@return
    An appropriate mimetype based on the name of the file in the path,
    or "application/octet-stream" if no mimetype could be determined.
guacamole/src/main/java/org/apache/guacamole/resource/WebApplicationResource.java