on master help sign in
Everything compiles, version bumped to 2.0
commit0dd6663f53d32ca594deb5c25362a4f5486241b4 authorMichael Snoyman <michael@snoyman.com> dateMon 19 Aug 2013, 11:41 (13 years ago) parent681935f
34 files changed+114−112
wai-app-static/Network/Wai/Application/Static.hs+1−1 wai-app-static/WaiAppStatic/Storage/Embedded.hs+2−2 wai-app-static/WaiAppStatic/Storage/Filesystem.hs+1−1 wai-app-static/wai-app-static.cabal+2−2 wai-eventsource/src/Network/Wai/EventSource.hs+6−6 wai-eventsource/wai-eventsource.cabal+3−3 wai-extra/Network/Wai/Handler/CGI.hs+8−11 wai-extra/Network/Wai/Middleware/Autohead.hs+1 wai-extra/Network/Wai/Middleware/Gzip.hs+5−3 wai-extra/Network/Wai/Middleware/HttpAuth.hs+2−3 wai-extra/Network/Wai/Middleware/Jsonp.hs+2−1 wai-extra/Network/Wai/Middleware/MethodOverridePost.hs+1−2 wai-extra/Network/Wai/Middleware/RequestLogger.hs+2−2 wai-extra/Network/Wai/Middleware/Vhost.hs+1−1 wai-extra/Network/Wai/Parse.hs+13−13 wai-extra/test/WaiExtraTest.hs+9−9 wai-extra/tests.hs+1−1 wai-extra/wai-extra.cabal+2−2 wai-frontend-monadcgi/Network/Wai/Frontend/MonadCGI.hs−2 wai-frontend-monadcgi/wai-frontend-monadcgi.cabal+2−2 wai-handler-devel/wai-handler-devel.cabal+3−3 wai-handler-fastcgi/wai-handler-fastcgi.cabal+3−3 wai-handler-launch/Network/Wai/Handler/Launch.hs+3−2 wai-handler-launch/wai-handler-launch.cabal+3−3 wai-handler-scgi/wai-handler-scgi.cabal+3−3 wai-handler-webkit/wai-handler-webkit.cabal+2−2 wai-test/Network/Wai/Test.hs+13−10 wai-test/wai-test.cabal+3−2 wai-websockets/Network/Wai/Handler/WebSockets.hs+4−4 wai-websockets/wai-websockets.cabal+3−3 wai/wai.cabal+1−1 warp-static/warp-static.cabal+4−4 warp-tls/warp-tls.cabal+3−3 warp/warp.cabal+2−2
wai-app-static/Network/Wai/Application/Static.hs+1−1
@@ -85,7 +85,7 @@ serveFolder ss@StaticSettings {..} pieces req folder@Folder {..} =
8585 Just listing -> do
8686 -- directory listings turned on, display it
8787 builder <- listing pieces folder
88− return $ WaiResponse $ W.ResponseBuilder H.status200
88+ return $ WaiResponse $ W.responseBuilder H.status200
8989 [ ("Content-Type", "text/html; charset=utf-8")
9090 ] builder
9191 Nothing -> return $ WaiResponse $ W.responseLBS H.status403
wai-app-static/WaiAppStatic/Storage/Embedded.hs+2−2
@@ -49,7 +49,7 @@ toEntry :: (Piece, EmbeddedEntry) -> Either FolderName File
4949toEntry (name, EEFolder{}) = Left name
5050toEntry (name, EEFile bs) = Right File
5151 { fileGetSize = S.length bs
52− , fileToResponse = \s h -> W.ResponseBuilder s h $ fromByteString bs
52+ , fileToResponse = \s h -> W.responseBuilder s h $ fromByteString bs
5353 , fileName = name
5454 , fileGetHash = return $ Just $ runHash bs
5555 , fileGetModified = Nothing
@@ -82,7 +82,7 @@ toEmbedded fps =
8282bsToFile :: Piece -> ByteString -> File
8383bsToFile name bs = File
8484 { fileGetSize = S.length bs
85− , fileToResponse = \s h -> W.ResponseBuilder s h $ fromByteString bs
85+ , fileToResponse = \s h -> W.responseBuilder s h $ fromByteString bs
8686 , fileName = name
8787 , fileGetHash = return $ Just $ runHash bs
8888 , fileGetModified = Nothing
wai-app-static/WaiAppStatic/Storage/Filesystem.hs+1−1
@@ -91,7 +91,7 @@ fileHelper hashFunc fp name = do
9191 Left (_ :: SomeException) -> return Nothing
9292 Right fs | isRegularFile fs -> return $ Just File
9393 { fileGetSize = fromIntegral $ fileSize fs
94− , fileToResponse = \s h -> W.ResponseFile s h (F.encodeString fp) Nothing
94+ , fileToResponse = \s h -> W.responseFile s h (F.encodeString fp) Nothing
9595 , fileName = name
9696 , fileGetHash = hashFunc fp
9797 , fileGetModified = Just $ modificationTime fs
wai-app-static/wai-app-static.cabal+2−2
@@ -1,5 +1,5 @@
11name: wai-app-static
2−version: 1.3.1.3
2+version: 2.0.0
33license: MIT
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
@@ -24,7 +24,7 @@ Flag print
2424
2525library
2626 build-depends: base >= 4 && < 5
27− , wai >= 1.3 && < 1.5
27+ , wai >= 2.0 && < 2.1
2828 , bytestring >= 0.9.1.4
2929 , http-types >= 0.7
3030 , transformers >= 0.2.2
wai-eventsource/src/Network/Wai/EventSource.hs+6−6
@@ -16,7 +16,7 @@ import Control.Monad.IO.Class (liftIO)
1616import Data.Conduit
1717import qualified Data.Conduit.List as CL
1818import Network.HTTP.Types (status200)
19−import Network.Wai (Application, Response(..))
19+import Network.Wai (Application, Response, responseSource)
2020
2121import Network.Wai.EventSource.EventStream
2222
@@ -29,7 +29,7 @@ eventSourceAppChan chan _ = do
2929
3030-- | Make a new WAI EventSource application reading events from
3131-- the given source.
32−eventSourceAppSource :: Source (ResourceT IO) ServerEvent -> Application
32+eventSourceAppSource :: Source IO ServerEvent -> Application
3333eventSourceAppSource src _ = return $ response sourceToSource src
3434
3535-- | Make a new WAI EventSource application reading events from
@@ -37,13 +37,13 @@ eventSourceAppSource src _ = return $ response sourceToSource src
3737eventSourceAppIO :: IO ServerEvent -> Application
3838eventSourceAppIO act _ = return $ response ioToSource act
3939
40−response :: (a -> Source (ResourceT IO) (Flush Builder)) -> a -> Response
41−response f a = ResponseSource status200 [("Content-Type", "text/event-stream")] $ f a
40+response :: (a -> Source IO (Flush Builder)) -> a -> Response
41+response f a = responseSource status200 [("Content-Type", "text/event-stream")] $ f a
4242
43−chanToSource :: Chan ServerEvent -> Source (ResourceT IO) (Flush Builder)
43+chanToSource :: Chan ServerEvent -> Source IO (Flush Builder)
4444chanToSource = ioToSource . readChan
4545
46−ioToSource :: IO ServerEvent -> Source (ResourceT IO) (Flush Builder)
46+ioToSource :: IO ServerEvent -> Source IO (Flush Builder)
4747ioToSource act =
4848 loop
4949 where
wai-eventsource/wai-eventsource.cabal+3−3
@@ -1,5 +1,5 @@
11Name: wai-eventsource
2−Version: 1.3.0.4
2+Version: 2.0.0
33Synopsis: WAI support for server-sent events
44Description: WAI support for server-sent events
55License: MIT
@@ -19,8 +19,8 @@ Library
1919 , blaze-builder >= 0.3 && < 0.4
2020 , conduit >= 0.5 && < 1.1
2121 , http-types >= 0.7
22− , wai >= 1.3 && < 1.5
23− , warp >= 1.3 && < 1.4
22+ , wai >= 2.0 && < 2.1
23+ , warp >= 2.0 && < 2.1
2424 , transformers
2525
2626 ghc-options: -Wall
wai-extra/Network/Wai/Handler/CGI.hs+8−11
@@ -11,6 +11,7 @@ module Network.Wai.Handler.CGI
1111 ) where
1212
1313import Network.Wai
14+import Network.Wai.Internal
1415import Network.Socket (getAddrInfo, addrAddress)
1516import System.Environment (getEnvironment)
1617import Data.Maybe (fromMaybe)
@@ -25,6 +26,7 @@ import Blaze.ByteString.Builder (fromByteString, toLazyByteString)
2526import Blaze.ByteString.Builder.Char8 (fromChar, fromString)
2627import Data.Conduit.Blaze (builderToByteStringFlush)
2728import Control.Monad.IO.Class (liftIO)
29+import Control.Monad.Trans.Resource (withInternalState)
2830import Data.ByteString.Lazy.Internal (defaultChunkSize)
2931import System.IO (Handle)
3032import Network.HTTP.Types (Status (..))
@@ -67,7 +69,7 @@ runSendfile sf app = do
6769-- stick with 'run' or 'runSendfile'.
6870runGeneric
6971 :: [(String, String)] -- ^ all variables
70− -> (Int -> Source (ResourceT IO) B.ByteString) -- ^ responseBody of input
72+ -> (Int -> Source IO B.ByteString) -- ^ responseBody of input
7173 -> (B.ByteString -> IO ()) -- ^ destination for output
7274 -> Maybe B.ByteString -- ^ does the server support the X-Sendfile header?
7375 -> Application
@@ -76,8 +78,6 @@ runGeneric vars inputH outputH xsendfile app = do
7678 let rmethod = B.pack $ lookup' "REQUEST_METHOD" vars
7779 pinfo = lookup' "PATH_INFO" vars
7880 qstring = lookup' "QUERY_STRING" vars
79− servername = lookup' "SERVER_NAME" vars
80− serverport = safeRead 80 $ lookup' "SERVER_PORT" vars
8181 contentLength = safeRead 0 $ lookup' "CONTENT_LENGTH" vars
8282 remoteHost' =
8383 case lookup "REMOTE_ADDR" vars of
@@ -95,24 +95,21 @@ runGeneric vars inputH outputH xsendfile app = do
9595 case addrs of
9696 a:_ -> addrAddress a
9797 [] -> error $ "Invalid REMOTE_ADDR or REMOTE_HOST: " ++ remoteHost'
98− runResourceT $ do
98+ runResourceT $ withInternalState $ \internalState -> do
9999 let env = Request
100100 { requestMethod = rmethod
101101 , rawPathInfo = B.pack pinfo
102102 , pathInfo = H.decodePathSegments $ B.pack pinfo
103103 , rawQueryString = B.pack qstring
104104 , queryString = H.parseQuery $ B.pack qstring
105− , serverName = B.pack servername
106− , serverPort = serverport
107105 , requestHeaders = map (cleanupVarName *** B.pack) vars
108106 , isSecure = isSecure'
109107 , remoteHost = addr
110108 , httpVersion = H.http11 -- FIXME
111109 , requestBody = inputH contentLength
112110 , vault = mempty
113−#if MIN_VERSION_wai(1, 4, 0)
114111 , requestBodyLength = KnownLength $ fromIntegral contentLength
115−#endif
112+ , resourceInternalState = internalState
116113 }
117114 -- FIXME worry about exception?
118115 res <- app env
@@ -120,7 +117,7 @@ runGeneric vars inputH outputH xsendfile app = do
120117 (Just sf, ResponseFile s hs fp Nothing) ->
121118 liftIO $ mapM_ outputH $ L.toChunks $ toLazyByteString $ sfBuilder s hs sf fp
122119 _ -> do
123− let (s, hs, b) = responseSource res
120+ let (s, hs, b) = responseToSource env res
124121 src = CL.sourceList [Chunk $ headers s hs `mappend` fromChar '\n']
125122 `mappend` b
126123 src $$ builderSink
@@ -170,12 +167,12 @@ cleanupVarName s =
170167 helper' (x:rest) = toLower x : helper' rest
171168 helper' [] = []
172169
173−requestBodyHandle :: Handle -> Int -> Source (ResourceT IO) B.ByteString
170+requestBodyHandle :: Handle -> Int -> Source IO B.ByteString
174171requestBodyHandle h = requestBodyFunc $ \i -> do
175172 bs <- B.hGet h i
176173 return $ if B.null bs then Nothing else Just bs
177174
178−requestBodyFunc :: (Int -> IO (Maybe B.ByteString)) -> Int -> Source (ResourceT IO) B.ByteString
175+requestBodyFunc :: (Int -> IO (Maybe B.ByteString)) -> Int -> Source IO B.ByteString
179176requestBodyFunc get =
180177 loop
181178 where
wai-extra/Network/Wai/Middleware/Autohead.hs+1
@@ -4,6 +4,7 @@
44module Network.Wai.Middleware.Autohead (autohead) where
55
66import Network.Wai
7+import Network.Wai.Internal
78import Data.Monoid (mempty)
89
910autohead :: Middleware
wai-extra/Network/Wai/Middleware/Gzip.hs+5−3
@@ -40,6 +40,7 @@ import Data.Conduit.Blaze (builderToByteStringFlush)
4040import Blaze.ByteString.Builder (fromByteString)
4141import Control.Exception (try, SomeException)
4242import qualified Data.Set as Set
43+import Network.Wai.Internal
4344
4445data GzipSettings = GzipSettings
4546 { gzipFiles :: GzipFiles
@@ -84,7 +85,7 @@ gzip set app env = do
8485 Just m
8586 | gzipCheckMime set m -> liftIO $ compressFile s hs file cache
8687 _ -> return res
87− _ -> return $ compressE set res
88+ _ -> return $ compressE set env res
8889 else return res
8990 where
9091 enc = fromMaybe [] $ (splitCommas . S8.unpack)
@@ -119,9 +120,10 @@ compressFile s hs file cache = do
119120 safe _ = '_'
120121
121122compressE :: GzipSettings
123+ -> Request
122124 -> Response
123125 -> Response
124−compressE set res =
126+compressE set req res =
125127 case lookup "content-type" hs of
126128 Just m | gzipCheckMime set m ->
127129 let hs' = fixHeaders hs
@@ -130,7 +132,7 @@ compressE set res =
130132 C.$= CL.map (fmap fromByteString)
131133 _ -> res
132134 where
133− (s, hs, b) = responseSource res
135+ (s, hs, b) = responseToSource req res
134136
135137-- Remove Content-Length header, since we will certainly have a
136138-- different length after gzip compression.
wai-extra/Network/Wai/Middleware/HttpAuth.hs+2−3
@@ -16,14 +16,13 @@ import Network.HTTP.Types (status401)
1616import Data.ByteString (ByteString)
1717import qualified Data.ByteString as S
1818import Data.String (IsString (..))
19−import Control.Monad.Trans.Resource (ResourceT)
2019import Data.Word8 (isSpace, _colon, toLower)
2120import Data.ByteString.Base64 (decodeLenient)
2221
2322-- | Check if a given username and password is valid.
2423type CheckCreds = ByteString
2524 -> ByteString
26− -> ResourceT IO Bool
25+ -> IO Bool
2726
2827-- | Perform basic authentication.
2928--
@@ -73,7 +72,7 @@ data AuthSettings = AuthSettings
7372 -- authentication is not provided.
7473 --
7574 -- Since 1.3.4
76− , authIsProtected :: !(Request -> ResourceT IO Bool)
75+ , authIsProtected :: !(Request -> IO Bool)
7776 -- ^ Determine if access to the requested resource is restricted.
7877 --
7978 -- Default: always returns @True@.
wai-extra/Network/Wai/Middleware/Jsonp.hs+2−1
@@ -16,6 +16,7 @@
1616module Network.Wai.Middleware.Jsonp (jsonp) where
1717
1818import Network.Wai
19+import Network.Wai.Internal
1920import Data.ByteString (ByteString)
2021import qualified Data.ByteString.Char8 as B8
2122import Blaze.ByteString.Builder (copyByteString)
@@ -68,7 +69,7 @@ jsonp app env = do
6869 Just hs' -> addCallback c s hs' b
6970 Nothing -> return r
7071 where
71− (s, hs, b) = responseSource r
72+ (s, hs, b) = responseToSource env r
7273
7374 checkJSON hs =
7475 case lookup "Content-Type" hs of
wai-extra/Network/Wai/Middleware/MethodOverridePost.hs+1−2
@@ -12,7 +12,6 @@ import Network.Wai
1212import Network.HTTP.Types (parseQuery)
1313import Data.Monoid (mconcat)
1414import Data.Conduit.Lazy (lazyConsume)
15−import Control.Monad.Trans.Resource (ResourceT)
1615import Data.Conduit.List (sourceList)
1716
1817-- | Allows overriding of the HTTP request method via the _method post string parameter.
@@ -31,7 +30,7 @@ methodOverridePost app req = case (requestMethod req, lookup "Content-Type" (req
3130 ("POST", Just "application/x-www-form-urlencoded") -> setPost req >>= app
3231 _ -> app req
3332
34−setPost :: Request -> ResourceT IO Request
33+setPost :: Request -> IO Request
3534setPost req = do
3635 body <- lazyConsume (requestBody req)
3736 case parseQuery (mconcat body) of
wai-extra/Network/Wai/Middleware/RequestLogger.hs+2−2
@@ -187,7 +187,7 @@ detailedMiddleware cb useColors = do
187187 ]
188188
189189detailedMiddleware' :: Callback
190− -> (C.ResourceT IO (BS.ByteString -> [BS.ByteString]))
190+ -> IO (BS.ByteString -> [BS.ByteString])
191191 -> Middleware
192192detailedMiddleware' cb getAddColor app req = do
193193 let mlen = lookup "content-length" (requestHeaders req) >>= readInt
@@ -245,7 +245,7 @@ detailedMiddleware' cb getAddColor app req = do
245245 allPostParams body =
246246 case getRequestBodyType req of
247247 Nothing -> return ([], [])
248− Just rbt -> C.runResourceT $ CL.sourceList body C.$$ sinkRequestBody lbsBackEnd rbt
248+ Just rbt -> CL.sourceList body C.$$ sinkRequestBody lbsBackEnd rbt
249249
250250 emptyGetParam :: (BS.ByteString, Maybe BS.ByteString) -> (BS.ByteString, BS.ByteString)
251251 emptyGetParam (k, Just v) = (k,v)
wai-extra/Network/Wai/Middleware/Vhost.hs+1−1
@@ -16,7 +16,7 @@ vhost vhosts def req =
1616
1717redirectWWW :: Text -> Application -> Application -- W.MiddleWare
1818redirectWWW home app req =
19− if BS.isPrefixOf "www" $ serverName req
19+ if maybe True (BS.isPrefixOf "www") $ lookup "host" $ requestHeaders req
2020 then return $ responseLBS H.status301
2121 [ ("Content-Type", "text/plain") , ("Location", TE.encodeUtf8 home) ] "Redirect"
2222 else app req
wai-extra/Network/Wai/Parse.hs+13−13
@@ -130,7 +130,7 @@ type File y = (S.ByteString, FileInfo y)
130130-- type, and returns a `Sink` for storing the contents.
131131type BackEnd a = S.ByteString -- ^ parameter name
132132 -> FileInfo ()
133− -> Sink S.ByteString (ResourceT IO) a
133+ -> Sink S.ByteString IO a
134134
135135data RequestBodyType = UrlEncoded | Multipart S.ByteString
136136
@@ -169,7 +169,7 @@ parseContentType a = do
169169
170170parseRequestBody :: BackEnd y
171171 -> Request
172− -> ResourceT IO ([Param], [File y])
172+ -> IO ([Param], [File y])
173173parseRequestBody s r =
174174 case getRequestBodyType r of
175175 Nothing -> return ([], [])
@@ -177,12 +177,12 @@ parseRequestBody s r =
177177
178178sinkRequestBody :: BackEnd y
179179 -> RequestBodyType
180− -> Sink S.ByteString (ResourceT IO) ([Param], [File y])
180+ -> Sink S.ByteString IO ([Param], [File y])
181181sinkRequestBody s r = fmap partitionEithers $ conduitRequestBody s r =$ CL.consume
182182
183183conduitRequestBody :: BackEnd y
184184 -> RequestBodyType
185− -> Conduit S.ByteString (ResourceT IO) (Either Param (File y))
185+ -> Conduit S.ByteString IO (Either Param (File y))
186186conduitRequestBody _ UrlEncoded = do
187187 -- NOTE: in general, url-encoded data will be in a single chunk.
188188 -- Therefore, I'm optimizing for the usual case by sticking with
@@ -212,9 +212,9 @@ takeLine =
212212 return $ Just $ killCR x
213213
214214#if MIN_VERSION_conduit(1, 0, 0)
215−takeLines :: Consumer S.ByteString (ResourceT IO) [S.ByteString]
215+takeLines :: Consumer S.ByteString IO [S.ByteString]
216216#else
217−takeLines :: Pipe S.ByteString S.ByteString o u (ResourceT IO) [S.ByteString]
217+takeLines :: Pipe S.ByteString S.ByteString o u IO [S.ByteString]
218218#endif
219219takeLines = do
220220 res <- takeLine
@@ -229,9 +229,9 @@ takeLines = do
229229parsePieces :: BackEnd y
230230 -> S.ByteString
231231#if MIN_VERSION_conduit(1, 0, 0)
232− -> ConduitM S.ByteString (Either Param (File y)) (ResourceT IO) ()
232+ -> ConduitM S.ByteString (Either Param (File y)) IO ()
233233#else
234− -> Pipe S.ByteString S.ByteString (Either Param (File y)) u (ResourceT IO) ()
234+ -> Pipe S.ByteString S.ByteString (Either Param (File y)) u IO ()
235235#endif
236236parsePieces sink bound =
237237 loop
@@ -308,9 +308,9 @@ sinkTillBound' :: S.ByteString
308308 -> FileInfo ()
309309 -> BackEnd y
310310#if MIN_VERSION_conduit(1, 0, 0)
311− -> ConduitM S.ByteString o (ResourceT IO) (Bool, y)
311+ -> ConduitM S.ByteString o IO (Bool, y)
312312#else
313− -> Pipe S.ByteString S.ByteString o u (ResourceT IO) (Bool, y)
313+ -> Pipe S.ByteString S.ByteString o u IO (Bool, y)
314314#endif
315315sinkTillBound' bound name fi sink =
316316#if MIN_VERSION_conduit(1, 0, 0)
@@ -319,7 +319,7 @@ sinkTillBound' bound name fi sink =
319319 conduitTillBound bound >+> withUpstream (fix $ sink name fi)
320320 where
321321#if MIN_VERSION_conduit(1, 0, 0)
322− fix :: Sink S8.ByteString (ResourceT IO) y -> Pipe Void S8.ByteString Void Bool (ResourceT IO) y
322+ fix :: Sink S8.ByteString IO y -> Pipe Void S8.ByteString Void Bool IO y
323323 fix (ConduitM p) = ignoreTerm >+> injectLeftovers p
324324 ignoreTerm = await' >>= maybe (return ()) (\x -> yield' x >> ignoreTerm)
325325 await' = NeedInput (return . Just) (const $ return Nothing)
@@ -372,9 +372,9 @@ sinkTillBound :: S.ByteString
372372 -> (x -> S.ByteString -> IO x)
373373 -> x
374374#if MIN_VERSION_conduit(1, 0, 0)
375− -> Consumer S.ByteString (ResourceT IO) (Bool, x)
375+ -> Consumer S.ByteString IO (Bool, x)
376376#else
377− -> Pipe S.ByteString S.ByteString o u (ResourceT IO) (Bool, x)
377+ -> Pipe S.ByteString S.ByteString o u IO (Bool, x)
378378#endif
379379sinkTillBound bound iter seed0 =
380380#if MIN_VERSION_conduit(1, 0, 0)
wai-extra/test/WaiExtraTest.hs+9−9
@@ -115,7 +115,7 @@ caseParseHttpAccept = do
115115
116116parseRequestBody' :: BackEnd L.ByteString
117117 -> SRequest
118− -> C.ResourceT IO ([(S.ByteString, S.ByteString)], [(S.ByteString, FileInfo L.ByteString)])
118+ -> IO ([(S.ByteString, S.ByteString)], [(S.ByteString, FileInfo L.ByteString)])
119119parseRequestBody' sink (SRequest req bod) =
120120 case getRequestBodyType req of
121121 Nothing -> return ([], [])
@@ -123,7 +123,7 @@ parseRequestBody' sink (SRequest req bod) =
123123
124124caseParseRequestBody :: Assertion
125125caseParseRequestBody =
126− C.runResourceT t
126+ t
127127 where
128128 content2 = S8.pack $
129129 "--AaB03x\n" ++
@@ -187,7 +187,7 @@ caseParseRequestBody =
187187
188188caseMultipartPlus :: Assertion
189189caseMultipartPlus = do
190− result <- C.runResourceT $ parseRequestBody' lbsBackEnd $ toRequest ctype content
190+ result <- parseRequestBody' lbsBackEnd $ toRequest ctype content
191191 liftIO $ result @?= ([("email", "has+plus")], [])
192192 where
193193 content = S8.pack $
@@ -200,7 +200,7 @@ caseMultipartPlus = do
200200
201201caseMultipartAttrs :: Assertion
202202caseMultipartAttrs = do
203− result <- C.runResourceT $ parseRequestBody' lbsBackEnd $ toRequest ctype content
203+ result <- parseRequestBody' lbsBackEnd $ toRequest ctype content
204204 liftIO $ result @?= ([("email", "has+plus")], [])
205205 where
206206 content = S8.pack $
@@ -213,7 +213,7 @@ caseMultipartAttrs = do
213213
214214caseUrlEncPlus :: Assertion
215215caseUrlEncPlus = do
216− result <- C.runResourceT $ parseRequestBody' lbsBackEnd $ toRequest ctype content
216+ result <- parseRequestBody' lbsBackEnd $ toRequest ctype content
217217 liftIO $ result @?= ([("email", "has+plus")], [])
218218 where
219219 content = S8.pack $ "email=has%2Bplus"
@@ -357,19 +357,19 @@ vhostApp1, vhostApp2, vhostApp :: Application
357357vhostApp1 = const $ return $ responseLBS status200 [] "app1"
358358vhostApp2 = const $ return $ responseLBS status200 [] "app2"
359359vhostApp = vhost
360− [ ((== "foo.com") . serverName, vhostApp1)
360+ [ ((== Just "foo.com") . lookup "host" . requestHeaders, vhostApp1)
361361 ]
362362 vhostApp2
363363
364364caseVhost :: Assertion
365365caseVhost = flip runSession vhostApp $ do
366366 sres1 <- request defaultRequest
367− { serverName = "foo.com"
367+ { requestHeaders = [("Host", "foo.com")]
368368 }
369369 assertBody "app1" sres1
370370
371371 sres2 <- request defaultRequest
372− { serverName = "bar.com"
372+ { requestHeaders = [("Host", "bar.com")]
373373 }
374374 assertBody "app2" sres2
375375
@@ -494,7 +494,7 @@ dalvikHelper includeLength = do
494494 case getRequestBodyType request' of
495495 Nothing -> return ([], [])
496496 Just rbt -> C.runResourceT $ sourceFile "test/requests/dalvik-request"
497− C.$$ sinkRequestBody lbsBackEnd rbt
497+ C.$$ C.transPipe liftIO (sinkRequestBody lbsBackEnd rbt)
498498 lookup "scannedTime" params @?= Just "1.298590056748E9"
499499 lookup "geoLong" params @?= Just "0"
500500 lookup "geoLat" params @?= Just "0"
wai-extra/tests.hs+1−1
@@ -1,4 +1,4 @@
1−import Test.Hspec.Monadic
1+import Test.Hspec
22import qualified WaiExtraTest
33
44main :: IO ()
wai-extra/wai-extra.cabal+2−2
@@ -1,5 +1,5 @@
11Name: wai-extra
2−Version: 1.3.4.2
2+Version: 2.0.0
33Synopsis: Provides some basic WAI handlers and middleware.
44Description: The goal here is to provide common features without many dependencies.
55License: MIT
@@ -22,7 +22,7 @@ extra-source-files:
2222Library
2323 Build-Depends: base >= 4 && < 5
2424 , bytestring >= 0.9.1.4
25− , wai >= 1.3 && < 1.5
25+ , wai >= 2.0 && < 2.1
2626 , old-locale >= 1.0.0.2 && < 1.1
2727 , time >= 1.1.4
2828 , network >= 2.2.1.5
wai-frontend-monadcgi/Network/Wai/Frontend/MonadCGI.hs−2
@@ -67,6 +67,4 @@ getCgiVars e =
6767 [ ("PATH_INFO", S8.unpack $ rawPathInfo e)
6868 , ("REQUEST_METHOD", show $ requestMethod e)
6969 , ("QUERY_STRING", S8.unpack $ rawQueryString e)
70− , ("SERVER_NAME", S8.unpack $ serverName e)
71− , ("SERVER_PORT", show $ serverPort e)
7270 ]
wai-frontend-monadcgi/wai-frontend-monadcgi.cabal+2−2
@@ -1,5 +1,5 @@
11name: wai-frontend-monadcgi
2−version: 1.3.0.2
2+version: 2.0.0
33license: MIT
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
@@ -20,7 +20,7 @@ library
2020 , http-types
2121 , transformers
2222 , case-insensitive
23− , wai >= 1.3 && < 1.5
23+ , wai >= 2.0 && < 2.1
2424 exposed-modules: Network.Wai.Frontend.MonadCGI
2525 ghc-options: -Wall
2626
wai-handler-devel/wai-handler-devel.cabal+3−3
@@ -1,5 +1,5 @@
11Name: wai-handler-devel
2−Version: 1.3.0.6
2+Version: 2.0.0
33Synopsis: WAI server that automatically reloads code after modification.
44Description: This handler automatically reloads your source code upon any changes. It works by using the hint package, essentially embedding GHC inside the handler. The handler (both the executable and library) takes three arguments: the port to listen on, the module name containing the application function, and the name of the function.
55 .
@@ -22,8 +22,8 @@ Source-repository head
2222
2323Library
2424 Build-Depends: base >= 4 && < 5
25− , wai >= 1.3 && < 1.5
26− , wai-extra >= 1.3 && < 1.4
25+ , wai >= 2.0 && < 2.1
26+ , wai-extra >= 2.0 && < 2.1
2727 , http-types >= 0.7
2828 , warp >= 1.3 && < 1.4
2929 , directory >= 1.0.1
wai-handler-fastcgi/wai-handler-fastcgi.cabal+3−3
@@ -1,5 +1,5 @@
11name: wai-handler-fastcgi
2−version: 1.3.0.2
2+version: 2.0.0
33license: MIT
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
@@ -15,8 +15,8 @@ description: Calls out to the libfcgi C library.
1515
1616library
1717 build-depends: base >= 4 && < 5
18− , wai >= 1.3 && < 1.5
19− , wai-extra >= 1.3 && < 1.4
18+ , wai >= 2.0 && < 2.1
19+ , wai-extra >= 2.0 && < 2.1
2020 , bytestring >= 0.9.1.4
2121 exposed-modules: Network.Wai.Handler.FastCGI
2222 ghc-options: -Wall
wai-handler-launch/Network/Wai/Handler/Launch.hs+3−2
@@ -8,6 +8,7 @@ module Network.Wai.Handler.Launch
88 ) where
99
1010import Network.Wai
11+import Network.Wai.Internal
1112import Network.HTTP.Types
1213import qualified Network.Wai.Handler.Warp as Warp
1314import Data.IORef
@@ -45,7 +46,7 @@ ping var app req
4546 ResponseSource _ hs _
4647 | not $ isHtml hs -> return res
4748 _ -> do
48− let (s, hs, body) = responseSource res
49+ let (s, hs, body) = responseToSource req res
4950 let (isEnc, headers') = fixHeaders id hs
5051 let headers'' = filter (\(x, _) -> x /= "content-length") headers'
5152 let fixEnc src =
@@ -60,7 +61,7 @@ ping var app req
6061toInsert :: S.ByteString
6162toInsert = "<script>setInterval(function(){var x;if(window.XMLHttpRequest){x=new XMLHttpRequest();}else{x=new ActiveXObject(\"Microsoft.XMLHTTP\");}x.open(\"GET\",\"/_ping\",false);x.send();},60000)</script>"
6263
63−insideHead :: Conduit (Flush S.ByteString) (ResourceT IO) (Flush S.ByteString)
64+insideHead :: Conduit (Flush S.ByteString) IO (Flush S.ByteString)
6465insideHead =
6566 loop' (S.empty, whole)
6667 where
wai-handler-launch/wai-handler-launch.cabal+3−3
@@ -1,5 +1,5 @@
11Name: wai-handler-launch
2−Version: 1.3.1.4
2+Version: 2.0.0
33Synopsis: Launch a web app in the default browser.
44Description: This handles cross-platform launching and inserts Javascript code to ping the server. When the server no longer receives pings, it shuts down.
55License: MIT
@@ -13,8 +13,8 @@ Cabal-version: >=1.6
1313Library
1414 Exposed-modules: Network.Wai.Handler.Launch
1515 build-depends: base >= 4 && < 5
16− , wai >= 1.3 && < 1.5
17− , warp >= 1.3 && < 1.4
16+ , wai >= 2.0 && < 2.1
17+ , warp >= 2.0 && < 2.1
1818 , http-types >= 0.7
1919 , transformers >= 0.2.2 && < 0.4
2020 , bytestring >= 0.9.1.4
wai-handler-scgi/wai-handler-scgi.cabal+3−3
@@ -1,5 +1,5 @@
11name: wai-handler-scgi
2−version: 1.3.0.2
2+version: 2.0.0
33license: MIT
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
@@ -14,8 +14,8 @@ description: Wai handler to SCGI
1414
1515library
1616 build-depends: base >= 4 && < 5
17− , wai >= 1.3 && < 1.5
18− , wai-extra >= 1.3 && < 1.4
17+ , wai >= 2.0 && < 2.1
18+ , wai-extra >= 2.0 && < 2.1
1919 , bytestring >= 0.9.1.4
2020 exposed-modules: Network.Wai.Handler.SCGI
2121 ghc-options: -Wall
wai-handler-webkit/wai-handler-webkit.cabal+2−2
@@ -1,5 +1,5 @@
11name: wai-handler-webkit
2−version: 1.3.0.1
2+version: 2.0.0
33license: MIT
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
@@ -16,7 +16,7 @@ homepage: http://www.yesodweb.com/book/web-application-interface
1616
1717library
1818 build-depends: base >= 4 && < 5
19− , wai >= 1.3 && < 1.5
19+ , wai >= 2.0 && < 2.1
2020 , warp >= 1.3 && < 1.5
2121 ghc-options: -Wall
2222 exposed-modules: Network.Wai.Handler.Webkit
wai-test/Network/Wai/Test.hs+13−10
@@ -20,11 +20,14 @@ module Network.Wai.Test
2020 , assertHeader
2121 , assertNoHeader
2222 ) where
23+
2324import Network.Wai
25+import Network.Wai.Internal (Request (Request))
2426import qualified Test.HUnit.Base as H
2527import Control.Monad.IO.Class (liftIO)
2628import Control.Monad.Trans.State (StateT, evalStateT)
2729import Control.Monad.Trans.Reader (ReaderT, runReaderT, ask)
30+import Control.Monad.Trans.Resource (withInternalState)
2831import Data.Map (Map)
2932import qualified Data.Map as Map
3033import Data.ByteString (ByteString)
@@ -75,8 +78,6 @@ defaultRequest = Request
7578 , httpVersion = H.http11
7679 , rawPathInfo = "/"
7780 , rawQueryString = ""
78− , serverName = "localhost"
79− , serverPort = 80
8081 , requestHeaders = []
8182 , isSecure = False
8283 , remoteHost = SockAddrInet 0 0
@@ -84,9 +85,8 @@ defaultRequest = Request
8485 , queryString = []
8586 , requestBody = mempty
8687 , vault = mempty
87−#if MIN_VERSION_wai(1, 4, 0)
8888 , requestBodyLength = KnownLength 0
89−#endif
89+ , resourceInternalState = error "Network.Wai.Test.defaultRequest: No resourceInternalState provided"
9090 }
9191
9292-- | Set whole path (request path + query string).
@@ -112,19 +112,22 @@ setRawPathInfo r rawPinfo =
112112srequest :: SRequest -> Session SResponse
113113srequest (SRequest req bod) = do
114114 app <- ask
115− liftIO $ C.runResourceT $ do
116− let req' = req { requestBody = CL.sourceList $ L.toChunks bod }
115+ liftIO $ C.runResourceT $ withInternalState $ \internalState -> do
116+ let req' = req
117+ { requestBody = CL.sourceList $ L.toChunks bod
118+ , resourceInternalState = internalState
119+ }
117120 res <- app req'
118− sres <- runResponse res
121+ sres <- runResponse req' res
119122 -- FIXME cookie processing
120123 return sres
121124
122−runResponse :: Response -> C.ResourceT IO SResponse
123−runResponse res = do
125+runResponse :: Request -> Response -> IO SResponse
126+runResponse req res = do
124127 bss <- body C.$= CL.map toBuilder C.$= builderToByteString C.$$ CL.consume
125128 return $ SResponse s h $ L.fromChunks bss
126129 where
127− (s, h, body) = responseSource res
130+ (s, h, body) = responseToSource req res
128131 toBuilder (C.Chunk builder) = builder
129132 toBuilder C.Flush = flush
130133
wai-test/wai-test.cabal+3−2
@@ -1,5 +1,5 @@
11name: wai-test
2−version: 1.3.1.1
2+version: 2.0.0
33license: MIT
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
@@ -14,7 +14,7 @@ description: Unit test framework (built on HUnit) for WAI applications.
1414
1515library
1616 build-depends: base >= 4 && < 5
17− , wai >= 1.3 && < 1.5
17+ , wai >= 2.0 && < 2.1
1818 , bytestring >= 0.9.1.4
1919 , text >= 0.7 && < 0.12
2020 , blaze-builder >= 0.2.1.4 && < 0.4
@@ -27,6 +27,7 @@ library
2727 , http-types >= 0.7
2828 , case-insensitive >= 0.2
2929 , network
30+ , resourcet
3031 exposed-modules: Network.Wai.Test
3132 ghc-options: -Wall
3233
wai-websockets/Network/Wai/Handler/WebSockets.hs+4−4
@@ -18,7 +18,7 @@ import qualified Network.WebSockets as WS
1818intercept :: WS.Protocol p
1919 => (WS.Request -> WS.WebSockets p ())
2020 -> Wai.Request
21− -> Maybe (Source (ResourceT IO) ByteString -> Warp.Connection -> ResourceT IO ())
21+ -> Maybe (Source IO ByteString -> Warp.Connection -> IO ())
2222intercept = interceptWith WS.defaultWebSocketsOptions
2323
2424-- | Variation of 'intercept' which allows custom options.
@@ -26,7 +26,7 @@ interceptWith :: WS.Protocol p
2626 => WS.WebSocketsOptions
2727 -> (WS.Request -> WS.WebSockets p ())
2828 -> Wai.Request
29− -> Maybe (Source (ResourceT IO) ByteString -> Warp.Connection -> ResourceT IO ())
29+ -> Maybe (Source IO ByteString -> Warp.Connection -> IO ())
3030interceptWith opts app req = case lookup "upgrade" $ Wai.requestHeaders req of
3131 Just s
3232 | S.map toLower s == "websocket" -> Just $ runWebSockets opts req' app
@@ -41,9 +41,9 @@ runWebSockets :: WS.Protocol p
4141 => WS.WebSocketsOptions
4242 -> WS.RequestHttpPart
4343 -> (WS.Request -> WS.WebSockets p ())
44− -> Source (ResourceT IO) ByteString
44+ -> Source IO ByteString
4545 -> Warp.Connection
46− -> ResourceT IO ()
46+ -> IO ()
4747runWebSockets opts req app source conn = do
4848 step <- liftIO $ E.runIteratee $ WS.runWebSocketsWith opts req app send
4949 source $$ sink (E.returnI step)
wai-websockets/wai-websockets.cabal+3−3
@@ -1,5 +1,5 @@
11Name: wai-websockets
2−Version: 1.3.1.2
2+Version: 2.0.0
33Synopsis: Provide a bridge betweeen WAI and the websockets package.
44License: MIT
55License-file: LICENSE
@@ -20,7 +20,7 @@ Library
2020 Build-Depends: base >= 3 && < 5
2121 , bytestring >= 0.9.1.4
2222 , conduit >= 0.5 && < 1.1
23− , wai >= 1.3 && < 1.5
23+ , wai >= 2.0 && < 2.1
2424 , enumerator >= 0.4.8 && < 0.5
2525 , network-enumerator >= 0.1.2 && < 0.2
2626 , blaze-builder >= 0.2.1.4 && < 0.4
@@ -28,7 +28,7 @@ Library
2828 , network >= 2.2.1.5
2929 , transformers >= 0.2 && < 0.4
3030 , websockets >= 0.6 && < 0.8
31− , warp >= 1.3 && < 1.4
31+ , warp >= 2.0 && < 2.1
3232 Exposed-modules: Network.Wai.Handler.WebSockets
3333 ghc-options: -Wall
3434
wai/wai.cabal+1−1
@@ -1,5 +1,5 @@
11Name: wai
2−Version: 1.5.0
2+Version: 2.0.0
33Synopsis: Web Application Interface.
44Description: Provides a common protocol for communication between web applications and web servers.
55License: MIT
warp-static/warp-static.cabal+4−4
@@ -1,5 +1,5 @@
11Name: warp-static
2−Version: 1.3.0.1
2+Version: 2.0.0
33Synopsis: Static file server based on Warp and wai-app-static
44Homepage: http://github.com/yesodweb/wai
55License: MIT
@@ -15,9 +15,9 @@ Description: Serve up static files by running the warp executable. Based
1515Executable warp
1616 Main-is: warp.hs
1717 Build-depends: base >= 4 && < 5
18− , warp >= 1.3 && < 1.4
19− , wai-app-static >= 1.3 && < 1.4
20− , wai-extra >= 1.3 && < 1.4
18+ , warp >= 2.0 && < 2.1
19+ , wai-app-static >= 2.0 && < 2.1
20+ , wai-extra >= 2.0 && < 2.1
2121 , cmdargs >= 0.6.7
2222 , directory >= 1.0
2323 , containers >= 0.2
warp-tls/warp-tls.cabal+3−3
@@ -1,5 +1,5 @@
11Name: warp-tls
2−Version: 1.4.1.3
2+Version: 2.0.0
33Synopsis: HTTP over SSL/TLS support for Warp via the TLS package
44License: MIT
55License-file: LICENSE
@@ -15,8 +15,8 @@ Description: HTTP over SSL/TLS support for Warp via the TLS package.
1515Library
1616 Build-Depends: base >= 4 && < 5
1717 , bytestring >= 0.9
18− , wai >= 1.3 && < 1.5
19− , warp >= 1.3.5 && < 1.4
18+ , wai >= 2.0 && < 2.1
19+ , warp >= 2.0 && < 2.1
2020 , transformers >= 0.2
2121 , conduit >= 0.5 && < 1.1
2222 , network-conduit >= 0.6 && < 1.1
warp/warp.cabal+2−2
@@ -1,5 +1,5 @@
11Name: warp
2−Version: 1.5.0
2+Version: 2.0.0
33Synopsis: A fast, light-weight web server for WAI applications.
44License: MIT
55License-file: LICENSE
@@ -42,7 +42,7 @@ Library
4242 , transformers >= 0.2.2 && < 0.4
4343 , unix-compat >= 0.2
4444 , void
45− , wai >= 1.5 && < 1.6
45+ , wai >= 2.0 && < 2.1
4646 , http-attoparsec
4747 , resourcet
4848 if flag(network-bytestring)