X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FStaticFile.hs;h=f560ae3494a31ca53a86e33510f2c96b29e6db6d;hb=2dfd3e662204585dd64f2ddbe3b3eed0c708c68f;hp=5b5eb9734e3a68441516f36a86ada99269ea7888;hpb=1ead053df6a792edafa9d714c4c038a8a9c3ad16;p=Lucu.git diff --git a/Network/HTTP/Lucu/StaticFile.hs b/Network/HTTP/Lucu/StaticFile.hs index 5b5eb97..f560ae3 100644 --- a/Network/HTTP/Lucu/StaticFile.hs +++ b/Network/HTTP/Lucu/StaticFile.hs @@ -15,8 +15,10 @@ import Control.Monad.Unicode import Control.Monad.Trans import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Convertible.Base +import Data.Convertible.Instances.Text () +import Data.Monoid.Unicode import Data.String -import qualified Data.Text as T import qualified Data.Text.Encoding as T import Network.HTTP.Lucu.Abortion import Network.HTTP.Lucu.Config @@ -35,7 +37,7 @@ import System.FilePath -- @fpath@ on the filesystem. staticFile ∷ FilePath → Resource staticFile path - = emptyResource { + = (∅) { resGet = Just $ handleStaticFile True path , resHead = Just $ handleStaticFile False path } @@ -71,18 +73,18 @@ handleStaticFile sendContent path $ liftIO (LBS.readFile path) ≫= putChunks -- | @'staticDir' dir@ is a 'Resource' which maps all files in @dir@ --- and its subdirectories on the filesystem to the --- 'Network.HTTP.Lucu.Resource.Tree.ResTree'. +-- and its subdirectories on the filesystem to the resource tree. Thus +-- having 'Network.HTTP.Lucu.nonGreedy' 'staticDir' in a tree makes no +-- sense. -- -- Note that 'staticDir' currently doesn't have a directory-listing -- capability. Requesting the content of a directory will end up being -- replied with /403 Forbidden/. staticDir ∷ FilePath → Resource staticDir path - = emptyResource { - resIsGreedy = True - , resGet = Just $ handleStaticDir True path - , resHead = Just $ handleStaticDir False path + = (∅) { + resGet = Just $ handleStaticDir True path + , resHead = Just $ handleStaticDir False path } -- TODO: implement directory listing. @@ -94,7 +96,7 @@ handleStaticDir sendContent basePath handleStaticFile sendContent path where dec8 ∷ ByteString → String - dec8 = T.unpack ∘ T.decodeUtf8 + dec8 = cs ∘ T.decodeUtf8 securityCheck ∷ (Eq s, Show s, IsString s, Monad m) ⇒ [s] → m () securityCheck pathElems