From 175e14b3b144537644e65ca76f1fca5c56fd44e9 Mon Sep 17 00:00:00 2001 From: pho Date: Fri, 20 Apr 2007 23:51:25 +0900 Subject: [PATCH] is better than +/+ darcs-hash:20070420145125-62b54-23b1d7f9a2def6491adff61696ca9c7ebfa49667.gz --- Network/HTTP/Lucu.hs | 10 +- Network/HTTP/Lucu/ETag.hs | 2 +- Network/HTTP/Lucu/HttpVersion.hs | 8 +- Network/HTTP/Lucu/MIMEType.hs | 43 ++- .../HTTP/Lucu/MIMEType/DefaultExtensionMap.hs | 352 +++++++++--------- Network/HTTP/Lucu/MIMEType/Guess.hs | 6 +- Network/HTTP/Lucu/Resource/Tree.hs | 2 +- Network/HTTP/Lucu/Response.hs | 4 +- examples/HelloWorld.hs | 7 +- 9 files changed, 219 insertions(+), 215 deletions(-) diff --git a/Network/HTTP/Lucu.hs b/Network/HTTP/Lucu.hs index b2c88c6..6f6e4d9 100644 --- a/Network/HTTP/Lucu.hs +++ b/Network/HTTP/Lucu.hs @@ -16,14 +16,10 @@ module Network.HTTP.Lucu -- MIMEType , MIMEType(..) - , (+/+) - , (+:+) - , (+=+) + , () + , (<:>) + , (<=>) - -- Request - , Method(..) - , Request(..) - -- Resource (driftTo だけは要らない) , module Network.HTTP.Lucu.Resource diff --git a/Network/HTTP/Lucu/ETag.hs b/Network/HTTP/Lucu/ETag.hs index 8565883..bdb1473 100644 --- a/Network/HTTP/Lucu/ETag.hs +++ b/Network/HTTP/Lucu/ETag.hs @@ -1,6 +1,6 @@ -- #prune --- |Creation and comparison of entity tags. +-- |Manipulation of entity tags. module Network.HTTP.Lucu.ETag ( ETag(..) , strongETag diff --git a/Network/HTTP/Lucu/HttpVersion.hs b/Network/HTTP/Lucu/HttpVersion.hs index 9b955d3..38d0e5b 100644 --- a/Network/HTTP/Lucu/HttpVersion.hs +++ b/Network/HTTP/Lucu/HttpVersion.hs @@ -1,7 +1,10 @@ +-- #prune + +-- |Manipulation of HTTP version string. module Network.HTTP.Lucu.HttpVersion ( HttpVersion(..) - , httpVersionP -- Parser HttpVersion - , hPutHttpVersion -- Handle -> HttpVersion -> IO () + , httpVersionP + , hPutHttpVersion ) where @@ -10,6 +13,7 @@ import Data.ByteString.Lazy.Char8 (ByteString) import Network.HTTP.Lucu.Parser import System.IO +-- |@'HttpVersion' major minor@ represents \"HTTP\/major.minor\". data HttpVersion = HttpVersion Int Int deriving (Eq) diff --git a/Network/HTTP/Lucu/MIMEType.hs b/Network/HTTP/Lucu/MIMEType.hs index bd799e0..93b8f1f 100644 --- a/Network/HTTP/Lucu/MIMEType.hs +++ b/Network/HTTP/Lucu/MIMEType.hs @@ -1,10 +1,13 @@ +-- #prune + +-- |Manipulation of MIME Types. module Network.HTTP.Lucu.MIMEType ( MIMEType(..) - , (+/+) -- String -> String -> MIMEType - , (+:+) -- MIMEType -> (String, String) -> MIMEType - , (+=+) -- String -> String -> (String, String) - , mimeTypeP -- Parser MIMEType - , mimeTypeListP -- Parser [MIMEType] + , () + , (<:>) + , (<=>) + , mimeTypeP + , mimeTypeListP ) where @@ -12,7 +15,8 @@ import Network.HTTP.Lucu.Parser import Network.HTTP.Lucu.Parser.Http import Network.HTTP.Lucu.Utils - +-- |@'MIMEType' \"major\" \"minor\" [(\"name\", \"value\")]@ +-- represents \"major\/minor; name=value\". data MIMEType = MIMEType { mtMajor :: String , mtMinor :: String @@ -36,25 +40,28 @@ instance Show MIMEType where value -infix 9 +/+, +=+ -infixl 8 +:+ - +infix 9 , <=> +infixl 8 <:> -(+/+) :: String -> String -> MIMEType -maj +/+ min +-- |@\"major\" \<\/\> \"minor\"@ constructs a MIME Type +-- \"major\/minor\". +() :: String -> String -> MIMEType +maj min = MIMEType maj min [] - -(+:+) :: MIMEType -> (String, String) -> MIMEType -mt@(MIMEType _ _ params) +:+ pair +-- |\<\:\> appends a @(name, value)@ pair to a MIME Type. +(<:>) :: MIMEType -> (String, String) -> MIMEType +mt@(MIMEType _ _ params) <:> pair = mt { mtParams = mtParams mt ++ [pair] } - -(+=+) :: String -> String -> (String, String) -name +=+ value = (name, value) - +-- |\<\=\> takes two strings and makes a tuple of them. So you can say +-- @\"text\" \<\/\> \"xml\" \<\:\> \"charset\" \<\=\> \"UTF-8\" \<\:\> +-- \"q\" \<\=\> \"0.9\"@ to represent \"text\/xml; charset=UTF-8; +-- q=0.9\". +(<=>) :: String -> String -> (String, String) +name <=> value = (name, value) mimeTypeP :: Parser MIMEType diff --git a/Network/HTTP/Lucu/MIMEType/DefaultExtensionMap.hs b/Network/HTTP/Lucu/MIMEType/DefaultExtensionMap.hs index 642afb2..cdeb0e8 100644 --- a/Network/HTTP/Lucu/MIMEType/DefaultExtensionMap.hs +++ b/Network/HTTP/Lucu/MIMEType/DefaultExtensionMap.hs @@ -11,179 +11,179 @@ import Data.Map (Map) defaultExtensionMap :: Map String MIMEType defaultExtensionMap = M.fromList - [("3gp", "application" +/+ "x-3gp"), ("669", "audio" +/+ "x-mod"), - ("Z", "application" +/+ "x-compress"), - ("a", "application" +/+ "x-ar"), ("ac3", "audio" +/+ "x-ac3"), - ("ai", "application" +/+ "postscript"), - ("aif", "audio" +/+ "x-aiff"), ("aifc", "audio" +/+ "x-aiff"), - ("aiff", "audio" +/+ "x-aiff"), ("amf", "audio" +/+ "x-mod"), - ("anx", "application" +/+ "ogg"), - ("ape", "application" +/+ "x-ape"), ("asc", "text" +/+ "plain"), - ("asf", "video" +/+ "x-ms-asf"), - ("atom", "application" +/+ "atom+xml"), ("au", "audio" +/+ "x-au"), - ("avi", "video" +/+ "x-msvideo"), - ("bcpio", "application" +/+ "x-bcpio"), - ("bin", "application" +/+ "octet-stream"), - ("bmp", "image" +/+ "bmp"), ("bz2", "application" +/+ "x-bzip"), - ("cabal", "text" +/+ "x-cabal"), - ("cdf", "application" +/+ "x-netcdf"), ("cgm", "image" +/+ "cgm"), - ("class", "application" +/+ "octet-stream"), - ("cpio", "application" +/+ "x-cpio"), - ("cpt", "application" +/+ "mac-compactpro"), - ("csh", "application" +/+ "x-csh"), ("css", "text" +/+ "css"), - ("dcr", "application" +/+ "x-director"), - ("dif", "video" +/+ "x-dv"), - ("dir", "application" +/+ "x-director"), - ("djv", "image" +/+ "vnd.djvu"), ("djvu", "image" +/+ "vnd.djvu"), - ("dll", "application" +/+ "octet-stream"), - ("dmg", "application" +/+ "octet-stream"), - ("dms", "application" +/+ "octet-stream"), - ("doc", "application" +/+ "msword"), ("dsm", "audio" +/+ "x-mod"), - ("dtd", "application" +/+ "xml-dtd"), ("dv", "video" +/+ "x-dv"), - ("dvi", "application" +/+ "x-dvi"), - ("dxr", "application" +/+ "x-director"), - ("eps", "application" +/+ "postscript"), - ("etx", "text" +/+ "x-setext"), - ("exe", "application" +/+ "octet-stream"), - ("ez", "application" +/+ "andrew-inset"), - ("far", "audio" +/+ "x-mod"), ("flac", "audio" +/+ "x-flac"), - ("flc", "video" +/+ "x-fli"), ("fli", "video" +/+ "x-fli"), - ("flv", "video" +/+ "x-flv"), ("gdm", "audio" +/+ "x-mod"), - ("gif", "image" +/+ "gif"), ("gram", "application" +/+ "srgs"), - ("grxml", "application" +/+ "srgs+xml"), - ("gtar", "application" +/+ "x-gtar"), - ("gz", "application" +/+ "x-gzip"), - ("hdf", "application" +/+ "x-hdf"), - ("hi", "application" +/+ "octet-stream"), - ("hqx", "application" +/+ "mac-binhex40"), - ("hs", "text" +/+ "x-haskell"), ("htm", "text" +/+ "html"), - ("html", "text" +/+ "html"), - ("ice", "x-conference" +/+ "x-cooltalk"), - ("ico", "image" +/+ "x-icon"), ("ics", "text" +/+ "calendar"), - ("ief", "image" +/+ "ief"), ("ifb", "text" +/+ "calendar"), - ("iff", "audio" +/+ "x-svx"), ("iges", "model" +/+ "iges"), - ("igs", "model" +/+ "iges"), ("ilbc", "audio" +/+ "iLBC-sh"), - ("imf", "audio" +/+ "x-mod"), ("it", "audio" +/+ "x-mod"), - ("jng", "image" +/+ "x-jng"), - ("jnlp", "application" +/+ "x-java-jnlp-file"), - ("jp2", "image" +/+ "jp2"), ("jpe", "image" +/+ "jpeg"), - ("jpeg", "image" +/+ "jpeg"), ("jpg", "image" +/+ "jpeg"), - ("js", "application" +/+ "x-javascript"), - ("kar", "audio" +/+ "midi"), - ("latex", "application" +/+ "x-latex"), - ("lha", "application" +/+ "octet-stream"), - ("lzh", "application" +/+ "octet-stream"), - ("m3u", "audio" +/+ "x-mpegurl"), ("m4a", "audio" +/+ "mp4a-latm"), - ("m4p", "audio" +/+ "mp4a-latm"), - ("m4u", "video" +/+ "vnd.mpegurl"), ("m4v", "video" +/+ "mpeg4"), - ("mac", "image" +/+ "x-macpaint"), - ("man", "application" +/+ "x-troff-man"), - ("mathml", "application" +/+ "mathml+xml"), - ("me", "application" +/+ "x-troff-me"), - ("med", "audio" +/+ "x-mod"), ("mesh", "model" +/+ "mesh"), - ("mid", "audio" +/+ "midi"), ("midi", "audio" +/+ "midi"), - ("mif", "application" +/+ "vnd.mif"), - ("mka", "video" +/+ "x-matroska"), - ("mkv", "video" +/+ "x-matroska"), ("mng", "video" +/+ "x-mng"), - ("mod", "audio" +/+ "x-mod"), ("mov", "video" +/+ "quicktime"), - ("movie", "video" +/+ "x-sgi-movie"), ("mp2", "audio" +/+ "mpeg"), - ("mp3", "audio" +/+ "mpeg"), ("mp4", "video" +/+ "mp4"), - ("mpc", "audio" +/+ "x-musepack"), ("mpe", "video" +/+ "mpeg"), - ("mpeg", "video" +/+ "mpeg"), ("mpg", "video" +/+ "mpeg"), - ("mpga", "audio" +/+ "mpeg"), - ("ms", "application" +/+ "x-troff-ms"), - ("msh", "model" +/+ "mesh"), ("mtm", "audio" +/+ "x-mod"), - ("mve", "video" +/+ "x-mve"), ("mxu", "video" +/+ "vnd.mpegurl"), - ("nar", "application" +/+ "x-nar"), - ("nc", "application" +/+ "x-netcdf"), - ("nist", "audio" +/+ "x-nist"), ("nuv", "video" +/+ "x-nuv"), - ("o", "application" +/+ "octet-stream"), - ("oda", "application" +/+ "oda"), ("ogg", "application" +/+ "ogg"), - ("ogm", "application" +/+ "ogg"), ("okt", "audio" +/+ "x-mod"), - ("paf", "audio" +/+ "x-paris"), - ("pbm", "image" +/+ "x-portable-bitmap"), - ("pct", "image" +/+ "pict"), ("pdb", "chemical" +/+ "x-pdb"), - ("pdf", "application" +/+ "pdf"), - ("pgm", "image" +/+ "x-portable-graymap"), - ("pgn", "application" +/+ "x-chess-pgn"), - ("pic", "image" +/+ "pict"), ("pict", "image" +/+ "pict"), - ("png", "image" +/+ "png"), - ("pnm", "image" +/+ "x-portable-anymap"), - ("pnt", "image" +/+ "x-macpaint"), - ("pntg", "image" +/+ "x-macpaint"), - ("ppm", "image" +/+ "x-portable-pixmap"), - ("ppt", "application" +/+ "vnd.ms-powerpoint"), - ("ps", "application" +/+ "postscript"), - ("qif", "image" +/+ "x-quicktime"), - ("qt", "video" +/+ "quicktime"), - ("qti", "image" +/+ "x-quicktime"), - ("qtif", "image" +/+ "x-quicktime"), - ("ra", "audio" +/+ "x-pn-realaudio"), - ("ram", "text" +/+ "uri-list"), ("rar", "application" +/+ "x-rar"), - ("ras", "image" +/+ "x-sun-raster"), - ("rdf", "application" +/+ "rdf+xml"), ("rgb", "image" +/+ "x-rgb"), - ("rm", "application" +/+ "vnd.rn-realmedia"), - ("roff", "application" +/+ "x-troff"), ("rtf", "text" +/+ "rtf"), - ("rtx", "text" +/+ "richtext"), ("s3m", "audio" +/+ "x-mod"), - ("sam", "audio" +/+ "x-mod"), ("sds", "audio" +/+ "x-sds"), - ("sf", "audio" +/+ "x-ircam"), ("sgm", "text" +/+ "sgml"), - ("sgml", "text" +/+ "sgml"), ("sh", "application" +/+ "x-sh"), - ("shar", "application" +/+ "x-shar"), - ("shn", "audio" +/+ "x-shorten"), ("sid", "audio" +/+ "x-sid"), - ("silo", "model" +/+ "mesh"), - ("sit", "application" +/+ "x-stuffit"), - ("skd", "application" +/+ "x-koan"), - ("skm", "application" +/+ "x-koan"), - ("skp", "application" +/+ "x-koan"), - ("skt", "application" +/+ "x-koan"), - ("smi", "application" +/+ "smil"), - ("smil", "application" +/+ "smil"), ("snd", "audio" +/+ "x-au"), - ("so", "application" +/+ "octet-stream"), - ("spc", "application" +/+ "x-spc"), - ("spl", "application" +/+ "x-futuresplash"), - ("src", "application" +/+ "x-wais-source"), - ("stm", "audio" +/+ "x-mod"), ("stx", "audio" +/+ "x-mod"), - ("sv4cpio", "application" +/+ "x-sv4cpio"), - ("sv4crc", "application" +/+ "x-sv4crc"), - ("svg", "image" +/+ "svg+xml"), ("svx", "audio" +/+ "x-svx"), - ("swf", "application" +/+ "x-shockwave-flash"), - ("swfl", "application" +/+ "x-shockwave-flash"), - ("t", "application" +/+ "x-troff"), - ("tar", "application" +/+ "x-tar"), - ("tbz", "application" +/+ "x-bzip"), - ("tcl", "application" +/+ "x-tcl"), - ("tex", "application" +/+ "x-tex"), - ("texi", "application" +/+ "x-texinfo"), - ("texinfo", "application" +/+ "x-texinfo"), - ("tgz", "application" +/+ "x-gzip"), ("tif", "image" +/+ "tiff"), - ("tiff", "image" +/+ "tiff"), ("tr", "application" +/+ "x-troff"), - ("ts", "video" +/+ "mpegts"), - ("tsv", "text" +/+ "tab-separated-values"), - ("tta", "audio" +/+ "x-ttafile"), ("txt", "text" +/+ "plain"), - ("ult", "audio" +/+ "x-mod"), - ("ustar", "application" +/+ "x-ustar"), - ("vcd", "application" +/+ "x-cdlink"), - ("voc", "audio" +/+ "x-voc"), ("vrml", "model" +/+ "vrml"), - ("vxml", "application" +/+ "voicexml+xml"), - ("w64", "audio" +/+ "x-w64"), ("wav", "audio" +/+ "x-wav"), - ("wbmp", "image" +/+ "vnd.wap.wbmp"), - ("wbxml", "application" +/+ "vnd.wap.wbxml"), - ("wm", "video" +/+ "x-ms-asf"), ("wma", "video" +/+ "x-ms-asf"), - ("wml", "text" +/+ "vnd.wap.wml"), - ("wmlc", "application" +/+ "vnd.wap.wmlc"), - ("wmls", "text" +/+ "vnd.wap.wmlscript"), - ("wmlsc", "application" +/+ "vnd.wap.wmlscriptc"), - ("wmv", "video" +/+ "x-ms-asf"), ("wrl", "model" +/+ "vrml"), - ("wv", "application" +/+ "x-wavpack"), - ("wvc", "application" +/+ "x-wavpack-correction"), - ("wvp", "application" +/+ "x-wavpack"), - ("xbm", "image" +/+ "x-xbitmap"), ("xcf", "image" +/+ "x-xcf"), - ("xht", "application" +/+ "xhtml+xml"), - ("xhtml", "application" +/+ "xhtml+xml"), - ("xls", "application" +/+ "vnd.ms-excel"), - ("xm", "audio" +/+ "x-mod"), ("xml", "application" +/+ "xml"), - ("xpm", "image" +/+ "x-xpixmap"), ("xsl", "application" +/+ "xml"), - ("xslt", "application" +/+ "xslt+xml"), - ("xul", "application" +/+ "vnd.mozilla.xul+xml"), - ("xwd", "image" +/+ "x-xwindowdump"), - ("xyz", "chemical" +/+ "x-xyz"), ("zip", "application" +/+ "zip")] + [("3gp", "application" "x-3gp"), ("669", "audio" "x-mod"), + ("Z", "application" "x-compress"), + ("a", "application" "x-ar"), ("ac3", "audio" "x-ac3"), + ("ai", "application" "postscript"), + ("aif", "audio" "x-aiff"), ("aifc", "audio" "x-aiff"), + ("aiff", "audio" "x-aiff"), ("amf", "audio" "x-mod"), + ("anx", "application" "ogg"), + ("ape", "application" "x-ape"), ("asc", "text" "plain"), + ("asf", "video" "x-ms-asf"), + ("atom", "application" "atom+xml"), ("au", "audio" "x-au"), + ("avi", "video" "x-msvideo"), + ("bcpio", "application" "x-bcpio"), + ("bin", "application" "octet-stream"), + ("bmp", "image" "bmp"), ("bz2", "application" "x-bzip"), + ("cabal", "text" "x-cabal"), + ("cdf", "application" "x-netcdf"), ("cgm", "image" "cgm"), + ("class", "application" "octet-stream"), + ("cpio", "application" "x-cpio"), + ("cpt", "application" "mac-compactpro"), + ("csh", "application" "x-csh"), ("css", "text" "css"), + ("dcr", "application" "x-director"), + ("dif", "video" "x-dv"), + ("dir", "application" "x-director"), + ("djv", "image" "vnd.djvu"), ("djvu", "image" "vnd.djvu"), + ("dll", "application" "octet-stream"), + ("dmg", "application" "octet-stream"), + ("dms", "application" "octet-stream"), + ("doc", "application" "msword"), ("dsm", "audio" "x-mod"), + ("dtd", "application" "xml-dtd"), ("dv", "video" "x-dv"), + ("dvi", "application" "x-dvi"), + ("dxr", "application" "x-director"), + ("eps", "application" "postscript"), + ("etx", "text" "x-setext"), + ("exe", "application" "octet-stream"), + ("ez", "application" "andrew-inset"), + ("far", "audio" "x-mod"), ("flac", "audio" "x-flac"), + ("flc", "video" "x-fli"), ("fli", "video" "x-fli"), + ("flv", "video" "x-flv"), ("gdm", "audio" "x-mod"), + ("gif", "image" "gif"), ("gram", "application" "srgs"), + ("grxml", "application" "srgs+xml"), + ("gtar", "application" "x-gtar"), + ("gz", "application" "x-gzip"), + ("hdf", "application" "x-hdf"), + ("hi", "application" "octet-stream"), + ("hqx", "application" "mac-binhex40"), + ("hs", "text" "x-haskell"), ("htm", "text" "html"), + ("html", "text" "html"), + ("ice", "x-conference" "x-cooltalk"), + ("ico", "image" "x-icon"), ("ics", "text" "calendar"), + ("ief", "image" "ief"), ("ifb", "text" "calendar"), + ("iff", "audio" "x-svx"), ("iges", "model" "iges"), + ("igs", "model" "iges"), ("ilbc", "audio" "iLBC-sh"), + ("imf", "audio" "x-mod"), ("it", "audio" "x-mod"), + ("jng", "image" "x-jng"), + ("jnlp", "application" "x-java-jnlp-file"), + ("jp2", "image" "jp2"), ("jpe", "image" "jpeg"), + ("jpeg", "image" "jpeg"), ("jpg", "image" "jpeg"), + ("js", "application" "x-javascript"), + ("kar", "audio" "midi"), + ("latex", "application" "x-latex"), + ("lha", "application" "octet-stream"), + ("lzh", "application" "octet-stream"), + ("m3u", "audio" "x-mpegurl"), ("m4a", "audio" "mp4a-latm"), + ("m4p", "audio" "mp4a-latm"), + ("m4u", "video" "vnd.mpegurl"), ("m4v", "video" "mpeg4"), + ("mac", "image" "x-macpaint"), + ("man", "application" "x-troff-man"), + ("mathml", "application" "mathml+xml"), + ("me", "application" "x-troff-me"), + ("med", "audio" "x-mod"), ("mesh", "model" "mesh"), + ("mid", "audio" "midi"), ("midi", "audio" "midi"), + ("mif", "application" "vnd.mif"), + ("mka", "video" "x-matroska"), + ("mkv", "video" "x-matroska"), ("mng", "video" "x-mng"), + ("mod", "audio" "x-mod"), ("mov", "video" "quicktime"), + ("movie", "video" "x-sgi-movie"), ("mp2", "audio" "mpeg"), + ("mp3", "audio" "mpeg"), ("mp4", "video" "mp4"), + ("mpc", "audio" "x-musepack"), ("mpe", "video" "mpeg"), + ("mpeg", "video" "mpeg"), ("mpg", "video" "mpeg"), + ("mpga", "audio" "mpeg"), + ("ms", "application" "x-troff-ms"), + ("msh", "model" "mesh"), ("mtm", "audio" "x-mod"), + ("mve", "video" "x-mve"), ("mxu", "video" "vnd.mpegurl"), + ("nar", "application" "x-nar"), + ("nc", "application" "x-netcdf"), + ("nist", "audio" "x-nist"), ("nuv", "video" "x-nuv"), + ("o", "application" "octet-stream"), + ("oda", "application" "oda"), ("ogg", "application" "ogg"), + ("ogm", "application" "ogg"), ("okt", "audio" "x-mod"), + ("paf", "audio" "x-paris"), + ("pbm", "image" "x-portable-bitmap"), + ("pct", "image" "pict"), ("pdb", "chemical" "x-pdb"), + ("pdf", "application" "pdf"), + ("pgm", "image" "x-portable-graymap"), + ("pgn", "application" "x-chess-pgn"), + ("pic", "image" "pict"), ("pict", "image" "pict"), + ("png", "image" "png"), + ("pnm", "image" "x-portable-anymap"), + ("pnt", "image" "x-macpaint"), + ("pntg", "image" "x-macpaint"), + ("ppm", "image" "x-portable-pixmap"), + ("ppt", "application" "vnd.ms-powerpoint"), + ("ps", "application" "postscript"), + ("qif", "image" "x-quicktime"), + ("qt", "video" "quicktime"), + ("qti", "image" "x-quicktime"), + ("qtif", "image" "x-quicktime"), + ("ra", "audio" "x-pn-realaudio"), + ("ram", "text" "uri-list"), ("rar", "application" "x-rar"), + ("ras", "image" "x-sun-raster"), + ("rdf", "application" "rdf+xml"), ("rgb", "image" "x-rgb"), + ("rm", "application" "vnd.rn-realmedia"), + ("roff", "application" "x-troff"), ("rtf", "text" "rtf"), + ("rtx", "text" "richtext"), ("s3m", "audio" "x-mod"), + ("sam", "audio" "x-mod"), ("sds", "audio" "x-sds"), + ("sf", "audio" "x-ircam"), ("sgm", "text" "sgml"), + ("sgml", "text" "sgml"), ("sh", "application" "x-sh"), + ("shar", "application" "x-shar"), + ("shn", "audio" "x-shorten"), ("sid", "audio" "x-sid"), + ("silo", "model" "mesh"), + ("sit", "application" "x-stuffit"), + ("skd", "application" "x-koan"), + ("skm", "application" "x-koan"), + ("skp", "application" "x-koan"), + ("skt", "application" "x-koan"), + ("smi", "application" "smil"), + ("smil", "application" "smil"), ("snd", "audio" "x-au"), + ("so", "application" "octet-stream"), + ("spc", "application" "x-spc"), + ("spl", "application" "x-futuresplash"), + ("src", "application" "x-wais-source"), + ("stm", "audio" "x-mod"), ("stx", "audio" "x-mod"), + ("sv4cpio", "application" "x-sv4cpio"), + ("sv4crc", "application" "x-sv4crc"), + ("svg", "image" "svg+xml"), ("svx", "audio" "x-svx"), + ("swf", "application" "x-shockwave-flash"), + ("swfl", "application" "x-shockwave-flash"), + ("t", "application" "x-troff"), + ("tar", "application" "x-tar"), + ("tbz", "application" "x-bzip"), + ("tcl", "application" "x-tcl"), + ("tex", "application" "x-tex"), + ("texi", "application" "x-texinfo"), + ("texinfo", "application" "x-texinfo"), + ("tgz", "application" "x-gzip"), ("tif", "image" "tiff"), + ("tiff", "image" "tiff"), ("tr", "application" "x-troff"), + ("ts", "video" "mpegts"), + ("tsv", "text" "tab-separated-values"), + ("tta", "audio" "x-ttafile"), ("txt", "text" "plain"), + ("ult", "audio" "x-mod"), + ("ustar", "application" "x-ustar"), + ("vcd", "application" "x-cdlink"), + ("voc", "audio" "x-voc"), ("vrml", "model" "vrml"), + ("vxml", "application" "voicexml+xml"), + ("w64", "audio" "x-w64"), ("wav", "audio" "x-wav"), + ("wbmp", "image" "vnd.wap.wbmp"), + ("wbxml", "application" "vnd.wap.wbxml"), + ("wm", "video" "x-ms-asf"), ("wma", "video" "x-ms-asf"), + ("wml", "text" "vnd.wap.wml"), + ("wmlc", "application" "vnd.wap.wmlc"), + ("wmls", "text" "vnd.wap.wmlscript"), + ("wmlsc", "application" "vnd.wap.wmlscriptc"), + ("wmv", "video" "x-ms-asf"), ("wrl", "model" "vrml"), + ("wv", "application" "x-wavpack"), + ("wvc", "application" "x-wavpack-correction"), + ("wvp", "application" "x-wavpack"), + ("xbm", "image" "x-xbitmap"), ("xcf", "image" "x-xcf"), + ("xht", "application" "xhtml+xml"), + ("xhtml", "application" "xhtml+xml"), + ("xls", "application" "vnd.ms-excel"), + ("xm", "audio" "x-mod"), ("xml", "application" "xml"), + ("xpm", "image" "x-xpixmap"), ("xsl", "application" "xml"), + ("xslt", "application" "xslt+xml"), + ("xul", "application" "vnd.mozilla.xul+xml"), + ("xwd", "image" "x-xwindowdump"), + ("xyz", "chemical" "x-xyz"), ("zip", "application" "zip")] diff --git a/Network/HTTP/Lucu/MIMEType/Guess.hs b/Network/HTTP/Lucu/MIMEType/Guess.hs index 12f19e0..db51e65 100644 --- a/Network/HTTP/Lucu/MIMEType/Guess.hs +++ b/Network/HTTP/Lucu/MIMEType/Guess.hs @@ -102,16 +102,16 @@ outputExtMapAsHS extMap fpath mimeToExp (MIMEType maj min params) = foldl appendParam (HsInfixApp (HsLit (HsString maj)) - (HsQVarOp (UnQual (HsSymbol "+/+"))) + (HsQVarOp (UnQual (HsSymbol ""))) (HsLit (HsString min))) params appendParam :: HsExp -> (String, String) -> HsExp appendParam x param - = HsInfixApp x (HsQVarOp (UnQual (HsSymbol "+:+"))) $ paramToExp param + = HsInfixApp x (HsQVarOp (UnQual (HsSymbol "<:>"))) $ paramToExp param paramToExp :: (String, String) -> HsExp paramToExp (name, value) = HsInfixApp (HsLit (HsString name)) - (HsQVarOp (UnQual (HsSymbol "+=+"))) + (HsQVarOp (UnQual (HsSymbol "<=>"))) (HsLit (HsString value)) \ No newline at end of file diff --git a/Network/HTTP/Lucu/Resource/Tree.hs b/Network/HTTP/Lucu/Resource/Tree.hs index e4fa662..9cd8d0b 100644 --- a/Network/HTTP/Lucu/Resource/Tree.hs +++ b/Network/HTTP/Lucu/Resource/Tree.hs @@ -180,7 +180,7 @@ runResource def itr -- FIXME: 同じ名前で複數の値があった時は、こ -- れではまずいと思ふ。 mapM_ (\ (name, value) -> setHeader name value) $ aboHeaders abo - setContentType ("application" +/+ "xhtml+xml") + setContentType ("application" "xhtml+xml") output $ abortPage conf reqM resM abo else hPutStrLn stderr $ show abo diff --git a/Network/HTTP/Lucu/Response.hs b/Network/HTTP/Lucu/Response.hs index 54d57b2..5a7c3a5 100644 --- a/Network/HTTP/Lucu/Response.hs +++ b/Network/HTTP/Lucu/Response.hs @@ -78,8 +78,8 @@ data Response = Response { resVersion :: HttpVersion , resStatus :: StatusCode , resHeaders :: Headers - } - deriving (Show, Eq) + } deriving (Show, Eq) + instance HasHeaders Response where getHeaders = resHeaders diff --git a/examples/HelloWorld.hs b/examples/HelloWorld.hs index 20be0ce..d584009 100644 --- a/examples/HelloWorld.hs +++ b/examples/HelloWorld.hs @@ -21,9 +21,6 @@ main = let config = defaultConfig { cnfServerPort = PortNumber 9999 } resources = mkResTree [ ( [] , helloWorld ) - , ( ["index.html"] - , staticFile "/Users/admin/Sites/index.html" ) - , ( ["urandom"] , staticFile "/dev/urandom" ) @@ -43,7 +40,7 @@ helloWorld , resGet = Just $ do --time <- liftIO $ getClockTime --foundEntity (strongETag "abcde") time - setContentType $ "text" +/+ "hello" + setContentType $ "text" "hello" outputChunk "Hello, " outputChunk "World!\n" , resHead = Nothing @@ -51,7 +48,7 @@ helloWorld = Just $ do str1 <- inputChunk 3 str2 <- inputChunk 3 str3 <- inputChunk 3 - setContentType $ "text" +/+ "hello" + setContentType $ "text" "hello" output ("[" ++ str1 ++ " - " ++ str2 ++ "#" ++ str3 ++ "]") , resPut = Nothing , resDelete = Nothing -- 2.40.0