]> gitweb.factorcode.org Git - factor.git/blob - libs/httpd/mime.factor
more sql changes
[factor.git] / libs / httpd / mime.factor
1 ! Copyright (C) 2004, 2005 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 IN: httpd
4 USING: io hashtables kernel sequences math namespaces ;
5
6 : file-extension ( filename -- extension )
7     "." split dup length 1 <= [ drop f ] [ peek ] if ;
8
9 : mime-type ( filename -- mime-type )
10     file-extension "mime-types" get
11     hash [ "text/plain" ] unless* ;
12
13 H{
14     { "html"   "text/html"                        }
15     { "txt"    "text/plain"                       }
16     { "xml"    "text/xml"                         }
17     { "css"    "text/css"                         }
18                                                     
19     { "gif"    "image/gif"                        }
20     { "png"    "image/png"                        }
21     { "jpg"    "image/jpeg"                       }
22     { "jpeg"   "image/jpeg"                       }
23                                                     
24     { "jar"    "application/octet-stream"         }
25     { "zip"    "application/octet-stream"         }
26     { "tgz"    "application/octet-stream"         }
27     { "tar.gz" "application/octet-stream"         }
28     { "gz"     "application/octet-stream"         }
29
30     { "pdf"    "application/pdf"                  }
31
32     { "factor" "text/plain"                       }
33     { "fhtml"  "application/x-factor-server-page" }
34 } "mime-types" global set-hash