wai-app-file-cgi 3.1.6 → 3.1.7
raw patch · 4 files changed
+19/−17 lines, 4 filesdep −io-choicedep −lifted-basedep ~base
Dependencies removed: io-choice, lifted-base
Dependency ranges changed: base
Files
- Network/Wai/Application/Classic/File.hs +8/−6
- Network/Wai/Application/Classic/Status.hs +4/−7
- test/ClassicSpec.hs +5/−0
- wai-app-file-cgi.cabal +2/−4
Network/Wai/Application/Classic/File.hs view
@@ -5,10 +5,7 @@ , redirectHeader ) where -#if __GLASGOW_HASKELL__ < 709 import Control.Applicative-#endif-import Control.Exception.IOChoice import Data.ByteString (ByteString) import Data.Maybe import qualified Data.ByteString.Char8 as BS (concat)@@ -97,8 +94,8 @@ processGET :: HandlerInfo -> Bool -> Maybe Path -> IO RspSpec processGET hinfo ishtml rfile = tryGet hinfo ishtml- ||> tryRedirect hinfo rfile- ||> return notFound+ <|> tryRedirect hinfo rfile+ <|> return notFound tryGet :: HandlerInfo -> Bool -> IO RspSpec tryGet hinfo@(HandlerInfo _ _ _ langs) True =@@ -115,7 +112,7 @@ ---------------------------------------------------------------- tryRedirect :: HandlerInfo -> Maybe Path -> IO RspSpec-tryRedirect _ Nothing = goNext+tryRedirect _ Nothing = empty tryRedirect (HandlerInfo spec req _ langs) (Just file) = runAnyOne $ map (tryRedirectFile hinfo) langs where@@ -152,3 +149,8 @@ notAllowed :: RspSpec notAllowed = NoBody methodNotAllowed405++----------------------------------------------------------------++runAnyOne :: [IO a] -> IO a+runAnyOne = foldr (<|>) empty
Network/Wai/Application/Classic/Status.hs view
@@ -3,12 +3,9 @@ module Network.Wai.Application.Classic.Status (getStatusInfo) where -#if __GLASGOW_HASKELL__ < 709 import Control.Applicative-#endif import Control.Arrow import Control.Exception-import Control.Exception.IOChoice import qualified Data.ByteString.Lazy as BL import Data.ByteString.Lazy.Char8 () import qualified Data.StaticHash as M@@ -22,8 +19,8 @@ getStatusInfo :: ClassicAppSpec -> Request -> [Lang] -> Status -> IO StatusInfo getStatusInfo cspec req langs st = getStatusFile getF dir code langs- ||> getStatusBS code- ||> return StatusNone+ <|> getStatusBS code+ <|> return StatusNone where dir = statusFileDir cspec getF = getFileInfo req@@ -64,8 +61,8 @@ mfiles = case M.lookup code statusFileMap of Nothing -> [] Just file -> map ($ (dir </> file)) langs- tryFile = foldr func goNext- func f io = StatusFile f . fileInfoSize <$> getF f' ||> io+ tryFile = foldr func empty+ func f io = StatusFile f . fileInfoSize <$> getF f' <|> io where f' = pathString f
test/ClassicSpec.hs view
@@ -43,6 +43,11 @@ bdy <- rspBody <$> sendGETwH url [Header HdrAcceptLanguage "ja, en;q=0.7"] ans <- readFileAscii "test/html/ja/index.html.ja" bdy `shouldBe` ans+ it "returns English HTML even if language is specified" $ do+ let url = "http://127.0.0.1:2345/"+ bdy <- rspBody <$> sendGETwH url [Header HdrAcceptLanguage "ja, en;q=0.7"]+ ans <- readFileAscii "test/html/index.html"+ bdy `shouldBe` ans it "returns 304 if not changed" $ do let url = "http://127.0.0.1:2345/" hdr <- rspHeaders <$> sendGET url
wai-app-file-cgi.cabal view
@@ -1,5 +1,5 @@ Name: wai-app-file-cgi-Version: 3.1.6+Version: 3.1.7 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3@@ -38,7 +38,7 @@ Network.Wai.Application.Classic.Types Network.Wai.Application.Classic.RevProxy - Build-Depends: base >= 4 && < 5+ Build-Depends: base >= 4.9 && < 5 , array , attoparsec >= 0.10.0.0 , attoparsec-conduit@@ -54,8 +54,6 @@ , http-conduit >= 2.1 , http-date , http-types >= 0.7- , io-choice- , lifted-base , mime-types , network , process