warp 3.0.9 → 3.0.9.1
raw patch · 4 files changed
+47/−8 lines, 4 filesdep ~arraydep ~basedep ~blaze-builder
Dependency ranges changed: array, base, blaze-builder, bytestring, case-insensitive, hashable, http-date, http-types, iproute, network, old-locale, streaming-commons, text, time, unix, unix-compat, void
Files
- ChangeLog.md +4/−0
- Network/Wai/Handler/Warp/Buffer.hs +1/−1
- Network/Wai/Handler/Warp/IO.hs +37/−2
- warp.cabal +5/−5
ChangeLog.md view
@@ -1,3 +1,7 @@+## 3.0.9.1++Add support for blaze-builder 0.4+ ## 3.0.9 * Add runEnv: like run but uses $PORT [#334](https://github.com/yesodweb/wai/pull/334)
Network/Wai/Handler/Warp/Buffer.hs view
@@ -1,6 +1,6 @@ module Network.Wai.Handler.Warp.Buffer where -import qualified Blaze.ByteString.Builder.Internal.Buffer as B (Buffer (..))+import qualified Data.Streaming.ByteString.Builder.Buffer as B (Buffer (..)) import Data.Word (Word8) import Foreign.ForeignPtr (newForeignPtr_) import Foreign.Marshal.Alloc (mallocBytes, free)
Network/Wai/Handler/Warp/IO.hs view
@@ -1,14 +1,47 @@ {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-} module Network.Wai.Handler.Warp.IO where -import Blaze.ByteString.Builder.Internal.Types (Builder(..), BuildSignal(..), BufRange(..), runBuildStep, buildStep) import Data.ByteString.Internal (ByteString(..)) import Foreign.ForeignPtr (newForeignPtr_)-import Foreign.Ptr (plusPtr, minusPtr) import Network.Wai.Handler.Warp.Buffer +-- Support for doctest, where cabal macros are not available+#ifndef MIN_VERSION_blaze_builder+#define MIN_VERSION_blaze_builder(x, y, z) 1+#endif++#if MIN_VERSION_blaze_builder(0,4,0)++import Blaze.ByteString.Builder (Builder)+import Data.ByteString.Builder.Extra (runBuilder, Next(Done, More, Chunk))+ toBufIOWith :: Buffer -> BufSize -> (ByteString -> IO ()) -> Builder -> IO ()+toBufIOWith buf !size io builder = loop firstWriter+ where+ firstWriter = runBuilder builder+ runIO len = toBS buf len >>= io+ loop writer = do+ (len, signal) <- writer buf size+ case signal of+ Done -> runIO len+ More minSize next+ | size < minSize -> error "toBufIOWith: BufferFull: minSize"+ | otherwise -> do+ runIO len+ loop next+ Chunk bs next -> do+ runIO len+ io bs+ loop next++#else /* !MIN_VERSION_blaze_builder(0,4,0) */++import Blaze.ByteString.Builder.Internal.Types (Builder(..), BuildSignal(..), BufRange(..), runBuildStep, buildStep)+import Foreign.Ptr (plusPtr, minusPtr)++toBufIOWith :: Buffer -> BufSize -> (ByteString -> IO ()) -> Builder -> IO () toBufIOWith buf !size io (Builder build) = loop firstStep where firstStep = build (buildStep finalStep)@@ -28,6 +61,8 @@ runIO ptr io bs loop next++#endif /* !MIN_VERSION_blaze_builder(0,4,0) */ toBS :: Buffer -> Int -> IO ByteString toBS ptr siz = do
warp.cabal view
@@ -1,5 +1,5 @@ Name: warp-Version: 3.0.9+Version: 3.0.9.1 Synopsis: A fast, light-weight web server for WAI applications. License: MIT License-file: LICENSE@@ -30,7 +30,7 @@ Build-Depends: base >= 3 && < 5 , array , auto-update >= 0.1.1 && < 0.2- , blaze-builder >= 0.3.3 && < 0.4+ , blaze-builder >= 0.3.3 && < 0.5 , bytestring >= 0.9.1.4 , case-insensitive >= 0.2 , ghc-prim@@ -41,7 +41,7 @@ , void , wai >= 3.0 && < 3.1 , text- , streaming-commons >= 0.1.2+ , streaming-commons >= 0.1.10 if flag(network-bytestring) Build-Depends: network >= 2.2.1.5 && < 2.2.3 , network-bytestring >= 0.1.3 && < 0.1.4@@ -112,7 +112,7 @@ Build-Depends: base >= 4 && < 5 , array , auto-update- , blaze-builder >= 0.3.3 && < 0.4+ , blaze-builder >= 0.3.3 && < 0.5 , bytestring >= 0.9.1.4 , case-insensitive >= 0.2 , ghc-prim@@ -132,7 +132,7 @@ , time , old-locale , text- , streaming-commons >= 0.1.1+ , streaming-commons >= 0.1.10 , async if (os(linux) || os(freebsd) || os(darwin)) && flag(allow-sendfilefd)