on master help sign in
Conditional compilation to fix #479 (ping @kazu-yamamoto)
commit945632cfdcd1135a47dec761a62860d5ea122141 authorMichael Snoyman <michael@snoyman.com> dateMon 7 Dec 2015, 09:25 (11 years ago) parented7072d
1 file changed+15−2
warp/Network/Wai/Handler/Warp/File.hs+15−2
warp/Network/Wai/Handler/Warp/File.hs+15−2
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE OverloadedStrings #-}
23{-# LANGUAGE BangPatterns #-}
34
@@ -140,7 +141,13 @@ parseByteRanges bs1 = do
140141-- | @contentRangeHeader beg end total@ constructs a Content-Range 'H.Header'
141142-- for the range specified.
142143contentRangeHeader :: Integer -> Integer -> Integer -> H.Header
143−contentRangeHeader beg end total = (H.hContentRange, range)
144+contentRangeHeader beg end total = (
145+#if MIN_VERSION_http_types(0,9,0)
146+ H.hContentRange
147+#else
148+ "content-range"
149+#endif
150+ , range)
144151 where
145152 range = B.pack
146153 -- building with ShowS
@@ -157,7 +164,13 @@ addContentHeaders hs off len size = hs''
157164 where
158165 contentRange = contentRangeHeader off (off + len - 1) size
159166 lengthBS = L.toStrict $ B.toLazyByteString $ B.integerDec len
160− hs' = (H.hContentLength, lengthBS):(H.hAcceptRanges, "bytes"):hs
167+ hs' = (H.hContentLength, lengthBS):(
168+#if MIN_VERSION_http_types(0,9,0)
169+ H.hAcceptRanges
170+#else
171+ "accept-ranges"
172+#endif
173+ , "bytes"):hs
161174 hs'' = if len == size then hs' else contentRange:hs'
162175
163176-- |