hack-handler-cgi 0.0.0 → 0.0.1
raw patch · 2 files changed
+13/−3 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Hack/Handler/CGI.hs +12/−2
- hack-handler-cgi.cabal +1/−1
Hack/Handler/CGI.hs view
@@ -9,6 +9,8 @@ import Data.Maybe (fromMaybe) import qualified Data.ByteString.Lazy as BS import Data.Word (Word8)+import Control.Arrow (first)+import Data.Char (toLower) safeRead :: Read a => a -> String -> a safeRead d s =@@ -36,6 +38,7 @@ qstring = lookup' "QUERY_STRING" vars servername = lookup' "SERVER_NAME" vars serverport = safeRead 80 $ lookup' "SERVER_PORT" vars+ contentLength = safeRead 0 $ lookup' "CONTENT_LENGTH" vars let env = def { requestMethod = rmethod , scriptName = sname@@ -43,8 +46,8 @@ , queryString = qstring , serverName = servername , serverPort = serverport- , http = vars- , hackInput = body'+ , http = map (first cleanupVarName) vars+ , hackInput = BS.take contentLength body' } res <- app env let h = headers res@@ -74,3 +77,10 @@ | fromEnum c < 256 = toEnum $ fromEnum c | otherwise = error $ "Out of bound character, value: " ++ show (fromEnum c)++cleanupVarName :: String -> String+cleanupVarName ('H':'T':'T':'P':'_':a:as) = a : helper' as where+ helper' ('_':x:rest) = '-' : x : helper' rest+ helper' (x:rest) = toLower x : helper' rest+ helper' [] = []+cleanupVarName x = x
hack-handler-cgi.cabal view
@@ -1,5 +1,5 @@ name: hack-handler-cgi-version: 0.0.0+version: 0.0.1 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>