ocaml-cohttp
ocaml-cohttp copied to clipboard
cohttp_server_{lwt,async} should serve more useful mime types
Lots of files that are "obviously" ascii text are served as application/octet-stream and lots of files that have precise types are served with those rather than something useful like text/plain (markdown and ocaml source come to mind). This needs something heuristic and maybe a magic number library.
Agreed, or a short term fix to the mime types database for common things like Markdown and OCaml sources.
Unfortunately, the mime types database is technically correct (the best kind of correct). It's browsers that are stuck in 1998 with their poor mime type handling and mime alias facilities.
We need a small amount of magic like is_probably_ascii : path:string -> bool for when type is application/octet-stream as well as some addition to the database that describes a fallback type list. Then, we can do proper conneg (I wrote the media range parsing long ago) and serve the fallback type with a Vary header when we select text/plain over text/x-ocaml (or whatever).