on master help sign in
Add back http-types 0.8 support (#449)

Credit: @snoyberg

commitdb89a83482bdaaf58733d372de9bb255058ec104 authorKazu Yamamoto <kazu@iij.ad.jp> dateWed 14 Oct 2015, 09:05 (11 years ago) parenta027567
2 files changed+12−2
warp/Network/Wai/Handler/Warp/Response.hs+10 warp/warp.cabal+2−2
warp/Network/Wai/Handler/Warp/Response.hs+10
@@ -18,6 +18,10 @@ module Network.Wai.Handler.Warp.Response (
1818#define MIN_VERSION_base(x,y,z) 1
1919#endif
2020
21+#ifndef MIN_VERSION_http_types
22+#define MIN_VERSION_http_types(x,y,z) 1
23+#endif
24+
2125import Blaze.ByteString.Builder.HTTP (chunkedTransferEncoding, chunkedTransferTerminator)
2226#if __GLASGOW_HASKELL__ < 709
2327import Control.Applicative
@@ -46,7 +50,9 @@ import Data.Streaming.Blaze (newBlazeRecv, reuseBufferStrategy)
4650import Data.Version (showVersion)
4751import Data.Word8 (_cr, _lf)
4852import qualified Network.HTTP.Types as H
53+#if MIN_VERSION_http_types(0,9,0)
4954import qualified Network.HTTP.Types.Header as H
55+#endif
5056import Network.Wai
5157import Network.Wai.Handler.Warp.Buffer (toBuilderBuffer)
5258import qualified Network.Wai.Handler.Warp.Date as D
@@ -378,7 +384,11 @@ hasBody s = sc /= 204
378384----------------------------------------------------------------
379385
380386addTransferEncoding :: H.ResponseHeaders -> H.ResponseHeaders
387+#if MIN_VERSION_http_types(0,9,0)
381388addTransferEncoding hdrs = (H.hTransferEncoding, "chunked") : hdrs
389+#else
390+addTransferEncoding hdrs = ("transfer-encoding", "chunked") : hdrs
391+#endif
382392
383393addDate :: D.DateCache -> IndexedHeader -> H.ResponseHeaders -> IO H.ResponseHeaders
384394addDate dc rspidxhdr hdrs = case rspidxhdr ! idxDate of
warp/warp.cabal+2−2
@@ -40,7 +40,7 @@ Library
4040 , case-insensitive >= 0.2
4141 , containers
4242 , ghc-prim
43− , http-types >= 0.9
43+ , http-types >= 0.8.5
4444 , iproute >= 1.3.1
4545 , http2 >= 1.1
4646 , simple-sendfile >= 0.2.7 && < 0.3
@@ -139,7 +139,7 @@ Test-Suite spec
139139 , case-insensitive >= 0.2
140140 , ghc-prim
141141 , HTTP
142− , http-types >= 0.9
142+ , http-types >= 0.8.5
143143 , iproute >= 1.3.1
144144 , lifted-base >= 0.1
145145 , simple-sendfile >= 0.2.4 && < 0.3