hack-handler-epoll 0.1.1 → 0.1.2
raw patch · 2 files changed
+20/−18 lines, 2 filesdep ~HTTPdep ~containersdep ~data-defaultPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: HTTP, containers, data-default, epoll, failure, hack, network, utf8-string
API changes (from Hackage documentation)
Files
- hack-handler-epoll.cabal +9/−9
- src/Hack/Handler/Epoll.hs +11/−9
hack-handler-epoll.cabal view
@@ -1,5 +1,5 @@ name: hack-handler-epoll-version: 0.1.1+version: 0.1.2 synopsis: hack handler implementation using epoll description: Hack handler implemented using System.Linux.Epoll category: Web@@ -20,13 +20,13 @@ ghc-options: -Wall -O2 build-depends: base >= 3 && < 5, unix,- hack >= 2009.10.30,- epoll >= 0.2.2,- HTTP >= 4000.0.8,- data-default >= 0.2,- network >= 2.2.1.2,- failure >= 0.0.0.1,- utf8-string >= 0.3.4,- containers >= 0.2.0.1+ hack,+ epoll,+ HTTP,+ data-default,+ network,+ failure,+ utf8-string,+ containers hs-source-dirs: src
src/Hack/Handler/Epoll.hs view
@@ -17,6 +17,7 @@ ServerConf(..) ) where +import Control.Applicative import Control.Concurrent import Control.Exception (Exception, bracket, finally) import Control.Failure@@ -95,7 +96,7 @@ parseEnv :: ServerConf -> Runtime -> Fd -> SockAddr -> IO Env parseEnv c r fd ra = withIBuffer r fd $ \b -> do- (hd, bd) <- readBuffer b >>= return . headBody+ (hd, bd) <- headBody <$> readBuffer b header <- try $ parseRequestHead . breakLines $ hd headerToEnv c header bd ra @@ -106,7 +107,7 @@ let rhost = mrhost ||| "" host' = lookupHeader HdrHost header ||| host conf body' = readBody bodyLen bdy- return $ Env+ return Env { requestMethod = read . show $ meth , scriptName = "" , pathInfo = uriPath uri@@ -124,17 +125,15 @@ } where infixr 2 |||- (|||) m d = maybe d id m+ (|||) = flip fromMaybe bodyLen = transferEnc ||| contentLen ||| Unknown - contentLen = do- cl <- lookupHeader HdrContentLength header- return . Len . abs . read $ cl+ contentLen = (Len . abs . read) <$>+ lookupHeader HdrContentLength header - transferEnc = do- tc <- lookupHeader HdrTransferEncoding header- if tc /= "identity" then return Chunked else return Unknown+ transferEnc = (choose Chunked Unknown . (/= "identity")) <$>+ lookupHeader HdrTransferEncoding header writeResponse :: Runtime -> Fd -> Response -> IO ()@@ -188,6 +187,9 @@ isIn :: (Eq a) => [a] -> a -> Bool isIn = flip elem +choose :: a -> a -> Bool -> a+choose x _ True = x+choose _ y False = y statusCode :: M.Map Int String statusCode = M.fromAscList