]> gitweb @ CieloNegro.org - Lucu.git/blob - Network/HTTP/Lucu/Chunk.hs
Suppress unused-do-bind warnings which GHC 6.12.1 emits
[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 = many ( char ';' >>
24                          token    >>
25                          char '=' >>
26                          ( token <|> quotedStr )
27                        )
28                   >>
29                   return ()
30 {-# SPECIALIZE chunkHeaderP :: Parser Int #-}
31
32
33 chunkFooterP :: Parser ()
34 chunkFooterP = crlf >> return ()
35
36
37 chunkTrailerP :: Parser Headers
38 chunkTrailerP = headersP