]> gitweb @ CieloNegro.org - Lucu.git/blob - Network/HTTP/Lucu/Chunk.hs
Chunked input now works!
[Lucu.git] / Network / HTTP / Lucu / Chunk.hs
1 module Network.HTTP.Lucu.Chunk
2     ( chunkHeaderP  -- Num a => Parser a
3     , chunkFooterP  -- Parser ()
4     , chunkTrailerP -- Parser Headers
5     )
6     where
7
8 import           Network.HTTP.Lucu.Headers
9 import           Network.HTTP.Lucu.Parser
10 import           Network.HTTP.Lucu.Parser.Http
11 import           Numeric
12
13
14 chunkHeaderP :: Num a => Parser a
15 chunkHeaderP = do hexLen <- many1 hexDigit
16                   extension
17                   crlf
18
19                   let [(len, _)] = readHex hexLen
20                   return len
21     where
22       extension :: Parser ()
23       extension = do many $ do char ';'
24                                token
25                                char '='
26                                token <|> quotedStr
27                      return ()
28
29
30 chunkFooterP :: Parser ()
31 chunkFooterP = crlf >> return ()
32
33
34 chunkTrailerP :: Parser Headers
35 chunkTrailerP = headersP