@@ -12,6 +12,7 @@ module Network.Wai.Handler.Warp.Response (
1212 ) where
1313
1414import Blaze.ByteString.Builder (fromByteString, Builder, flush)
15+import Blaze.ByteString.Builder.Internal (defaultBufferSize)
1516import Blaze.ByteString.Builder.HTTP (chunkedTransferEncoding, chunkedTransferTerminator)
1617import Control.Applicative
1718import Control.Exception
@@ -24,7 +25,7 @@ import qualified Data.ByteString.Char8 as B (pack)
2425import qualified Data.CaseInsensitive as CI
2526import Data.Conduit
2627import qualified Data.Conduit.List as CL
27−import Data.Conduit.Blaze (unsafeBuilderToByteString)
28+import Data.Conduit.Blaze (builderToByteStringWith, allocBuffer, reuseBufferStrategy)
2829import Data.Function (on)
2930import Data.List (deleteBy)
3031import Data.Maybe (isJust, listToMaybe)
@@ -38,7 +39,6 @@ import qualified Network.HTTP.Types as H
3839import Network.Wai
3940import qualified Network.Wai.Handler.Warp.Date as D
4041import Network.Wai.Handler.Warp.Header
41−import Network.Wai.Handler.Warp.Buffer (toBlazeBuffer)
4242import Network.Wai.Handler.Warp.IO (toBufIOWith)
4343import Network.Wai.Handler.Warp.ResponseHeader
4444import Network.Wai.Handler.Warp.RequestHeader (parseByteRanges)
@@ -247,8 +247,8 @@ sendRsp conn ver s hs restore (RspSource withBodyFlush needsChunked th) =
247247 withBodyFlush $ \bodyFlush -> restore $ do
248248 header <- composeHeaderBuilder ver s hs needsChunked
249249 let src = yield header >> cbody bodyFlush
250− buffer <- toBlazeBuffer (connBuffer conn) (connBufferSize conn)
251− src $$ unsafeBuilderToByteString (return buffer) =$ connSink conn th
250+ strategy = reuseBufferStrategy $ allocBuffer defaultBufferSize
251+ src $$ builderToByteStringWith strategy =$ connSink conn th
252252 where
253253 cbody bodyFlush = if needsChunked then body $= chunk else body
254254 where