on master help sign in
drop blaze-builder dependency for wai
e7232dcMichael Karg
wai/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.2.1.2
2+
3+* Drop dependency on blaze-builder
4+
1## 3.2.1.1
5## 3.2.1.1
2
6
3* Relax upper bound on bytestring-builder
7* Relax upper bound on bytestring-builder
wai/Network/Wai.hs+6−7
@@ -83,8 +83,7 @@ module Network.Wai
83 , modifyResponse
83 , modifyResponse
84 ) where
84 ) where
85
85
86−import Blaze.ByteString.Builder (Builder, fromLazyByteString)
86+import Data.ByteString.Builder (Builder, byteString, lazyByteString)
87−import Blaze.ByteString.Builder (fromByteString)
88import Control.Monad (unless)
87import Control.Monad (unless)
89import qualified Data.ByteString as B
88import qualified Data.ByteString as B
90import qualified Data.ByteString.Lazy as L
89import qualified Data.ByteString.Lazy as L
@@ -134,7 +133,7 @@ responseBuilder = ResponseBuilder
134-- | Creating 'Response' from 'L.ByteString'. This is a wrapper for
133-- | Creating 'Response' from 'L.ByteString'. This is a wrapper for
135-- 'responseBuilder'.
134-- 'responseBuilder'.
136responseLBS :: H.Status -> H.ResponseHeaders -> L.ByteString -> Response
135responseLBS :: H.Status -> H.ResponseHeaders -> L.ByteString -> Response
137−responseLBS s h = ResponseBuilder s h . fromLazyByteString
136+responseLBS s h = ResponseBuilder s h . lazyByteString
138
137
139-- | Creating 'Response' from a stream of values.
138-- | Creating 'Response' from a stream of values.
140--
139--
@@ -148,9 +147,9 @@ responseLBS s h = ResponseBuilder s h . fromLazyByteString
148-- (putStrLn \"Allocating scarce resource\")
147-- (putStrLn \"Allocating scarce resource\")
149-- (putStrLn \"Cleaning up\")
148-- (putStrLn \"Cleaning up\")
150-- $ respond $ responseStream status200 [] $ \\write flush -> do
149-- $ respond $ responseStream status200 [] $ \\write flush -> do
151−-- write $ fromByteString \"Hello\\n\"
150+-- write $ byteString \"Hello\\n\"
152-- flush
151-- flush
153−-- write $ fromByteString \"World\\n\"
152+-- write $ byteString \"World\\n\"
154-- @
153-- @
155--
154--
156-- Note that in some cases you can use @bracket@ from inside @responseStream@
155-- Note that in some cases you can use @bracket@ from inside @responseStream@
@@ -213,7 +212,7 @@ responseToStream (ResponseFile s h fp (Just part)) =
213 bs <- B.hGetSome handle defaultChunkSize
212 bs <- B.hGetSome handle defaultChunkSize
214 unless (B.null bs) $ do
213 unless (B.null bs) $ do
215 let x = B.take remaining bs
214 let x = B.take remaining bs
216− sendChunk $ fromByteString x
215+ sendChunk $ byteString x
217 loop $ remaining - B.length x
216 loop $ remaining - B.length x
218 loop $ fromIntegral $ filePartByteCount part
217 loop $ fromIntegral $ filePartByteCount part
219 )
218 )
@@ -224,7 +223,7 @@ responseToStream (ResponseFile s h fp Nothing) =
224 withBody $ \sendChunk _flush -> fix $ \loop -> do
223 withBody $ \sendChunk _flush -> fix $ \loop -> do
225 bs <- B.hGetSome handle defaultChunkSize
224 bs <- B.hGetSome handle defaultChunkSize
226 unless (B.null bs) $ do
225 unless (B.null bs) $ do
227− sendChunk $ fromByteString bs
226+ sendChunk $ byteString bs
228 loop
227 loop
229 )
228 )
230responseToStream (ResponseBuilder s h b) =
229responseToStream (ResponseBuilder s h b) =
wai/Network/Wai/Internal.hs+1−1
@@ -5,7 +5,7 @@
5-- given for stability of these interfaces.
5-- given for stability of these interfaces.
6module Network.Wai.Internal where
6module Network.Wai.Internal where
7
7
8−import Blaze.ByteString.Builder (Builder)
8+import Data.ByteString.Builder (Builder)
9import qualified Data.ByteString as B hiding (pack)
9import qualified Data.ByteString as B hiding (pack)
10import Data.Text (Text)
10import Data.Text (Text)
11import Data.Typeable (Typeable)
11import Data.Typeable (Typeable)
wai/test/Network/WaiSpec.hs+4−4
@@ -7,7 +7,7 @@ import Data.IORef
7import Data.Monoid
7import Data.Monoid
8import qualified Data.ByteString as S
8import qualified Data.ByteString as S
9import qualified Data.ByteString.Lazy as L
9import qualified Data.ByteString.Lazy as L
10−import Blaze.ByteString.Builder (toByteString, Builder, fromWord8)
10+import Data.ByteString.Builder (Builder, toLazyByteString, word8)
11import Control.Monad (forM_)
11import Control.Monad (forM_)
12
12
13spec :: Spec
13spec :: Spec
@@ -23,17 +23,17 @@ spec = do
23 flush :: IO ()
23 flush :: IO ()
24 flush = return ()
24 flush = return ()
25 streamingBody add flush
25 streamingBody add flush
26− fmap toByteString $ readIORef builderRef
26+ fmap (L.toStrict . toLazyByteString) $ readIORef builderRef
27 prop "responseLBS" $ \bytes -> do
27 prop "responseLBS" $ \bytes -> do
28 body <- getBody $ responseLBS undefined undefined $ L.pack bytes
28 body <- getBody $ responseLBS undefined undefined $ L.pack bytes
29 body `shouldBe` S.pack bytes
29 body `shouldBe` S.pack bytes
30 prop "responseBuilder" $ \bytes -> do
30 prop "responseBuilder" $ \bytes -> do
31 body <- getBody $ responseBuilder undefined undefined
31 body <- getBody $ responseBuilder undefined undefined
32− $ mconcat $ map fromWord8 bytes
32+ $ mconcat $ map word8 bytes
33 body `shouldBe` S.pack bytes
33 body `shouldBe` S.pack bytes
34 prop "responseStream" $ \chunks -> do
34 prop "responseStream" $ \chunks -> do
35 body <- getBody $ responseStream undefined undefined $ \sendChunk _ ->
35 body <- getBody $ responseStream undefined undefined $ \sendChunk _ ->
36− forM_ chunks $ \chunk -> sendChunk $ mconcat $ map fromWord8 chunk
36+ forM_ chunks $ \chunk -> sendChunk $ mconcat $ map word8 chunk
37 body `shouldBe` S.concat (map S.pack chunks)
37 body `shouldBe` S.concat (map S.pack chunks)
38 it "responseFile total" $ do
38 it "responseFile total" $ do
39 let fp = "wai.cabal"
39 let fp = "wai.cabal"
wai/wai.cabal+2−4
@@ -1,5 +1,5 @@
1Name: wai
1Name: wai
2−Version: 3.2.1.1
2+Version: 3.2.1.2
3Synopsis: Web Application Interface.
3Synopsis: Web Application Interface.
4Description: Provides a common protocol for communication between web applications and web servers.
4Description: Provides a common protocol for communication between web applications and web servers.
5description: API docs and the README are available at <http://www.stackage.org/package/wai>.
5description: API docs and the README are available at <http://www.stackage.org/package/wai>.
@@ -20,8 +20,7 @@ Source-repository head
20
20
21Library
21Library
22 Build-Depends: base >= 4.8 && < 5
22 Build-Depends: base >= 4.8 && < 5
23− , bytestring >= 0.10
23+ , bytestring >= 0.10.2
24− , blaze-builder >= 0.2.1.4 && < 0.5
25 , network >= 2.2.1.5
24 , network >= 2.2.1.5
26 , http-types >= 0.7
25 , http-types >= 0.7
27 , text >= 0.7
26 , text >= 0.7
@@ -40,7 +39,6 @@ test-suite test
40 build-depends: base >= 4.8 && < 5
39 build-depends: base >= 4.8 && < 5
41 , wai
40 , wai
42 , hspec
41 , hspec
43− , blaze-builder
44 , bytestring
42 , bytestring
45 other-modules: Network.WaiSpec
43 other-modules: Network.WaiSpec
46
44