on master help sign in
refactoring.
commit227e037d2cd1c7aa29318cfd398453bfa943f2f6 authorKazu Yamamoto <kazu@iij.ad.jp> dateThu 3 Mar 2016, 14:27 (11 years ago) parentfecb6e9
1 file changed+19−18
warp/Network/Wai/Handler/Warp/File.hs+19−18
warp/Network/Wai/Handler/Warp/File.hs+19−18
@@ -40,17 +40,17 @@ conditionalRequest :: I.FileInfo
4040 -> RspFileInfo
4141conditionalRequest finfo hs0 reqidx = case condition of
4242 nobody@(WithoutBody _) -> nobody
43− WithBody s _ off len -> let hs = (H.hLastModified,date) :
44− addContentHeaders hs0 off len size
43+ WithBody s _ off len -> let !hs = (H.hLastModified,date) :
44+ addContentHeaders hs0 off len size
4545 in WithBody s hs off len
4646 where
47− mtime = I.fileInfoTime finfo
48− size = I.fileInfoSize finfo
49− date = I.fileInfoDate finfo
50− mcondition = ifmodified reqidx size mtime
51− <|> ifunmodified reqidx size mtime
52− <|> ifrange reqidx size mtime
53− condition = fromMaybe (unconditional reqidx size) mcondition
47+ !mtime = I.fileInfoTime finfo
48+ !size = I.fileInfoSize finfo
49+ !date = I.fileInfoDate finfo
50+ !mcondition = ifmodified reqidx size mtime
51+ <|> ifunmodified reqidx size mtime
52+ <|> ifrange reqidx size mtime
53+ !condition = fromMaybe (unconditional reqidx size) mcondition
5454
5555----------------------------------------------------------------
5656
@@ -140,16 +140,17 @@ parseByteRanges bs1 = do
140140
141141----------------------------------------------------------------
142142
143−-- | @contentRangeHeader beg end total@ constructs a Content-Range 'H.Header'
144−-- for the range specified.
145−contentRangeHeader :: Integer -> Integer -> Integer -> H.Header
146−contentRangeHeader beg end total = (
143+contentRange :: H.HeaderName
147144#if MIN_VERSION_http_types(0,9,0)
148− H.hContentRange
145+contentRange = H.hContentRange
149146#else
150− "Content-Range"
147+contentRange = "Content-Range"
151148#endif
152− , range)
149+
150+-- | @contentRangeHeader beg end total@ constructs a Content-Range 'H.Header'
151+-- for the range specified.
152+contentRangeHeader :: Integer -> Integer -> Integer -> H.Header
153+contentRangeHeader beg end total = (contentRange, range)
153154 where
154155 range = B.pack
155156 -- building with ShowS
@@ -171,8 +172,8 @@ acceptRange = "Accept-Ranges"
171172addContentHeaders :: H.ResponseHeaders -> Integer -> Integer -> Integer -> H.ResponseHeaders
172173addContentHeaders hs off len size
173174 | len == size = hs'
174− | otherwise = let !contentRange = contentRangeHeader off (off + len - 1) size
175− in contentRange:hs'
175+ | otherwise = let !ctrng = contentRangeHeader off (off + len - 1) size
176+ in ctrng:hs'
176177 where
177178 !lengthBS = B.pack $ show len -- fixme
178179 !hs' = (H.hContentLength, lengthBS) : (acceptRange,"bytes") : hs