3 | import Data.ByteString
5 | import Data.SortedMap
16 | content : ByteString
20 | FormData = List FDPart
28 | part : ByteString -> Maybe FDPart
29 | part bs = Prelude.do
30 | guard (not $
isPrefixOf "--" bs || size bs == 0)
31 | let (_,r1) := breakDropAtSubstring crlf bs
32 | n := substringIndex crlf2.repr r1.repr
33 | (rh,r2) <- splitAt (n.fst + crlf2.size) r1
34 | h <- parseHeadersMay rh
35 | cd <- contentDisposition h
36 | nm <- parameter "name" cd.params
40 | multipart : (sep : ByteString) -> ByteString -> FormData
42 | let sepBS := "--" <+> sep
43 | in mapMaybe part (splitAtSubstring sepBS bs)