authCredentialP ∷ Parser AuthCredential
authCredentialP
- = try $
- do _ ← string "Basic"
+ = do _ ← string "Basic"
skipMany1 lws
b64 ← takeWhile1 base64
case C8.break (≡ ':') (B64.decodeLenient b64) of
weakETag = ETag True
eTagP ∷ Parser ETag
-eTagP = try $
- do isWeak ← option False (string "W/" ≫ return True)
+eTagP = do isWeak ← option False (string "W/" ≫ return True)
str ← quotedStr
return $ ETag isWeak str
-}
headersP ∷ Parser Headers
{-# INLINEABLE headersP #-}
-headersP = do xs ← P.many header
+headersP = do xs ← P.many $ try header
crlf
return $ toHeaders xs
where
header ∷ Parser (CIAscii, Ascii)
- header = try $
- do name ← A.toCIAscii <$> token
+ header = do name ← A.toCIAscii <$> token
_ ← char ':'
skipMany lws
- values ← sepBy content lws
- skipMany lws
+ values ← sepBy content (try lws)
+ skipMany (try lws)
crlf
return (name, joinValues values)
multipartFormP ∷ Ascii → Parser [(Text, FormData)]
multipartFormP boundary
- = try $
- do parts ← many (partP boundary)
+ = do parts ← many $ try $ partP boundary
_ ← string "--"
_ ← string $ A.toByteString boundary
_ ← string "--"
partP ∷ Ascii → Parser Part
partP boundary
- = try $
- do _ ← string "--"
+ = do _ ← string "--"
_ ← string $ A.toByteString boundary
crlf
hs ← headersP
bodyP ∷ Ascii → Parser LS.ByteString
bodyP boundary
- = try $
- do body ← manyCharsTill anyChar $
+ = do body ← manyCharsTill anyChar $
try $
do crlf
_ ← string "--"
listOf ∷ Parser a → Parser [a]
{-# INLINEABLE listOf #-}
listOf p
- = try $
- do skipMany lws
+ = do skipMany lws
sepBy p $ do skipMany lws
_ <- char ','
skipMany lws
-- |HTTP LWS: crlf? (sp | ht)+
lws ∷ Parser ()
{-# INLINEABLE lws #-}
-lws = try $
- do option () crlf
- _ ← satisfy isSPHT
- skipWhile isSPHT
+lws = do option () crlf
+ _ ← takeWhile1 isSPHT
+ return ()
-- |Returns 'True' for SP and HT.
isSPHT ∷ Char → Bool
]
uriP ∷ Parser URI
-uriP = try $
- do bs ← takeWhile1 (\c → (¬) (isCtl c ∨ c ≡ '\x20'))
+uriP = do bs ← takeWhile1 (\c → (¬) (isCtl c ∨ c ≡ '\x20'))
let str = C8.unpack bs
case parseURIReference str of
Nothing -> fail ("Unparsable URI: " ⧺ str)