on master help sign in
Updated wai-app-static to accept HEAD requests.

Removed autohead middleware from wai-app-static.

commit60eed5db2ffcfa5be6940d78fec84921d460f6c6 authorDennis J. McWherter Jr <dennis@microsonic.org> dateThu 2 Apr 2015, 08:13 (12 years ago) parent699b9f8
2 files changed+2−4
wai-app-static/Network/Wai/Application/Static.hs+2−2 wai-app-static/WaiAppStatic/CmdLine.hs−2
wai-app-static/Network/Wai/Application/Static.hs+2−2
@@ -214,10 +214,10 @@ staticApp set req = staticAppPieces set (W.pathInfo req) req
214214
215215staticAppPieces :: StaticSettings -> [Text] -> W.Application
216216staticAppPieces _ _ req sendResponse
217− | W.requestMethod req /= "GET" = sendResponse $ W.responseLBS
217+ | notElem (W.requestMethod req) ["GET", "HEAD"] = sendResponse $ W.responseLBS
218218 H.status405
219219 [("Content-Type", "text/plain")]
220− "Only GET is supported"
220+ "Only GET or HEAD is supported"
221221staticAppPieces _ [".hidden", "folder.png"] _ sendResponse = sendResponse $ W.responseLBS H.status200 [("Content-Type", "image/png")] $ L.fromChunks [$(embedFile "images/folder.png")]
222222staticAppPieces _ [".hidden", "haskell.png"] _ sendResponse = sendResponse $ W.responseLBS H.status200 [("Content-Type", "image/png")] $ L.fromChunks [$(embedFile "images/haskell.png")]
223223staticAppPieces ss rawPieces req sendResponse = liftIO $ do
wai-app-static/WaiAppStatic/CmdLine.hs−2
@@ -14,7 +14,6 @@ import Options.Applicative
1414import Text.Printf (printf)
1515import System.Directory (canonicalizePath)
1616import Control.Monad (unless)
17−import Network.Wai.Middleware.Autohead
1817import Network.Wai.Middleware.RequestLogger (logStdout)
1918import Network.Wai.Middleware.Gzip
2019import qualified Data.Map as Map
@@ -100,7 +99,6 @@ runCommandLine middleware = do
10099 unless quiet $ printf "Serving directory %s on port %d with %s index files.\n" docroot' port (if noindex then "no" else show index)
101100 let middle = gzip def { gzipFiles = GzipCompress }
102101 . (if verbose then logStdout else id)
103− . autohead
104102 . (middleware args)
105103 runSettings defaultSettings
106104 { settingsPort = port