Good practices regarding MIME type

colecmac at protonmail.com colecmac at protonmail.com
Thu Dec 10 21:31:12 GMT 2020


> I chose to set a default text/gemini in case the extension is unknown or
> if the file has no extension.

This is not a good idea for any unrecognized file, extension or not. If you
know the file is UTF-8 text, serve it as "text/plain", otherwise you should
serve it as "application/octet-stream", indicating a generic binary file.

Jetforce used to default to text/plain for all files[1], and it was a problem
because clients will try to display binary data as text, resulting in garbled
data. For example, try running `cat /dev/urandom` and see how that looks.

1: https://github.com/michael-lazar/jetforce/issues/38#issuecomment-659688602


Cheers,
makeworld

P.S. The more accurate term is media type, not MIME type. See
https://www.iana.org/assignments/media-types/media-types.xhtml, or
just Wikipedia :)




More information about the Gemini mailing list