packages feed

happstack-fastcgi 0.1.4 → 0.1.5

raw patch · 2 files changed

+21/−18 lines, 2 filesdep ~basenew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

happstack-fastcgi.cabal view
@@ -1,12 +1,12 @@ Name: happstack-fastcgi-Version: 0.1.4+Version: 0.1.5 Copyright: Tupil-Maintainer: ce [at] tupil.com, eml [at] tupil.com+Maintainer: tomberek [] gmail.com License: BSD3 License-file: LICENSE build-type: Simple category: Web-build-depends: base>=2.0, cgi >= 3000.0.0, fastcgi >= 3001.0.2, mtl, happstack-server, containers >= 0.2.0, utf8-string >= 0.3.4, bytestring+build-depends: base>=2.0 && < 5, cgi >= 3000.0.0, fastcgi >= 3001.0.2, mtl, happstack-server, containers >= 0.2.0, utf8-string >= 0.3.4, bytestring Synopsis: Happstack extension for use with FastCGI. Description:  This library lets you write FastCGI programs with Happstack. This package
src/Happstack/Server/FastCGI.hs view
@@ -19,8 +19,11 @@ import Data.Char (toLower) import Data.List (isPrefixOf) import Happstack.Server-import Happstack.Server.HTTP.Types (Request (..), Version (Version))+import Happstack.Server.Types (Request (..), HttpVersion (HttpVersion))+import Happstack.Server.Internal.Monads(runServerPartT) import Network.CGI.Monad (CGIRequest, cgiVars, cgiRequestBody, cgiGet)+import Happstack.Server.Internal.Cookie (parseCookies)+import Control.Concurrent.MVar (newMVar, MVar(..)) import Network.CGI.Protocol (maybeRead) import Network.FastCGI import qualified Data.ByteString.Lazy as BS@@ -57,15 +60,18 @@ toHappstackRequest :: CGIRequest -> CGI Request toHappstackRequest rq = do   i <- cgiInputs+  rqib <- liftIO $ newMVar i +  b <- cgiBody rq   return $ Request { rqMethod  = cgiMethod  rq                    , rqPaths   = cgiPaths   rq                    , rqUri	   = cgiUri     rq                    , rqQuery   = cgiQuery   rq-                   , rqInputs  = i+                   , rqInputsQuery  = i+                   , rqInputsBody = rqib                    , rqCookies = cgiCookies rq                    , rqVersion = cgiVersion rq                    , rqHeaders = cgiHeaders rq-                   , rqBody    = cgiBody    rq+                   , rqBody    = b                    , rqPeer    = cgiPeer    rq                    } @@ -101,7 +107,7 @@ cgiCookies :: CGIRequest -> [(String, H.Cookie)] cgiCookies = map cookieWithName . either (const []) id . parseCookies . str "HTTP_COOKIE" -cgiVersion :: CGIRequest -> Version+cgiVersion :: CGIRequest -> HttpVersion cgiVersion = parseProtocol . str "SERVER_PROTOCOL"  cgiHeaders :: CGIRequest -> Headers@@ -111,8 +117,8 @@            . M.toList            . cgiVars -cgiBody :: CGIRequest -> RqBody-cgiBody = Body . cgiRequestBody+cgiBody :: CGIRequest -> CGI (MVar RqBody)+cgiBody = liftIO . newMVar . Body . cgiRequestBody  cgiPeer :: CGIRequest -> (String, Int) cgiPeer r = (str "REMOTE_ADDR" r, withDef 0 (r ? "REMOTE_PORT" >>= maybeRead)) -- TODO@@ -135,10 +141,10 @@   -- | Parse the HTTP protocol-parseProtocol :: String -> Version-parseProtocol "HTTP/0.9" = Version 0 9-parseProtocol "HTTP/1.0" = Version 1 0-parseProtocol "HTTP/1.1" = Version 1 1+parseProtocol :: String -> HttpVersion+parseProtocol "HTTP/0.9" = HttpVersion 0 9+parseProtocol "HTTP/1.0" = HttpVersion 1 0+parseProtocol "HTTP/1.1" = HttpVersion 1 1 parseProtocol _          = error "Invalid HTTP Version"  -- | Gives an input key/value given an input key@@ -147,7 +153,7 @@   filename    <- getInputFilename k   value       <- withDef (BS.empty) <$> getInputFPS k   contentType <- withDef ""         <$> getInputContentType k-  return (k,  Input { inputValue       = value+  return (k,  Input { inputValue       = Right value                     , inputFilename    = filename                     , inputContentType = convertContentType $ parseContentType contentType                      })@@ -160,10 +166,7 @@  -- | Transforms a ServerPartT into a function. This is a copy of simpleHTTP' processRequest :: (ToMessage b, Monad m, Functor m) => ServerPartT m b -> Request -> m Response-processRequest hs req =  (runWebT $ runServerPartT hs req) >>= (return . (maybe standardNotFound id))-    where-        standardNotFound = H.setHeader "Content-Type" "text/html" $ toResponse "Not found"-+processRequest = simpleHTTP''  -------------------------------------------------- -- Copied straight from Lemmih's old happs-fastcgi