on master help sign in
refactoring.
808ee2aKazu Yamamoto
warp/Network/Wai/Handler/Warp/Response.hs+16−6
@@ -2,6 +2,7 @@
2{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE TupleSections #-}
3{-# LANGUAGE TupleSections #-}
4{-# LANGUAGE RankNTypes #-}
4{-# LANGUAGE RankNTypes #-}
5+{-# LANGUAGE CPP #-}
5
6
6module Network.Wai.Handler.Warp.Response (
7module Network.Wai.Handler.Warp.Response (
7 sendResponse
8 sendResponse
@@ -24,7 +25,11 @@ import Data.Conduit.Blaze (unsafeBuilderToByteString)
24import Data.Function (on)
25import Data.Function (on)
25import Data.List (deleteBy)
26import Data.List (deleteBy)
26import Data.Maybe (isJust, listToMaybe)
27import Data.Maybe (isJust, listToMaybe)
28+#if MIN_VERSION_base(4,5,0)
29+import Data.Monoid ((<>))
30+#else
27import Data.Monoid (mappend)
31import Data.Monoid (mappend)
32+#endif
28import Data.Version (showVersion)
33import Data.Version (showVersion)
29import Network.HTTP.Attoparsec (parseByteRanges)
34import Network.HTTP.Attoparsec (parseByteRanges)
30import qualified Network.HTTP.Types as H
35import qualified Network.HTTP.Types as H
@@ -39,6 +44,11 @@ import Numeric (showInt)
39import qualified Paths_warp
44import qualified Paths_warp
40import qualified System.PosixCompat.Files as P
45import qualified System.PosixCompat.Files as P
41
46
47+#if !MIN_VERSION_base(4,5,0)
48+(<>) :: Monoid m => m -> m -> m
49+(<>) = mappend
50+#endif
51+
42-- $setup
52-- $setup
43-- >>> :set -XOverloadedStrings
53-- >>> :set -XOverloadedStrings
44
54
@@ -199,13 +209,13 @@ sendRsp conn ver s0 hs0 (RspFile path mPart mRange hook) = do
199
209
200----------------------------------------------------------------
210----------------------------------------------------------------
201
211
202−sendRsp conn ver s hs (RspBuilder b needsChunked) = do
212+sendRsp conn ver s hs (RspBuilder body needsChunked) = do
203 header <- composeHeaderBuilder ver s hs needsChunked
213 header <- composeHeaderBuilder ver s hs needsChunked
204− let body
214+ let hdrBdy
205− | needsChunked = header `mappend` chunkedTransferEncoding b
215+ | needsChunked = header <> chunkedTransferEncoding body
206− `mappend` chunkedTransferTerminator
216+ <> chunkedTransferTerminator
207− | otherwise = header `mappend` b
217+ | otherwise = header <> body
208− flip toByteStringIO body $ \bs -> connSendAll conn bs
218+ flip toByteStringIO hdrBdy $ connSendAll conn
209
219
210----------------------------------------------------------------
220----------------------------------------------------------------
211
221