on master help sign in
drop blaze-builder dependency for wai
commite7232dc87f23ba9c657e35c938c3c7d0a5585373 authorMichael Karg <mgoremeier@gmail.com> dateSun 11 Mar 2018, 21:37 (9 years ago) parentf4a379f
5 files changed+17−16
wai/ChangeLog.md+4 wai/Network/Wai.hs+6−7 wai/Network/Wai/Internal.hs+1−1 wai/test/Network/WaiSpec.hs+4−4 wai/wai.cabal+2−4
wai/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.2.1.2
2+
3+* Drop dependency on blaze-builder
4+
15## 3.2.1.1
26
37* Relax upper bound on bytestring-builder
wai/Network/Wai.hs+6−7
@@ -83,8 +83,7 @@ module Network.Wai
8383 , modifyResponse
8484 ) where
8585
86−import Blaze.ByteString.Builder (Builder, fromLazyByteString)
87−import Blaze.ByteString.Builder (fromByteString)
86+import Data.ByteString.Builder (Builder, byteString, lazyByteString)
8887import Control.Monad (unless)
8988import qualified Data.ByteString as B
9089import qualified Data.ByteString.Lazy as L
@@ -134,7 +133,7 @@ responseBuilder = ResponseBuilder
134133-- | Creating 'Response' from 'L.ByteString'. This is a wrapper for
135134-- 'responseBuilder'.
136135responseLBS :: H.Status -> H.ResponseHeaders -> L.ByteString -> Response
137−responseLBS s h = ResponseBuilder s h . fromLazyByteString
136+responseLBS s h = ResponseBuilder s h . lazyByteString
138137
139138-- | Creating 'Response' from a stream of values.
140139--
@@ -148,9 +147,9 @@ responseLBS s h = ResponseBuilder s h . fromLazyByteString
148147-- (putStrLn \"Allocating scarce resource\")
149148-- (putStrLn \"Cleaning up\")
150149-- $ respond $ responseStream status200 [] $ \\write flush -> do
151−-- write $ fromByteString \"Hello\\n\"
150+-- write $ byteString \"Hello\\n\"
152151-- flush
153−-- write $ fromByteString \"World\\n\"
152+-- write $ byteString \"World\\n\"
154153-- @
155154--
156155-- Note that in some cases you can use @bracket@ from inside @responseStream@
@@ -213,7 +212,7 @@ responseToStream (ResponseFile s h fp (Just part)) =
213212 bs <- B.hGetSome handle defaultChunkSize
214213 unless (B.null bs) $ do
215214 let x = B.take remaining bs
216− sendChunk $ fromByteString x
215+ sendChunk $ byteString x
217216 loop $ remaining - B.length x
218217 loop $ fromIntegral $ filePartByteCount part
219218 )
@@ -224,7 +223,7 @@ responseToStream (ResponseFile s h fp Nothing) =
224223 withBody $ \sendChunk _flush -> fix $ \loop -> do
225224 bs <- B.hGetSome handle defaultChunkSize
226225 unless (B.null bs) $ do
227− sendChunk $ fromByteString bs
226+ sendChunk $ byteString bs
228227 loop
229228 )
230229responseToStream (ResponseBuilder s h b) =
wai/Network/Wai/Internal.hs+1−1
@@ -5,7 +5,7 @@
55-- given for stability of these interfaces.
66module Network.Wai.Internal where
77
8−import Blaze.ByteString.Builder (Builder)
8+import Data.ByteString.Builder (Builder)
99import qualified Data.ByteString as B hiding (pack)
1010import Data.Text (Text)
1111import Data.Typeable (Typeable)
wai/test/Network/WaiSpec.hs+4−4
@@ -7,7 +7,7 @@ import Data.IORef
77import Data.Monoid
88import qualified Data.ByteString as S
99import qualified Data.ByteString.Lazy as L
10−import Blaze.ByteString.Builder (toByteString, Builder, fromWord8)
10+import Data.ByteString.Builder (Builder, toLazyByteString, word8)
1111import Control.Monad (forM_)
1212
1313spec :: Spec
@@ -23,17 +23,17 @@ spec = do
2323 flush :: IO ()
2424 flush = return ()
2525 streamingBody add flush
26− fmap toByteString $ readIORef builderRef
26+ fmap (L.toStrict . toLazyByteString) $ readIORef builderRef
2727 prop "responseLBS" $ \bytes -> do
2828 body <- getBody $ responseLBS undefined undefined $ L.pack bytes
2929 body `shouldBe` S.pack bytes
3030 prop "responseBuilder" $ \bytes -> do
3131 body <- getBody $ responseBuilder undefined undefined
32− $ mconcat $ map fromWord8 bytes
32+ $ mconcat $ map word8 bytes
3333 body `shouldBe` S.pack bytes
3434 prop "responseStream" $ \chunks -> do
3535 body <- getBody $ responseStream undefined undefined $ \sendChunk _ ->
36− forM_ chunks $ \chunk -> sendChunk $ mconcat $ map fromWord8 chunk
36+ forM_ chunks $ \chunk -> sendChunk $ mconcat $ map word8 chunk
3737 body `shouldBe` S.concat (map S.pack chunks)
3838 it "responseFile total" $ do
3939 let fp = "wai.cabal"
wai/wai.cabal+2−4
@@ -1,5 +1,5 @@
11Name: wai
2−Version: 3.2.1.1
2+Version: 3.2.1.2
33Synopsis: Web Application Interface.
44Description: Provides a common protocol for communication between web applications and web servers.
55description: API docs and the README are available at <http://www.stackage.org/package/wai>.
@@ -20,8 +20,7 @@ Source-repository head
2020
2121Library
2222 Build-Depends: base >= 4.8 && < 5
23− , bytestring >= 0.10
24− , blaze-builder >= 0.2.1.4 && < 0.5
23+ , bytestring >= 0.10.2
2524 , network >= 2.2.1.5
2625 , http-types >= 0.7
2726 , text >= 0.7
@@ -40,7 +39,6 @@ test-suite test
4039 build-depends: base >= 4.8 && < 5
4140 , wai
4241 , hspec
43− , blaze-builder
4442 , bytestring
4543 other-modules: Network.WaiSpec
4644