[chatter] r11809 - in trunk/libraries/network/koala: config sources/koala
cgay at mccarthy.opendylan.org
cgay at mccarthy.opendylan.org
Mon May 12 11:01:05 CEST 2008
Author: cgay
Date: Mon May 12 11:01:04 2008
New Revision: 11809
Modified:
trunk/libraries/network/koala/config/koala-config.xml
trunk/libraries/network/koala/config/mime-type-map.xml
trunk/libraries/network/koala/sources/koala/config.dylan
trunk/libraries/network/koala/sources/koala/server.dylan
trunk/libraries/network/koala/sources/koala/static-files.dylan
trunk/libraries/network/koala/sources/koala/variables.dylan
trunk/libraries/network/koala/sources/koala/vhost.dylan
Log:
job: koala
It is no longer necessary to load a config file to have a reasonable
mime-type map. Mime-type maps are now per server.
Modified: trunk/libraries/network/koala/config/koala-config.xml
==============================================================================
Binary files. No diff available.
Modified: trunk/libraries/network/koala/config/mime-type-map.xml
==============================================================================
Binary files. No diff available.
Modified: trunk/libraries/network/koala/sources/koala/config.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/config.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/config.dylan Mon May 12 11:01:04 2008
@@ -425,17 +425,19 @@
merge-locators(merge-locators(as(<file-locator>, filename),
as(<directory-locator>, $koala-config-dir)),
server-root(*server*)));
-
log-info("Loading mime-type map from %s", mime-type-loc);
let mime-text = file-contents(mime-type-loc);
if (mime-text)
let mime-xml :: xml$<document> = xml$parse-document(mime-text);
- log-info("Transforming mime-type map...");
- log-info("%s",
- with-output-to-string (stream)
- // Transforming the document side-effects *mime-type-map*.
- xml$transform-document(mime-xml, state: $mime-type, stream: stream);
- end);
+ let clear = get-attr(node, #"clear");
+ if (clear & true-value?(clear))
+ log-info("Clearing default mime type mappings.");
+ remove-all-keys!(server-mime-type-map(*server*));
+ end;
+ with-output-to-string (stream)
+ // Transforming the document side-effects the server's mime type map.
+ xml$transform-document(mime-xml, state: $mime-type, stream: stream);
+ end;
else
warn("mime-type map %s not found", mime-type-loc);
end if;
@@ -447,9 +449,10 @@
state :: <mime-type>,
stream :: <stream>)
let mime-type = get-attr(node, #"id");
+ let mime-type-map = server-mime-type-map(*server*);
for (child in xml$node-children(node))
if (xml$name(child) = #"extension")
- *mime-type-map*[as(<symbol>, xml$text(child))] := mime-type;
+ mime-type-map[as(<symbol>, xml$text(child))] := mime-type;
else
warn("Skipping: %s %s %s: not an extension node!",
mime-type, xml$name(child), xml$text(child));
Modified: trunk/libraries/network/koala/sources/koala/server.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/server.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/server.dylan Mon May 12 11:01:04 2008
@@ -82,6 +82,8 @@
slot server-root :: <directory-locator>
= parent-directory(locator-directory(as(<file-locator>, application-filename())));
+ constant slot server-mime-type-map :: <table> = make(<table>);
+
end class <server>;
// API
@@ -125,6 +127,11 @@
document-root(default-virtual-host(server))
:= as(<directory-locator>, doc-root);
end;
+ // Copy mime type map in, since it may be modified when config loaded.
+ let tmap :: <table> = server.server-mime-type-map;
+ for (mime-type keyed-by extension in $default-mime-type-map)
+ tmap[extension] := mime-type;
+ end;
end method initialize;
// Keep some stats on user-agents
Modified: trunk/libraries/network/koala/sources/koala/static-files.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/static-files.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/static-files.dylan Mon May 12 11:01:04 2008
@@ -164,11 +164,11 @@
end method locator-below-root?;
-// Get MIME Type for file name
-define method get-mime-type (locator :: <locator>) => (mime-type :: <string>)
+define method get-mime-type
+ (locator :: <locator>) => (mime-type :: <string>)
let extension = locator-extension(locator);
let sym = extension & ~empty?(extension) & as(<symbol>, extension);
- let mime-type = ((sym & element(*mime-type-map*, sym, default: #f))
+ let mime-type = ((sym & element(server-mime-type-map(*server*), sym, default: #f))
| default-static-content-type(*virtual-host*));
log-debug("extension = %=, sym = %=, mime-type = %=", extension, sym, mime-type);
mime-type;
Modified: trunk/libraries/network/koala/sources/koala/variables.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/variables.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/variables.dylan Mon May 12 11:01:04 2008
@@ -2,14 +2,194 @@
Synopsis: Some globals that don't belong anywhere else in particular.
Most are configurable in the koala-config.xml file.
Author: Carl Gay
-Copyright: Copyright (c) 2001 Carl L. Gay. All rights reserved.
+Copyright: Copyright (c) 2001-2008 Carl L. Gay. All rights reserved.
License: Functional Objects Library Public License Version 1.0
Warranty: Distributed WITHOUT WARRANTY OF ANY KIND
// TODO: The follow 3 should probably be per vhost.
-define variable *mime-type-map* :: <table> = make(<table>);
+// Entries in this table may be overridden by entries in the mime-type-map
+// file specified in the Koala config file, if any.
+//
+define table $default-mime-type-map = {
+ #"ez" => "application/andrew-inset",
+ #"bz2" => "application/x-bzip2",
+ #"tar" => "application/tar",
+ #"rpm" => "application/x-rpm",
+ #"deb" => "application/x-deb",
+ #"gz" => "application/x-gzip",
+ #"tgz" => "application/x-gzip",
+ #"hqx" => "application/mac-binhex40",
+ #"cpt" => "application/mac-compactpro",
+ #"mathml" => "application/mathml+xml",
+ #"doc" => "application/msword",
+ #"bin" => "application/octet-stream",
+ #"dms" => "application/octet-stream",
+ #"lha" => "application/octet-stream",
+ #"lzh" => "application/octet-stream",
+ #"exe" => "application/octet-stream",
+ #"class" => "application/octet-stream",
+ #"so" => "application/octet-stream",
+ #"dll" => "application/octet-stream",
+ #"dmg" => "application/octet-stream",
+ #"oda" => "application/oda",
+ #"ogg" => "application/ogg",
+ #"pdf" => "application/pdf",
+ #"ai" => "application/postscript",
+ #"eps" => "application/postscript",
+ #"ps" => "application/postscript",
+ #"rdf" => "application/rdf+xml",
+ #"rtf" => "application/rtf",
+ #"smi" => "application/smil",
+ #"smil" => "application/smil",
+ #"gram" => "application/srgs",
+ #"grxml" => "application/srgs+xml",
+ #"mif" => "application/vnd.mif",
+ #"xls" => "application/vnd.ms-excel",
+ #"ppt" => "application/vnd.ms-powerpoint",
+ #"wbxml" => "application/vnd.wap.wbxml",
+ #"wmlc" => "application/vnd.wap.wmlc",
+ #"wmlsc" => "application/vnd.wap.wmlscriptc",
+ #"vxml" => "application/voicexml+xml",
+ #"bcpio" => "application/x-bcpio",
+ #"vcd" => "application/x-cdlink",
+ #"pgn" => "application/x-chess-pgn",
+ #"cpio" => "application/x-cpio",
+ #"csh" => "application/x-csh",
+ #"dcr" => "application/x-director",
+ #"dir" => "application/x-director",
+ #"dxr" => "application/x-director",
+ #"dvi" => "application/x-dvi",
+ #"spl" => "application/x-futuresplash",
+ #"gtar" => "application/x-gtar",
+ #"hdf" => "application/x-hdf",
+ #"js" => "application/x-javascript",
+ #"jnlp" => "application/x-java-jnlp-file",
+ #"skp" => "application/x-koan",
+ #"skd" => "application/x-koan",
+ #"skt" => "application/x-koan",
+ #"skm" => "application/x-koan",
+ #"latex" => "application/x-latex",
+ #"nc" => "application/x-netcdf",
+ #"cdf" => "application/x-netcdf",
+ #"sh" => "application/x-sh",
+ #"shar" => "application/x-shar",
+ #"swf" => "application/x-shockwave-flash",
+ #"sit" => "application/x-stuffit",
+ #"sv4cpio" => "application/x-sv4cpio",
+ #"sv4crc" => "application/x-sv4crc",
+ #"tar" => "application/x-tar",
+ #"tcl" => "application/x-tcl",
+ #"tex" => "application/x-tex",
+ #"texinfo" => "application/x-texinfo",
+ #"texi" => "application/x-texinfo",
+ #"t" => "application/x-troff",
+ #"tr" => "application/x-troff",
+ #"roff" => "application/x-troff",
+ #"man" => "application/x-troff-man",
+ #"me" => "application/x-troff-me",
+ #"ms" => "application/x-troff-ms",
+ #"ustar" => "application/x-ustar",
+ #"src" => "application/x-wais-source",
+ #"xhtml" => "application/xhtml+xml",
+ #"xht" => "application/xhtml+xml",
+ #"xslt" => "application/xslt+xml",
+ #"xml" => "application/xml",
+ #"xsl" => "application/xml",
+ #"dtd" => "application/xml-dtd",
+ #"zip" => "application/zip",
+ #"au" => "audio/basic",
+ #"snd" => "audio/basic",
+ #"mid" => "audio/midi",
+ #"midi" => "audio/midi",
+ #"kar" => "audio/midi",
+ #"mpga" => "audio/mpeg",
+ #"mp2" => "audio/mpeg",
+ #"mp3" => "audio/mpeg",
+ #"aif" => "audio/x-aiff",
+ #"aiff" => "audio/x-aiff",
+ #"aifc" => "audio/x-aiff",
+ #"m3u" => "audio/x-mpegurl",
+ #"ram" => "audio/x-pn-realaudio",
+ #"rm" => "audio/x-pn-realaudio",
+ #"rpm" => "audio/x-pn-realaudio-plugin",
+ #"ra" => "audio/x-realaudio",
+ #"wav" => "audio/x-wav",
+ #"pdb" => "chemical/x-pdb",
+ #"xyz" => "chemical/x-xyz",
+ #"bmp" => "image/bmp",
+ #"cgm" => "image/cgm",
+ #"gif" => "image/gif",
+ #"ief" => "image/ief",
+ #"jpeg" => "image/jpeg",
+ #"jpg" => "image/jpeg",
+ #"jpe" => "image/jpeg",
+ #"jp2" => "image/jp2",
+ #"pict" => "image/pict",
+ #"pic" => "image/pict",
+ #"pct" => "image/pict",
+ #"png" => "image/png",
+ #"tga" => "image/targa",
+ #"jng" => "image/x-jng",
+ #"svg" => "image/svg+xml",
+ #"tiff" => "image/tiff",
+ #"tif" => "image/tiff",
+ #"djvu" => "image/vnd.djvu",
+ #"djv" => "image/vnd.djvu",
+ #"wbmp" => "image/vnd.wap.wbmp",
+ #"ras" => "image/x-cmu-raster",
+ #"pntg" => "image/x-macpaint",
+ #"pnt" => "image/x-macpaint",
+ #"mac" => "image/x-macpaint",
+ #"ico" => "image/x-icon",
+ #"pnm" => "image/x-portable-anymap",
+ #"pbm" => "image/x-portable-bitmap",
+ #"pgm" => "image/x-portable-graymap",
+ #"ppm" => "image/x-portable-pixmap",
+ #"qtif" => "image/x-quicktime",
+ #"qti" => "image/x-quicktime",
+ #"rgb" => "image/x-rgb",
+ #"xbm" => "image/x-xbitmap",
+ #"xpm" => "image/x-xpixmap",
+ #"xwd" => "image/x-xwindowdump",
+ #"igs" => "model/iges",
+ #"iges" => "model/iges",
+ #"msh" => "model/mesh",
+ #"mesh" => "model/mesh",
+ #"silo" => "model/mesh",
+ #"wrl" => "model/vrml",
+ #"vrml" => "model/vrml",
+ #"ics" => "text/calendar",
+ #"ifb" => "text/calendar",
+ #"css" => "text/css",
+ #"html" => "text/html; charset=utf-8",
+ #"htm" => "text/html; charset=utf-8",
+ #"asc" => "text/plain",
+ #"txt" => "text/plain",
+ #"rtx" => "text/richtext",
+ #"rtf" => "text/rtf",
+ #"sgml" => "text/sgml",
+ #"sgm" => "text/sgml",
+ #"tsv" => "text/tab-separated-values",
+ #"wml" => "text/vnd.wap.wml",
+ #"wmls" => "text/vnd.wap.wmlscript",
+ #"etx" => "text/x-setext",
+ #"mp4" => "video/mp4",
+ #"mpeg" => "video/mpeg",
+ #"mpg" => "video/mpeg",
+ #"mpe" => "video/mpeg",
+ #"mng" => "video/x-mng",
+ #"qt" => "video/quicktime",
+ #"mov" => "video/quicktime",
+ #"mp4" => "video/mp4",
+ #"mxu" => "video/vnd.mpegurl",
+ #"dv" => "video/x-dv",
+ #"dif" => "video/x-dv",
+ #"avi" => "video/x-msvideo",
+ #"movie" => "video/x-sgi-movie",
+ #"ice" => "x-conference/x-cooltalk"
+ };
// Since logging is done on a per-vhost basis, this hack is needed
Modified: trunk/libraries/network/koala/sources/koala/vhost.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/vhost.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/vhost.dylan Mon May 12 11:01:04 2008
@@ -131,7 +131,7 @@
as(<file-locator>, "index.htm"));
// The value sent in the "Content-Type" header for static file responses if
- // no other value is set. See *mime-type-map*.
+ // no other value is set. See server-mime-type-map.
slot default-static-content-type :: <string> = "application/octet-stream";
// The value sent in the "Content-Type" header for dynamic responses if no
More information about the chatter
mailing list