--- | Computation of @'handleStaticFile' fpath@ serves the file at
--- @fpath@ on the filesystem. The
--- 'Network.HTTP.Lucu.Resource.Resource' must be in the /Examining
--- Request/ state before the computation. It will be in the /Done/
--- state after the computation.
---
--- If you just want to place a static file on the
--- 'Network.HTTP.Lucu.Resource.Tree.ResTree', you had better use
--- 'staticFile' instead of this.
-handleStaticFile :: FilePath -> Resource ()
-handleStaticFile path
- = path `seq`
- do exists <- liftIO $ fileExist path
- if exists then
- -- 存在はした。讀めるかどうかは知らない。
- do stat <- liftIO $ getFileStatus path
- if isRegularFile stat then
- do readable <- liftIO $ fileAccess path True False False
- unless readable
- -- 讀めない
- $ abort Forbidden [] Nothing
- -- 讀める
- tag <- liftIO $ generateETagFromFile path
- let lastMod = posixSecondsToUTCTime $ fromRational $ toRational $ modificationTime stat
- foundEntity tag lastMod
+octetStream ∷ MIMEType
+octetStream = mkMIMEType "application" "octet-stream"
+
+handleStaticFile ∷ Bool → FilePath → Resource ()
+handleStaticFile sendContent path
+ = do exists ← liftIO $ fileExist path
+ unless exists
+ $ foundNoEntity Nothing
+
+ readable ← liftIO $ fileAccess path True False False
+ unless readable
+ $ abort Forbidden [] Nothing