on master help sign in
if then else.
commite4d84292207777408a76945c4bfc0db831016b5d authorKazu Yamamoto <kazu@iij.ad.jp> dateTue 14 Aug 2012, 16:59 (14 years ago) parent5f27e17
2 files changed+15−18
warp/Network/Wai/Handler/Warp/Request.hs+8−10 warp/Network/Wai/Handler/Warp/Response.hs+7−8
warp/Network/Wai/Handler/Warp/Request.hs+8−10
@@ -199,16 +199,14 @@ takeHeaders =
199199 nl <- S.elemIndex 10 bs
200200 -- check if there are two more bytes in the bs
201201 -- if so, see if the second of those is a horizontal space
202− if bsLen > nl + 1
203− then
204− let c = S.index bs (nl + 1)
205− in Just (nl, c == 32 || c == 9)
206− else Just (nl, False)
202+ if bsLen > nl + 1 then
203+ let c = S.index bs (nl + 1)
204+ in Just (nl, c == 32 || c == 9)
205+ else
206+ Just (nl, False)
207207
208208{-# INLINE checkCR #-}
209209checkCR :: ByteString -> Int -> Int
210−checkCR bs pos =
211− let !p = pos - 1
212− in if '\r' == B.index bs p
213− then p
214− else pos
210+checkCR bs pos = if '\r' == B.index bs p then p else pos
211+ where
212+ !p = pos - 1
warp/Network/Wai/Handler/Warp/Response.hs+7−8
@@ -81,11 +81,12 @@ sendResponse th req conn r = sendResponse' r
8181 where
8282 headers' = headers version s hs
8383 needsChunked' = needsChunked hs
84− body = if needsChunked'
85− then headers' needsChunked'
86− `mappend` chunkedTransferEncoding b
87− `mappend` chunkedTransferTerminator
88− else headers' False `mappend` b
84+ body = if needsChunked' then
85+ headers' needsChunked'
86+ `mappend` chunkedTransferEncoding b
87+ `mappend` chunkedTransferTerminator
88+ else
89+ headers' False `mappend` b
8990
9091 sendResponse' (ResponseSource s hs bodyFlush)
9192 | hasBody s req = do
@@ -150,9 +151,7 @@ headers !httpversion !status !responseHeaders !isChunked' = {-# SCC "headers" #-
150151 `mappend` copyByteString (H.statusMessage status)
151152 `mappend` newlineBuilder
152153 !start' = foldl' responseHeaderToBuilder start (serverHeader responseHeaders)
153− !end = if isChunked'
154− then transferEncodingBuilder
155− else newlineBuilder
154+ !end = if isChunked' then transferEncodingBuilder else newlineBuilder
156155 in start' `mappend` end
157156
158157responseHeaderToBuilder :: Builder -> H.Header -> Builder