ocaml-cohttp icon indicating copy to clipboard operation
ocaml-cohttp copied to clipboard

cohttp_server_{lwt,async} should serve more useful mime types

Open dsheets opened this issue 10 years ago • 2 comments
trafficstars

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.

dsheets avatar Mar 04 '15 15:03 dsheets

Agreed, or a short term fix to the mime types database for common things like Markdown and OCaml sources.

avsm avatar Mar 04 '15 15:03 avsm

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).

dsheets avatar Mar 04 '15 16:03 dsheets