]> gitweb @ CieloNegro.org - Lucu.git/blob - Network/HTTP/Lucu/Chunk.hs
Moved hidden modules from Exposed-Modules to Other-Modules.
[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 {-# SPECIALIZE chunkHeaderP :: Parser Int #-}
29
30
31 chunkFooterP :: Parser ()
32 chunkFooterP = crlf >> return ()
33
34
35 chunkTrailerP :: Parser Headers
36 chunkTrailerP = headersP