Use ByteString-based getEnvironment on *nix systems

This commit is contained in:
Michael Snoyman 2014-03-13 14:14:01 +02:00
parent dc69a02d70
commit 746c04c9e9
2 changed files with 14 additions and 1 deletions

View File

@ -13,7 +13,6 @@ module Network.Wai.Handler.CGI
import Network.Wai
import Network.Wai.Internal
import Network.Socket (getAddrInfo, addrAddress)
import System.Environment (getEnvironment)
import Data.Maybe (fromMaybe)
import Control.Exception (mask)
import qualified Data.ByteString.Char8 as B
@ -35,6 +34,15 @@ import qualified Data.CaseInsensitive as CI
import Data.Monoid (mappend)
import Data.Conduit
#if WINDOWS
import System.Environment (getEnvironment)
#else
import qualified System.Posix.Env.ByteString as Env
getEnvironment :: IO [(String, String)]
getEnvironment = map (B.unpack *** B.unpack) `fmap` Env.getEnvironment
#endif
safeRead :: Read a => a -> String -> a
safeRead d s =
case reads s of

View File

@ -47,6 +47,11 @@ Library
, word8
, lifted-base >= 0.1.2
if os(windows)
cpp-options: -DWINDOWS
else
build-depends: unix
Exposed-modules: Network.Wai.Handler.CGI
Network.Wai.Middleware.AcceptOverride
Network.Wai.Middleware.Autohead