on master help sign in
Merge PR #682.
commit7819ee605324496e31fd86408e521dc0f484744a authorKazu Yamamoto <kazu@iij.ad.jp> dateFri 16 Mar 2018, 10:48 (9 years ago) parentf4a379ffc4ecb7
37 files changed+160−149
stack.yaml+6 wai-app-static/ChangeLog.md+4 wai-app-static/Network/Wai/Application/Static.hs+2−2 wai-app-static/WaiAppStatic/Storage/Embedded/Runtime.hs+3−3 wai-app-static/WaiAppStatic/Storage/Embedded/TH.hs+2−2 wai-app-static/WaiAppStatic/Types.hs+1−2 wai-app-static/wai-app-static.cabal+3−4 wai-conduit/ChangeLog.md+4 wai-conduit/Network/Wai/Conduit.hs+1−1 wai-conduit/wai-conduit.cabal+2−3 wai-extra/ChangeLog.md+4 wai-extra/Network/Wai/EventSource/EventStream.hs+8−9 wai-extra/Network/Wai/Handler/CGI.hs+16−25 wai-extra/Network/Wai/Header.hs+1−1 wai-extra/Network/Wai/Middleware/Gzip.hs+3−12 wai-extra/Network/Wai/Middleware/Jsonp.hs+7−7 wai-extra/Network/Wai/Middleware/RequestLogger.hs+2−2 wai-extra/Network/Wai/Middleware/RequestLogger/JSON.hs+3−2 wai-extra/Network/Wai/Test.hs+3−4 wai-extra/example/Main.hs+4−4 wai-extra/test/Network/Wai/TestSpec.hs+5−1 wai-extra/wai-extra.cabal+5−7 wai-handler-launch/ChangeLog.md+4 wai-handler-launch/Network/Wai/Handler/Launch.hs+21−21 wai-handler-launch/wai-handler-launch.cabal+3−4 wai-websockets/ChangeLog.md+4 wai-websockets/wai-websockets.cabal+1−3 wai/ChangeLog.md+4 wai/Network/Wai.hs+12−13 wai/Network/Wai/Internal.hs+1−1 wai/test/Network/WaiSpec.hs+4−5 wai/wai.cabal+5−5 wai/webkit-sample/webkit-sample.hs+2−2 warp/ChangeLog.md+4 warp/Network/Wai/Handler/Warp/MultiMap.hs+1 warp/Network/Wai/Handler/Warp/Response.hs+1−1 warp/warp.cabal+4−3
stack.yaml+6
@@ -14,8 +14,14 @@ flags:
1414 wai-extra:
1515 build-example: true
1616extra-deps:
17+- bsb-http-chunked-0
1718- tls-session-manager-0.0.0.2
1819- psqueues-0.2.4.0
20+- streaming-commons-0.2.0.0
21+- wai-logger-2.3.2
22+- http-client-0.5.10
23+- websockets-0.12.4.0
24+- binary-0.8.5.1
1925nix:
2026 enable: false
2127 packages:
wai-app-static/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.1.6.2
2+
3+* Drop dependency on blaze-builder
4+
15## 3.1.6.1
26
37* Add `<>` import
wai-app-static/Network/Wai/Application/Static.hs+2−2
@@ -34,7 +34,7 @@ import qualified Data.ByteString.Lazy as L
3434import Data.ByteString.Lazy.Char8 ()
3535import Control.Monad.IO.Class (liftIO)
3636
37−import Blaze.ByteString.Builder (toByteString)
37+import Data.ByteString.Builder (toLazyByteString)
3838
3939import Data.FileEmbed (embedFile)
4040
@@ -262,7 +262,7 @@ staticAppPieces ss rawPieces req sendResponse = liftIO $ do
262262 ] lbs
263263
264264 response (Redirect pieces' mHash) = do
265− let loc = (ssMkRedirect ss) pieces' $ toByteString (H.encodePathSegments $ map fromPiece pieces')
265+ let loc = ssMkRedirect ss pieces' $ L.toStrict $ toLazyByteString (H.encodePathSegments $ map fromPiece pieces')
266266 let qString = case mHash of
267267 Just hash -> replace "etag" (Just hash) (W.queryString req)
268268 Nothing -> remove "etag" (W.queryString req)
wai-app-static/WaiAppStatic/Storage/Embedded/Runtime.hs+3−3
@@ -8,7 +8,7 @@ import WaiAppStatic.Types
88import Data.ByteString (ByteString)
99import Control.Arrow ((&&&), second)
1010import Data.List
11−import Blaze.ByteString.Builder (fromByteString)
11+import Data.ByteString.Builder (byteString)
1212import qualified Network.Wai as W
1313import qualified Data.Map as Map
1414import Data.Function (on)
@@ -50,7 +50,7 @@ toEntry :: (Piece, EmbeddedEntry) -> Either FolderName File
5050toEntry (name, EEFolder{}) = Left name
5151toEntry (name, EEFile bs) = Right File
5252 { fileGetSize = fromIntegral $ S.length bs
53− , fileToResponse = \s h -> W.responseBuilder s h $ fromByteString bs
53+ , fileToResponse = \s h -> W.responseBuilder s h $ byteString bs
5454 , fileName = name
5555 , fileGetHash = return $ Just $ runHash bs
5656 , fileGetModified = Nothing
@@ -87,7 +87,7 @@ toEmbedded fps =
8787bsToFile :: Piece -> ByteString -> File
8888bsToFile name bs = File
8989 { fileGetSize = fromIntegral $ S.length bs
90− , fileToResponse = \s h -> W.responseBuilder s h $ fromByteString bs
90+ , fileToResponse = \s h -> W.responseBuilder s h $ byteString bs
9191 , fileName = name
9292 , fileGetHash = return $ Just $ runHash bs
9393 , fileGetModified = Nothing
wai-app-static/WaiAppStatic/Storage/Embedded/TH.hs+2−2
@@ -5,7 +5,7 @@ module WaiAppStatic.Storage.Embedded.TH(
55 , mkSettings
66) where
77
8−import Blaze.ByteString.Builder.ByteString (insertByteString)
8+import Data.ByteString.Builder.Extra (byteStringInsert)
99import Codec.Compression.GZip (compress)
1010import Control.Applicative
1111import Data.ByteString.Unsafe (unsafePackAddressLen)
@@ -130,7 +130,7 @@ embeddedToFile entry = File
130130 let h' = if embCompressed entry
131131 then h ++ [("Content-Encoding", "gzip")]
132132 else h
133− in W.responseBuilder s h' $ insertByteString $ embContent entry
133+ in W.responseBuilder s h' $ byteStringInsert $ embContent entry
134134
135135 -- Usually the fileName should just be the filename not the entire path,
136136 -- but we need the whole path to make the lookup within lookupMime
wai-app-static/WaiAppStatic/Types.hs+1−2
@@ -1,4 +1,3 @@
1−{-# LANGUAGE OverloadedStrings #-}
21module WaiAppStatic.Types
32 ( -- * Pieces
43 Piece
@@ -25,7 +24,7 @@ import qualified Network.Wai as W
2524import Data.ByteString (ByteString)
2625import System.Posix.Types (EpochTime)
2726import qualified Data.Text as T
28−import Blaze.ByteString.Builder (Builder)
27+import Data.ByteString.Builder (Builder)
2928import Network.Mime (MimeType)
3029
3130-- | An individual component of a path, or of a filepath.
wai-app-static/wai-app-static.cabal+3−4
@@ -1,5 +1,5 @@
11name: wai-app-static
2−version: 3.1.6.1
2+version: 3.1.6.2
33license: MIT
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
@@ -27,7 +27,7 @@ Flag print
2727library
2828 build-depends: base >= 4 && < 5
2929 , wai >= 3.0 && < 3.3
30− , bytestring >= 0.9.1.4
30+ , bytestring >= 0.10.4
3131 , http-types >= 0.7
3232 , transformers >= 0.2.2
3333 , unix-compat >= 0.2
@@ -37,7 +37,6 @@ library
3737 , old-locale >= 1.0.0.2
3838 , file-embed >= 0.0.3.1
3939 , text >= 0.7
40− , blaze-builder >= 0.2.1.4
4140 , cryptonite >= 0.6
4241 , memory >= 0.7
4342 , http-date
@@ -74,7 +73,7 @@ Executable warp
7473 , wai-app-static
7574 , directory >= 1.0
7675 , containers >= 0.2
77− , bytestring >= 0.9.1.4
76+ , bytestring >= 0.10.4
7877 , text >= 0.7
7978 , mime-types >= 0.1 && < 0.2
8079
wai-conduit/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.0.0.4
2+
3+* Drop dependency on blaze-builder
4+
15## 3.0.0.3
26
37* Support wai 3.2
wai-conduit/Network/Wai/Conduit.hs+1−1
@@ -16,7 +16,7 @@ import Data.ByteString (ByteString)
1616import qualified Data.ByteString as S
1717import Control.Monad (unless)
1818import Network.HTTP.Types
19−import Blaze.ByteString.Builder (Builder)
19+import Data.ByteString.Builder (Builder)
2020import Data.IORef
2121import qualified Data.Conduit.List as CL
2222
wai-conduit/wai-conduit.cabal+2−3
@@ -1,5 +1,5 @@
11name: wai-conduit
2−version: 3.0.0.3
2+version: 3.0.0.4
33synopsis: conduit wrappers for WAI
44description: API docs and the README are available at <http://www.stackage.org/package/wai-conduit>.
55homepage: https://github.com/yesodweb/wai
@@ -18,7 +18,6 @@ library
1818 , wai >= 3.0 && < 3.3
1919 , conduit
2020 , transformers
21− , bytestring
21+ , bytestring >= 0.10.4
2222 , http-types
23− , blaze-builder
2423 default-language: Haskell2010
wai-extra/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.0.22.1
2+
3+* Drop dependency on blaze-builder, requiring streaming-commons >= 0.2
4+
15## 3.0.22.0
26
37* Support for streaming-commons 0.2
wai-extra/Network/Wai/EventSource/EventStream.hs+8−9
@@ -9,8 +9,7 @@ module Network.Wai.EventSource.EventStream (
99 eventToBuilder
1010 ) where
1111
12−import Blaze.ByteString.Builder
13−import Blaze.ByteString.Builder.Char8
12+import Data.ByteString.Builder
1413#if __GLASGOW_HASKELL__ < 710
1514import Data.Monoid
1615#endif
@@ -39,18 +38,18 @@ data ServerEvent
3938 Newline as a Builder.
4039-}
4140nl :: Builder
42−nl = fromChar '\n'
41+nl = char7 '\n'
4342
4443
4544{-|
4645 Field names as Builder
4746-}
4847nameField, idField, dataField, retryField, commentField :: Builder
49−nameField = fromString "event:"
50−idField = fromString "id:"
51−dataField = fromString "data:"
52−retryField = fromString "retry:"
53−commentField = fromChar ':'
48+nameField = string7 "event:"
49+idField = string7 "id:"
50+dataField = string7 "data:"
51+retryField = string7 "retry:"
52+commentField = char7 ':'
5453
5554
5655{-|
@@ -66,7 +65,7 @@ field l b = l `mappend` b `mappend` nl
6665-}
6766eventToBuilder :: ServerEvent -> Maybe Builder
6867eventToBuilder (CommentEvent txt) = Just $ field commentField txt
69−eventToBuilder (RetryEvent n) = Just $ field retryField (fromShow n)
68+eventToBuilder (RetryEvent n) = Just $ field retryField (string8 . show $ n)
7069eventToBuilder (CloseEvent) = Nothing
7170eventToBuilder (ServerEvent n i d)= Just $
7271 (name n $ evid i $ mconcat (map (field dataField) d)) `mappend` nl
wai-extra/Network/Wai/Handler/CGI.hs+16−25
@@ -19,8 +19,8 @@ import Control.Arrow ((***))
1919import Data.Char (toLower)
2020import qualified System.IO
2121import qualified Data.String as String
22−import Blaze.ByteString.Builder (fromByteString, toLazyByteString, flush)
23−import Blaze.ByteString.Builder.Char8 (fromChar, fromString)
22+import Data.ByteString.Builder (byteString, toLazyByteString, char7, string8)
23+import Data.ByteString.Builder.Extra (flush)
2424import Data.ByteString.Lazy.Internal (defaultChunkSize)
2525import System.IO (Handle)
2626import Network.HTTP.Types (Status (..), hRange, hContentType, hContentLength)
@@ -30,12 +30,7 @@ import qualified Data.CaseInsensitive as CI
3030import Data.Monoid (mconcat, mempty, mappend)
3131#endif
3232
33−#if MIN_VERSION_streaming_commons(0, 2, 0)
34−import qualified Data.Streaming.ByteString.Builder as Blaze
35−#else
36−import qualified Data.Streaming.Blaze as Blaze
37−#endif
38−
33+import qualified Data.Streaming.ByteString.Builder as Builder
3934import Data.Function (fix)
4035import Control.Monad (unless, void)
4136
@@ -136,11 +131,7 @@ runGeneric vars inputH outputH xsendfile app = do
136131 return ResponseReceived
137132 _ -> do
138133 let (s, hs, wb) = responseToStream res
139−#if MIN_VERSION_streaming_commons(0, 2, 0)
140− (blazeRecv, blazeFinish) <- Blaze.newBuilderRecv Blaze.defaultStrategy
141−#else
142− (blazeRecv, blazeFinish) <- Blaze.newBlazeRecv Blaze.defaultStrategy
143−#endif
134+ (blazeRecv, blazeFinish) <- Builder.newBuilderRecv Builder.defaultStrategy
144135 wb $ \b -> do
145136 let sendBuilder builder = do
146137 popper <- blazeRecv builder
@@ -149,30 +140,30 @@ runGeneric vars inputH outputH xsendfile app = do
149140 unless (B.null bs) $ do
150141 outputH bs
151142 loop
152− sendBuilder $ headers s hs `mappend` fromChar '\n'
143+ sendBuilder $ headers s hs `mappend` char7 '\n'
153144 b sendBuilder (sendBuilder flush)
154145 blazeFinish >>= maybe (return ()) outputH
155146 return ResponseReceived
156147 where
157148 headers s hs = mconcat (map header $ status s : map header' (fixHeaders hs))
158− status (Status i m) = (fromByteString "Status", mconcat
159− [ fromString $ show i
160− , fromChar ' '
161− , fromByteString m
149+ status (Status i m) = (byteString "Status", mconcat
150+ [ string8 $ show i
151+ , char7 ' '
152+ , byteString m
162153 ])
163− header' (x, y) = (fromByteString $ CI.original x, fromByteString y)
154+ header' (x, y) = (byteString $ CI.original x, byteString y)
164155 header (x, y) = mconcat
165156 [ x
166− , fromByteString ": "
157+ , byteString ": "
167158 , y
168− , fromChar '\n'
159+ , char7 '\n'
169160 ]
170161 sfBuilder s hs sf fp = mconcat
171162 [ headers s hs
172− , header $ (fromByteString sf, fromString fp)
173− , fromChar '\n'
174− , fromByteString sf
175− , fromByteString " not supported"
163+ , header $ (byteString sf, string8 fp)
164+ , char7 '\n'
165+ , byteString sf
166+ , byteString " not supported"
176167 ]
177168 fixHeaders h =
178169 case lookup hContentType h of
wai-extra/Network/Wai/Header.hs+1−1
@@ -14,5 +14,5 @@ contentLength hdrs = lookup H.hContentLength hdrs >>= readInt
1414readInt :: S8.ByteString -> Maybe Integer
1515readInt bs =
1616 case S8.readInteger bs of
17− Just (i, "") -> Just i
17+ Just (i, rest) | S8.null rest -> Just i
1818 _ -> Nothing
wai-extra/Network/Wai/Middleware/Gzip.hs+3−12
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# LANGUAGE Rank2Types, ScopedTypeVariables #-}
32---------------------------------------------------------
43-- |
@@ -31,18 +30,14 @@ import Data.Default.Class
3130import Network.HTTP.Types ( Status, Header, hContentEncoding, hUserAgent
3231 , hContentType, hContentLength)
3332import System.Directory (doesFileExist, createDirectoryIfMissing)
34−import Blaze.ByteString.Builder (fromByteString)
33+import Data.ByteString.Builder (byteString)
34+import qualified Data.ByteString.Builder.Extra as Blaze (flush)
3535import Control.Exception (try, SomeException)
3636import qualified Data.Set as Set
3737import Network.Wai.Header
3838import Network.Wai.Internal
39−#if MIN_VERSION_streaming_commons(0, 2, 0)
4039import qualified Data.Streaming.ByteString.Builder as B
41−#else
42−import qualified Data.Streaming.Blaze as B
43−#endif
4440import qualified Data.Streaming.Zlib as Z
45−import qualified Blaze.ByteString.Builder as Blaze
4641import Control.Monad (unless)
4742import Data.Function (fix)
4843import Control.Exception (throwIO)
@@ -187,11 +182,7 @@ compressE set res sendResponse =
187182 Just m | gzipCheckMime set m ->
188183 let hs' = fixHeaders hs
189184 in wb $ \body -> sendResponse $ responseStream s hs' $ \sendChunk flush -> do
190−#if MIN_VERSION_streaming_commons(0, 2, 0)
191185 (blazeRecv, _) <- B.newBuilderRecv B.defaultStrategy
192−#else
193− (blazeRecv, _) <- B.newBlazeRecv B.defaultStrategy
194−#endif
195186 deflate <- Z.initDeflate 1 (Z.WindowBits 31)
196187 let sendBuilder builder = do
197188 popper <- blazeRecv builder
@@ -210,7 +201,7 @@ compressE set res sendResponse =
210201 case result of
211202 Z.PRDone -> return ()
212203 Z.PRNext bs' -> do
213− sendChunk $ fromByteString bs'
204+ sendChunk $ byteString bs'
214205 loop
215206 Z.PRError e -> throwIO e
216207
wai-extra/Network/Wai/Middleware/Jsonp.hs+7−7
@@ -18,8 +18,8 @@ import Network.Wai
1818import Network.Wai.Internal
1919import Data.ByteString (ByteString)
2020import qualified Data.ByteString.Char8 as B8
21−import Blaze.ByteString.Builder (copyByteString)
22−import Blaze.ByteString.Builder.Char8 (fromChar)
21+import Data.ByteString.Builder.Extra (byteStringCopy)
22+import Data.ByteString.Builder (char7)
2323#if __GLASGOW_HASKELL__ < 710
2424import Data.Monoid (mappend)
2525#endif
@@ -60,10 +60,10 @@ jsonp app env sendResponse = do
6060 sendResponse $ case checkJSON hs of
6161 Nothing -> r
6262 Just hs' -> responseBuilder s hs' $
63− copyByteString c
64− `mappend` fromChar '('
63+ byteStringCopy c
64+ `mappend` char7 '('
6565 `mappend` b
66− `mappend` fromChar ')'
66+ `mappend` char7 ')'
6767 go c r =
6868 case checkJSON hs of
6969 Just hs' -> addCallback c s hs' wb
@@ -81,9 +81,9 @@ jsonp app env sendResponse = do
8181
8282 addCallback cb s hs wb =
8383 wb $ \body -> sendResponse $ responseStream s hs $ \sendChunk flush -> do
84− sendChunk $ copyByteString cb `mappend` fromChar '('
84+ sendChunk $ byteStringCopy cb `mappend` char7 '('
8585 _ <- body sendChunk flush
86− sendChunk $ fromChar ')'
86+ sendChunk $ char7 ')'
8787
8888changeVal :: Eq a
8989 => a
wai-extra/Network/Wai/Middleware/RequestLogger.hs+2−2
@@ -20,7 +20,7 @@ module Network.Wai.Middleware.RequestLogger
2020 ) where
2121
2222import System.IO (Handle, hFlush, stdout)
23−import qualified Blaze.ByteString.Builder as B
23+import qualified Data.ByteString.Builder as B (Builder, byteString)
2424import qualified Data.ByteString as BS
2525import Data.ByteString.Char8 (pack)
2626import Control.Monad (when)
@@ -130,7 +130,7 @@ customMiddlewareWithDetails cb getdate formatter app req sendResponse = do
130130 t1 <- getCurrentTime
131131 date <- liftIO getdate
132132 -- We use Nothing for the response size since we generally don't know it
133− builderIO <- newIORef $ B.fromByteString ""
133+ builderIO <- newIORef $ B.byteString ""
134134 res' <- recordChunks builderIO res
135135 rspRcv <- sendResponse res'
136136 _ <- liftIO . cb .
wai-extra/Network/Wai/Middleware/RequestLogger/JSON.hs+3−2
@@ -2,7 +2,8 @@
22
33module Network.Wai.Middleware.RequestLogger.JSON (formatAsJSON) where
44
5−import qualified Blaze.ByteString.Builder as BB
5+import qualified Data.ByteString.Builder as BB (toLazyByteString)
6+import Data.ByteString.Lazy (toStrict)
67import Data.Aeson
78import Data.CaseInsensitive (original)
89import Data.Monoid ((<>))
@@ -31,7 +32,7 @@ formatAsJSON date req status responseSize duration reqBody response =
3132 , "size" .= responseSize
3233 , "body" .=
3334 if statusCode status >= 400
34− then Just . decodeUtf8 . BB.toByteString $ response
35+ then Just . decodeUtf8 . toStrict . BB.toLazyByteString $ response
3536 else Nothing
3637 ]
3738 , "time" .= decodeUtf8 date
wai-extra/Network/Wai/Test.hs+3−4
@@ -52,8 +52,7 @@ import qualified Data.Map as Map
5252import qualified Web.Cookie as Cookie
5353import Data.ByteString (ByteString)
5454import qualified Data.ByteString.Char8 as S8
55−import Blaze.ByteString.Builder (toLazyByteString, toByteString)
56−import qualified Blaze.ByteString.Builder as B
55+import Data.ByteString.Builder (toLazyByteString)
5756import qualified Data.ByteString.Lazy as L
5857import qualified Data.ByteString.Lazy.Char8 as L8
5958import qualified Network.HTTP.Types as H
@@ -114,7 +113,7 @@ request = srequest . flip SRequest L.empty
114113setPath :: Request -> S8.ByteString -> Request
115114setPath req path = req {
116115 pathInfo = segments
117− , rawPathInfo = B.toByteString (H.encodePathSegments segments)
116+ , rawPathInfo = (L8.toStrict . toLazyByteString) (H.encodePathSegments segments)
118117 , queryString = query
119118 , rawQueryString = (H.renderQuery True query)
120119 }
@@ -143,7 +142,7 @@ addCookiesToRequest req = do
143142 let cookiePairs = [ (Cookie.setCookieName c, Cookie.setCookieValue c)
144143 | c <- map snd $ Map.toList cookiesForRequest
145144 ]
146− let cookieValue = toByteString $ Cookie.renderCookies cookiePairs
145+ let cookieValue = L8.toStrict . toLazyByteString $ Cookie.renderCookies cookiePairs
147146 addCookieHeader rest
148147 | null cookiePairs = rest
149148 | otherwise = ("Cookie", cookieValue) : rest
wai-extra/example/Main.hs+4−4
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Main where
33
4−import Blaze.ByteString.Builder.Char.Utf8 (fromString)
4+import Data.ByteString.Builder (string8)
55import Control.Concurrent (forkIO, threadDelay)
66import Control.Concurrent.Chan
77import Control.Monad
@@ -27,15 +27,15 @@ eventChan :: Chan ServerEvent -> IO ()
2727eventChan chan = forever $ do
2828 threadDelay 1000000
2929 time <- getPOSIXTime
30− writeChan chan (ServerEvent Nothing Nothing [fromString . show $ time])
30+ writeChan chan (ServerEvent Nothing Nothing [string8 . show $ time])
3131
3232eventIO :: IO ServerEvent
3333eventIO = do
3434 threadDelay 1000000
3535 time <- getPOSIXTime
36− return $ ServerEvent (Just $ fromString "io")
36+ return $ ServerEvent (Just $ string8 "io")
3737 Nothing
38− [fromString . show $ time]
38+ [string8 . show $ time]
3939
4040main :: IO ()
4141main = do
wai-extra/test/Network/Wai/TestSpec.hs+5−1
@@ -16,13 +16,17 @@ import Network.Wai.Test
1616import Network.HTTP.Types (status200)
1717
1818import qualified Data.ByteString.Lazy.Char8 as L8
19−import Blaze.ByteString.Builder (toByteString)
19+import Data.ByteString.Builder (Builder, toLazyByteString)
20+import Data.ByteString (ByteString)
2021
2122import qualified Web.Cookie as Cookie
2223
2324main :: IO ()
2425main = hspec spec
2526
27+toByteString :: Builder -> ByteString
28+toByteString = L8.toStrict . toLazyByteString
29+
2630spec :: Spec
2731spec = do
2832 describe "setPath" $ do
wai-extra/wai-extra.cabal+5−7
@@ -1,5 +1,5 @@
11Name: wai-extra
2−Version: 3.0.22.0
2+Version: 3.0.22.1
33Synopsis: Provides some basic WAI handlers and middleware.
44description:
55 Provides basic WAI handler and middleware functionality:
@@ -88,20 +88,19 @@ flag build-example
8888
8989Library
9090 Build-Depends: base >= 4.6 && < 5
91− , bytestring >= 0.9.1.4
91+ , bytestring >= 0.10.4
9292 , wai >= 3.0.3.0 && < 3.3
9393 , old-locale >= 1.0.0.2 && < 1.1
9494 , time >= 1.1.4
9595 , network >= 2.6.1.0
9696 , directory >= 1.0.1
9797 , transformers >= 0.2.2
98− , blaze-builder >= 0.2.1.4 && < 0.5
9998 , http-types >= 0.7
10099 , text >= 0.7
101100 , case-insensitive >= 0.2
102101 , data-default-class
103102 , fast-logger >= 2.4.5 && < 2.5
104− , wai-logger >= 2.2.6 && < 2.4
103+ , wai-logger >= 2.3.2 && < 2.4
105104 , ansi-terminal
106105 , resourcet >= 0.4.6 && < 1.3
107106 , void >= 0.5
@@ -111,7 +110,7 @@ Library
111110 , word8
112111 , lifted-base >= 0.1.2
113112 , deepseq
114− , streaming-commons
113+ , streaming-commons >= 0.2
115114 , unix-compat
116115 , cookie
117116 , vault
@@ -171,7 +170,7 @@ executable example
171170 , wai
172171 , time
173172 , http-types
174− , blaze-builder
173+ , bytestring
175174 else
176175 buildable: False
177176 default-language: Haskell2010
@@ -200,7 +199,6 @@ test-suite spec
200199 , resourcet
201200 , bytestring
202201 , HUnit
203− , blaze-builder
204202 , cookie
205203 , time
206204 , case-insensitive
wai-handler-launch/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.0.2.4
2+
3+* Drop dependency on blaze-builder, requiring streaming-commons >= 0.2
4+
15## 3.0.2.3
26
37* `process` package bump
wai-handler-launch/Network/Wai/Handler/Launch.hs+21−21
@@ -22,15 +22,15 @@ import Control.Monad (unless)
2222import Control.Exception (throwIO)
2323import Data.Function (fix)
2424import qualified Data.ByteString as S
25−import Blaze.ByteString.Builder (fromByteString, Builder, flush)
26−import qualified Blaze.ByteString.Builder as Blaze
25+import Data.ByteString.Builder (Builder, byteString)
26+import qualified Data.ByteString.Builder.Extra as Builder (flush)
2727#if WINDOWS
2828import Foreign
2929import Foreign.C.String
3030#else
3131import System.Process (rawSystem)
3232#endif
33−import Data.Streaming.Blaze (newBlazeRecv, defaultStrategy)
33+import Data.Streaming.ByteString.Builder as B (newBuilderRecv, defaultStrategy)
3434import qualified Data.Streaming.Zlib as Z
3535
3636ping :: IORef Bool -> Middleware
@@ -60,7 +60,7 @@ decode :: (Builder -> IO ()) -> IO ()
6060 -> StreamingBody
6161 -> IO ()
6262decode sendInner flushInner streamingBody = do
63− (blazeRecv, blazeFinish) <- newBlazeRecv defaultStrategy
63+ (blazeRecv, blazeFinish) <- newBuilderRecv defaultStrategy
6464 inflate <- Z.initInflate $ Z.WindowBits 31
6565 let send builder = blazeRecv builder >>= goBuilderPopper
6666 goBuilderPopper popper = fix $ \loop -> do
@@ -73,15 +73,15 @@ decode sendInner flushInner streamingBody = do
7373 case res of
7474 Z.PRDone -> return ()
7575 Z.PRNext bs -> do
76− sendInner $ fromByteString bs
76+ sendInner $ byteString bs
7777 loop
7878 Z.PRError e -> throwIO e
79− streamingBody send (send flush)
79+ streamingBody send (send Builder.flush)
8080 mbs <- blazeFinish
8181 case mbs of
8282 Nothing -> return ()
8383 Just bs -> Z.feedInflate inflate bs >>= goZlibPopper
84− Z.finishInflate inflate >>= sendInner . fromByteString
84+ Z.finishInflate inflate >>= sendInner . byteString
8585
8686toInsert :: S.ByteString
8787toInsert = "<script>setInterval(function(){var x;if(window.XMLHttpRequest){x=new XMLHttpRequest();}else{x=new ActiveXObject(\"Microsoft.XMLHTTP\");}x.open(\"GET\",\"/_ping?\" + (new Date()).getTime(),true);x.send();},60000)</script>"
@@ -91,7 +91,7 @@ addInsideHead :: (Builder -> IO ())
9191 -> StreamingBody
9292 -> IO ()
9393addInsideHead sendInner flushInner streamingBody = do
94− (blazeRecv, blazeFinish) <- newBlazeRecv defaultStrategy
94+ (blazeRecv, blazeFinish) <- newBuilderRecv defaultStrategy
9595 ref <- newIORef $ Just (S.empty, whole)
9696 streamingBody (inner blazeRecv ref) (flush blazeRecv ref)
9797 state <- readIORef ref
@@ -101,11 +101,11 @@ addInsideHead sendInner flushInner streamingBody = do
101101 Just bs -> push state bs
102102 case state of
103103 Nothing -> return ()
104− Just (held, _) -> sendInner $ fromByteString held `mappend` fromByteString toInsert
104+ Just (held, _) -> sendInner $ byteString held `mappend` byteString toInsert
105105 where
106106 whole = "<head>"
107107
108− flush blazeRecv ref = inner blazeRecv ref Blaze.flush
108+ flush blazeRecv ref = inner blazeRecv ref Builder.flush
109109
110110 inner blazeRecv ref builder = do
111111 state0 <- readIORef ref
@@ -117,23 +117,23 @@ addInsideHead sendInner flushInner streamingBody = do
117117 else push state bs >>= loop
118118 loop state0
119119
120− push Nothing x = sendInner (fromByteString x) >> return Nothing
120+ push Nothing x = sendInner (byteString x) >> return Nothing
121121 push (Just (held, atFront)) x
122122 | atFront `S.isPrefixOf` x = do
123123 let y = S.drop (S.length atFront) x
124− sendInner $ fromByteString held
125− `mappend` fromByteString atFront
126− `mappend` fromByteString toInsert
127− `mappend` fromByteString y
124+ sendInner $ byteString held
125+ `mappend` byteString atFront
126+ `mappend` byteString toInsert
127+ `mappend` byteString y
128128 return Nothing
129129 | whole `S.isInfixOf` x = do
130130 let (before, rest) = S.breakSubstring whole x
131131 let after = S.drop (S.length whole) rest
132− sendInner $ fromByteString held
133− `mappend` fromByteString before
134− `mappend` fromByteString whole
135− `mappend` fromByteString toInsert
136− `mappend` fromByteString after
132+ sendInner $ byteString held
133+ `mappend` byteString before
134+ `mappend` byteString whole
135+ `mappend` byteString toInsert
136+ `mappend` byteString after
137137 return Nothing
138138 | x `S.isPrefixOf` atFront = do
139139 let held' = held `S.append` x
@@ -141,7 +141,7 @@ addInsideHead sendInner flushInner streamingBody = do
141141 return $ Just (held', atFront')
142142 | otherwise = do
143143 let (held', atFront', x') = getOverlap whole x
144− sendInner $ fromByteString held `mappend` fromByteString x'
144+ sendInner $ byteString held `mappend` byteString x'
145145 return $ Just (held', atFront')
146146
147147getOverlap :: S.ByteString -> S.ByteString -> (S.ByteString, S.ByteString, S.ByteString)
wai-handler-launch/wai-handler-launch.cabal+3−4
@@ -1,5 +1,5 @@
11Name: wai-handler-launch
2−Version: 3.0.2.3
2+Version: 3.0.2.4
33Synopsis: Launch a web app in the default browser.
44description: API docs and the README are available at <http://www.stackage.org/package/wai-handler-launch>.
55License: MIT
@@ -18,9 +18,8 @@ Library
1818 , warp >= 3.0 && < 3.3
1919 , http-types >= 0.7
2020 , transformers >= 0.2.2
21− , bytestring >= 0.9.1.4
22− , blaze-builder >= 0.2.1.4 && < 0.5
23− , streaming-commons
21+ , bytestring >= 0.10.4
22+ , streaming-commons >= 0.2
2423 , async
2524
2625 if os(windows)
wai-websockets/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.0.1.2
2+
3+* Drop unused dependency on blaze-builder
4+
15## 3.0.1.1
26
37* Doc improvement
wai-websockets/wai-websockets.cabal+1−3
@@ -1,5 +1,5 @@
11Name: wai-websockets
2−Version: 3.0.1.1
2+Version: 3.0.1.2
33Synopsis: Provide a bridge between WAI and the websockets package.
44License: MIT
55License-file: LICENSE
@@ -21,7 +21,6 @@ Library
2121 Build-Depends: base >= 3 && < 5
2222 , bytestring >= 0.9.1.4
2323 , wai >= 3.0 && < 3.3
24− , blaze-builder >= 0.2.1.4 && < 0.5
2524 , case-insensitive >= 0.2
2625 , network >= 2.2.1.5
2726 , transformers >= 0.2
@@ -41,7 +40,6 @@ Executable wai-websockets-example
4140 , wai-app-static
4241 , bytestring
4342 , case-insensitive
44− , blaze-builder
4543 , transformers
4644 , network
4745 , text
wai/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.2.1.2
2+
3+* Remove dependency on blaze-builder [#683](https://github.com/yesodweb/wai/pull/683)
4+
15## 3.2.1.1
26
37* Relax upper bound on bytestring-builder
wai/Network/Wai.hs+12−13
@@ -4,8 +4,8 @@ This module defines a generic web application interface. It is a common
44protocol between web servers and web applications.
55
66The overriding design principles here are performance and generality. To
7−address performance, this library is built on top of the conduit and
8−blaze-builder packages. The advantages of conduits over lazy IO have been
7+address performance, this library is built on top of the conduit package and
8+bytestring's Builder type. The advantages of conduits over lazy IO have been
99debated elsewhere and so will not be addressed here. However, helper functions
1010like 'responseLBS' allow you to continue using lazy IO if you so desire.
1111
@@ -83,8 +83,8 @@ 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, lazyByteString)
87+import Data.ByteString.Builder (byteString)
8888import Control.Monad (unless)
8989import qualified Data.ByteString as B
9090import qualified Data.ByteString.Lazy as L
@@ -92,7 +92,6 @@ import qualified Data.ByteString.Lazy.Internal as LI
9292import Data.ByteString.Lazy.Internal (defaultChunkSize)
9393import Data.ByteString.Lazy.Char8 ()
9494import Data.Function (fix)
95−import Data.Monoid (mempty)
9695import qualified Network.HTTP.Types as H
9796import Network.Socket (SockAddr (SockAddrInet))
9897import Network.Wai.Internal
@@ -120,13 +119,13 @@ responseFile = ResponseFile
120119--
121120-- A2. No. If the ByteStrings are small, then they will be copied into a larger
122121-- buffer, which should be a performance gain overall (less system calls). If
123−-- they are already large, then blaze-builder uses an InsertByteString
124−-- instruction to avoid copying.
122+-- they are already large, then an insert operation is used
123+-- to avoid copying.
125124--
126125-- Q3. Doesn't this prevent us from creating comet-style servers, since data
127126-- will be cached?
128127--
129−-- A3. You can force blaze-builder to output a ByteString before it is an
128+-- A3. You can force a Builder to output a ByteString before it is an
130129-- optimal size by sending a flush command.
131130responseBuilder :: H.Status -> H.ResponseHeaders -> Builder -> Response
132131responseBuilder = ResponseBuilder
@@ -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−5
@@ -4,10 +4,9 @@ import Test.Hspec
44import Test.Hspec.QuickCheck (prop)
55import Network.Wai
66import Data.IORef
7−import Data.Monoid
87import qualified Data.ByteString as S
98import qualified Data.ByteString.Lazy as L
10−import Blaze.ByteString.Builder (toByteString, Builder, fromWord8)
9+import Data.ByteString.Builder (Builder, toLazyByteString, word8)
1110import Control.Monad (forM_)
1211
1312spec :: Spec
@@ -23,17 +22,17 @@ spec = do
2322 flush :: IO ()
2423 flush = return ()
2524 streamingBody add flush
26− fmap toByteString $ readIORef builderRef
25+ fmap (L.toStrict . toLazyByteString) $ readIORef builderRef
2726 prop "responseLBS" $ \bytes -> do
2827 body <- getBody $ responseLBS undefined undefined $ L.pack bytes
2928 body `shouldBe` S.pack bytes
3029 prop "responseBuilder" $ \bytes -> do
3130 body <- getBody $ responseBuilder undefined undefined
32− $ mconcat $ map fromWord8 bytes
31+ $ mconcat $ map word8 bytes
3332 body `shouldBe` S.pack bytes
3433 prop "responseStream" $ \chunks -> do
3534 body <- getBody $ responseStream undefined undefined $ \sendChunk _ ->
36− forM_ chunks $ \chunk -> sendChunk $ mconcat $ map fromWord8 chunk
35+ forM_ chunks $ \chunk -> sendChunk $ mconcat $ map word8 chunk
3736 body `shouldBe` S.concat (map S.pack chunks)
3837 it "responseFile total" $ do
3938 let fp = "wai.cabal"
wai/wai.cabal+5−5
@@ -1,8 +1,9 @@
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.
5−description: API docs and the README are available at <http://www.stackage.org/package/wai>.
5+ .
6+ API docs and the README are available at <http://www.stackage.org/package/wai>.
67License: MIT
78License-file: LICENSE
89Author: Michael Snoyman
@@ -20,8 +21,7 @@ Source-repository head
2021
2122Library
2223 Build-Depends: base >= 4.8 && < 5
23− , bytestring >= 0.10
24− , blaze-builder >= 0.2.1.4 && < 0.5
24+ , bytestring >= 0.10.4
2525 , network >= 2.2.1.5
2626 , http-types >= 0.7
2727 , text >= 0.7
@@ -40,9 +40,9 @@ test-suite test
4040 build-depends: base >= 4.8 && < 5
4141 , wai
4242 , hspec
43− , blaze-builder
4443 , bytestring
4544 other-modules: Network.WaiSpec
45+ build-tool-depends: hspec-discover:hspec-discover
4646
4747source-repository head
4848 type: git
wai/webkit-sample/webkit-sample.hs+2−2
@@ -5,7 +5,7 @@ import Network.Wai.Handler.Webkit
55import Data.ByteString (ByteString)
66import qualified Data.ByteString.Lazy as L
77import Data.Enumerator (consume, Iteratee)
8−import Blaze.ByteString.Builder (fromLazyByteString)
8+import Data.ByteString.Builder (lazyByteString)
99
1010main :: IO ()
1111main = putStrLn "http://localhost:3000/" >> run "Webkit Sample" app
@@ -27,4 +27,4 @@ postResponse :: L.ByteString -> Iteratee ByteString IO Response
2727postResponse lbs = return $ ResponseBuilder
2828 status200
2929 [("Content-Type", "text/plain")]
30− (fromLazyByteString lbs)
30+ (lazyByteString lbs)
warp/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.2.18.2
2+
3+* Replace dependency on `blaze-builder` with `bsb-http-chunked`
4+
15## 3.2.18.1
26
37* Fix benchmark compilation [#681](https://github.com/yesodweb/wai/issues/681)
warp/Network/Wai/Handler/Warp/MultiMap.hs+1
@@ -15,6 +15,7 @@ import Data.IntMap.Strict (IntMap)
1515import qualified Data.IntMap.Strict as I
1616import qualified Data.List.NonEmpty as NE
1717import Data.Semigroup
18+import Prelude -- Silence redundant import warnings
1819
1920import Network.Wai.Handler.Warp.Imports hiding ((<>), union, empty, insert)
2021
warp/Network/Wai/Handler/Warp/Response.hs+1−1
@@ -13,7 +13,7 @@ module Network.Wai.Handler.Warp.Response (
1313 , addServer -- testing
1414 ) where
1515
16−import Blaze.ByteString.Builder.HTTP (chunkedTransferEncoding, chunkedTransferTerminator)
16+import Data.ByteString.Builder.HTTP.Chunked (chunkedTransferEncoding, chunkedTransferTerminator)
1717import qualified Control.Exception as E
1818import Data.Array ((!))
1919import qualified Data.ByteString as S
warp/warp.cabal+4−3
@@ -1,5 +1,5 @@
11Name: warp
2−Version: 3.2.18.1
2+Version: 3.2.18.2
33Synopsis: A fast, light-weight web server for WAI applications.
44License: MIT
55License-file: LICENSE
@@ -37,7 +37,7 @@ Library
3737 , array
3838 , async
3939 , auto-update >= 0.1.3 && < 0.2
40− , blaze-builder >= 0.4
40+ , bsb-http-chunked < 0.1
4141 , bytestring >= 0.9.1.4
4242 , case-insensitive >= 0.2
4343 , containers
@@ -181,7 +181,7 @@ Test-Suite spec
181181 Build-Depends: base >= 4.8 && < 5
182182 , array
183183 , auto-update
184− , blaze-builder >= 0.4
184+ , bsb-http-chunked < 0.1
185185 , bytestring >= 0.9.1.4
186186 , case-insensitive >= 0.2
187187 , ghc-prim
@@ -211,6 +211,7 @@ Test-Suite spec
211211 , word8
212212 , hashable
213213 , http-date
214+ -- Build-Tool-Depends: hspec-discover:hspec-discover
214215 if impl(ghc < 8)
215216 Build-Depends: semigroups
216217