on master help sign in
cleanup parseFirst
8dd8ecaMatt Brown
Network/Wai/Handler/Warp.hs+9−12
@@ -243,18 +243,15 @@ takeUntil c bs =
243
243
244parseFirst :: ByteString
244parseFirst :: ByteString
245 -> E.Iteratee S.ByteString IO (ByteString, ByteString, ByteString, HttpVersion)
245 -> E.Iteratee S.ByteString IO (ByteString, ByteString, ByteString, HttpVersion)
246−parseFirst s = do
246+parseFirst s =
247− let pieces = S.split 32 s -- ' '
247+ case S.split 32 s of -- ' '
248− (method, query, http') <-
248+ [method, query, http'] -> do
249− case pieces of
250− [x, y, z] -> return (x, y, z)
251− _ -> E.throwError $ BadFirstLine $ B.unpack s
252− let (hfirst, hsecond) = B.splitAt 5 http'
249+ let (hfirst, hsecond) = B.splitAt 5 http'
253− if (hfirst == "HTTP/")
250+ if hfirst == "HTTP/"
254− then
255− let (rpath, qstring) = S.breakByte 63 query -- '?'
251+ then let (rpath, qstring) = S.breakByte 63 query -- '?'
256− in return (method, rpath, qstring, hsecond)
252+ in return (method, rpath, qstring, hsecond)
257− else E.throwError NonHttp
253+ else E.throwError NonHttp
254+ _ -> E.throwError $ BadFirstLine $ B.unpack s
258{-# INLINE parseFirst #-} -- FIXME is this inline necessary? the function is only called from one place and not exported
255{-# INLINE parseFirst #-} -- FIXME is this inline necessary? the function is only called from one place and not exported
259
256
260httpBuilder, spaceBuilder, newlineBuilder, transferEncodingBuilder
257httpBuilder, spaceBuilder, newlineBuilder, transferEncodingBuilder