@@ -12,7 +12,6 @@ module Network.Wai.Handler.Warp.Response (
1212 ) where
1313
1414import Blaze.ByteString.Builder (fromByteString, Builder, flush)
15−import Blaze.ByteString.Builder.Internal (defaultBufferSize)
1615import Blaze.ByteString.Builder.HTTP (chunkedTransferEncoding, chunkedTransferTerminator)
1716import Control.Applicative
1817import Control.Exception
@@ -25,7 +24,7 @@ import qualified Data.ByteString.Char8 as B (pack)
2524import qualified Data.CaseInsensitive as CI
2625import Data.Conduit
2726import qualified Data.Conduit.List as CL
28−import Data.Conduit.Blaze (builderToByteStringWith, allocBuffer, reuseBufferStrategy)
27+import Data.Conduit.Blaze (unsafeBuilderToByteString)
2928import Data.Function (on)
3029import Data.List (deleteBy)
3130import Data.Maybe (isJust, listToMaybe)
@@ -38,6 +37,7 @@ import Data.Version (showVersion)
3837import qualified Network.HTTP.Types as H
3938import Network.Wai
4039import qualified Network.Wai.Handler.Warp.Date as D
40+import Network.Wai.Handler.Warp.Buffer (toBlazeBuffer)
4141import Network.Wai.Handler.Warp.Header
4242import Network.Wai.Handler.Warp.IO (toBufIOWith)
4343import Network.Wai.Handler.Warp.ResponseHeader
@@ -237,7 +237,7 @@ sendRsp conn ver s hs restore (RspBuilder body needsChunked) = restore $ do
237237 | needsChunked = header <> chunkedTransferEncoding body
238238 <> chunkedTransferTerminator
239239 | otherwise = header <> body
240− buffer = connBuffer conn
240+ buffer = connWriteBuffer conn
241241 size = connBufferSize conn
242242 toBufIOWith buffer size (connSendAll conn) hdrBdy
243243
@@ -246,9 +246,9 @@ sendRsp conn ver s hs restore (RspBuilder body needsChunked) = restore $ do
246246sendRsp conn ver s hs restore (RspSource withBodyFlush needsChunked th) =
247247 withBodyFlush $ \bodyFlush -> restore $ do
248248 header <- composeHeaderBuilder ver s hs needsChunked
249+ buffer <- toBlazeBuffer (connWriteBuffer conn) (connBufferSize conn)
249250 let src = yield header >> cbody bodyFlush
250− strategy = reuseBufferStrategy $ allocBuffer defaultBufferSize
251− src $$ builderToByteStringWith strategy =$ connSink conn th
251+ src $$ unsafeBuilderToByteString (return buffer) =$ connSink conn th
252252 where
253253 cbody bodyFlush = if needsChunked then body $= chunk else body
254254 where