X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FStaticFile.hs;h=ffda4cf8dbbbc0a6f0bb41b9536dfb30ec2d2d1c;hb=4e41b11200285142757434e9d67e17ed20fae455;hp=d79fc4fff4f6b6ff70959e7df497087a37289014;hpb=f402841101b4b84f263eea1a43c848f81c48ff93;p=Lucu.git diff --git a/Network/HTTP/Lucu/StaticFile.hs b/Network/HTTP/Lucu/StaticFile.hs index d79fc4f..ffda4cf 100644 --- a/Network/HTTP/Lucu/StaticFile.hs +++ b/Network/HTTP/Lucu/StaticFile.hs @@ -1,6 +1,7 @@ {-# LANGUAGE DoAndIfThenElse , OverloadedStrings + , QuasiQuotes , UnicodeSyntax #-} -- | Handling static files on the filesystem. @@ -27,8 +28,9 @@ import Data.Time.Clock.POSIX import Network.HTTP.Lucu.Abortion import Network.HTTP.Lucu.Config import Network.HTTP.Lucu.ETag -import Network.HTTP.Lucu.MIMEType +import Network.HTTP.Lucu.MIMEType hiding (mimeType) import Network.HTTP.Lucu.MIMEType.Guess +import Network.HTTP.Lucu.MIMEType.TH import Network.HTTP.Lucu.Resource import Network.HTTP.Lucu.Resource.Internal import Network.HTTP.Lucu.Response @@ -46,13 +48,13 @@ staticFile path } octetStream ∷ MIMEType -octetStream = mkMIMEType "application" "octet-stream" +octetStream = [mimeType| application/octet-stream |] handleStaticFile ∷ Bool → FilePath → Resource () handleStaticFile sendContent path = do exists ← liftIO $ fileExist path unless exists - $ foundNoEntity Nothing + foundNoEntity' readable ← liftIO $ fileAccess path True False False unless readable @@ -64,6 +66,7 @@ handleStaticFile sendContent path $ abort $ mkAbortion Forbidden [] Nothing + -- FIXME: Forget about ETags of a static file. tag ← liftIO $ generateETagFromFile path let lastMod = posixSecondsToUTCTime $ fromRational