00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "config.h"
00029 #include "MIMETypeRegistry.h"
00030
00031 namespace WebCore {
00032
00033 struct ExtensionMap {
00034 const char* extension;
00035 const char* mimeType;
00036 };
00037
00038 static const ExtensionMap extensionMap [] = {
00039 { "bmp", "image/bmp" },
00040 { "gif", "image/gif" },
00041 { "html", "text/html" },
00042 { "htm", "text/html" },
00043 { "ico", "image/x-icon" },
00044 { "jpeg", "image/jpeg" },
00045 { "jpg", "image/jpeg" },
00046 { "js", "application/x-javascript" },
00047 { "mng", "video/x-mng" },
00048 { "pbm", "image/x-portable-bitmap" },
00049 { "pgm", "image/x-portable-graymap" },
00050 { "pdf", "application/pdf" },
00051 { "png", "image/png" },
00052 { "ppm", "image/x-portable-pixmap" },
00053 { "rss", "application/rss+xml" },
00054 { "svg", "image/svg+xml" },
00055 { "text", "text/plain" },
00056 { "tif", "image/tiff" },
00057 { "tiff", "image/tiff" },
00058 { "txt", "text/plain" },
00059 { "xbm", "image/x-xbitmap" },
00060 { "xml", "text/xml" },
00061 { "xpm", "image/x-xpm" },
00062 { "xsl", "text/xsl" },
00063 { "xhtml", "application/xhtml+xml" },
00064 { 0, 0 }
00065 };
00066
00067 String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
00068 {
00069 String s = ext.lower();
00070
00071 const ExtensionMap *e = extensionMap;
00072 while (e->extension) {
00073 if (s == e->extension)
00074 return e->mimeType;
00075 ++e;
00076 }
00077
00078 return "application/octet-stream";
00079 }
00080
00081 }