unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* MIME type guessing module
@ 2014-12-31 16:36 David Thompson
  2015-01-01  0:14 ` Mike Gerwitz
  2015-01-02 15:33 ` Thien-Thi Nguyen
  0 siblings, 2 replies; 3+ messages in thread
From: David Thompson @ 2014-12-31 16:36 UTC (permalink / raw)
  To: guile-devel

Hello Guile hackers,

Recently I've taken to writing simple web servers in Guile.  Each time I
write one I wish that core Guile came with a procedure to guess the mime
type of a file.  Such a procedure would be very useful when serving
arbitrary static files from disk.

However, I can't figure out the best way to implement it.  Here are 3
possible ways of guessing a MIME type:

1) Use a lookup table that maps file extensions to MIME types.  This is
the simplest method as it would only test file extensions.  Python does
this, see: <https://docs.python.org/2/library/mimetypes.html>

2) Use pipes to read the output of the 'file' utility.  The guessing
will be more accurate because 'file' inspects a file's contents to make
better guesses.

3) Use the FFI to call libmagic.  Same benefits as above, but better
because we can use the FFI instead of subprocesses and pipes.

2 and 3 both have the disadvantage of requiring an additional
dependency, which seems hard to justify for such a minor feature.

I wrote a simple static file server (inspired by Python's
SimpleHTTPServer) that I would like to contribute once this blocker is
resolved.

Thoughts?  Would this be useful at all?

Thanks,

-- 
David Thompson
Web Developer - Free Software Foundation - http://fsf.org
GPG Key: 0FF1D807
Support the FSF: https://fsf.org/donate



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-02 15:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-31 16:36 MIME type guessing module David Thompson
2015-01-01  0:14 ` Mike Gerwitz
2015-01-02 15:33 ` Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).