]> gitweb @ CieloNegro.org - Lucu.git/blob - Network/HTTP/Lucu/Chunk.hs
a419464eefbc322989141167b8d4cbf8bcc741db
[Lucu.git] / Network / HTTP / Lucu / Chunk.hs
1 {-# LANGUAGE
2     UnicodeSyntax
3   #-}
4 module Network.HTTP.Lucu.Chunk
5     ( chunkHeaderP  -- Num a => Parser a
6     , chunkFooterP  -- Parser ()
7     , chunkTrailerP -- Parser Headers
8     )
9     where
10 import Control.Applicative
11 import Data.Attoparsec.Char8
12 import Data.Bits
13 import Network.HTTP.Lucu.Headers
14 import Network.HTTP.Lucu.Parser.Http
15
16 chunkHeaderP ∷ (Integral a, Bits a) ⇒ Parser a
17 {-# INLINEABLE chunkHeaderP #-}
18 chunkHeaderP = do len ← hexadecimal
19                   extension
20                   crlf
21                   return len
22     where
23       extension ∷ Parser ()
24       extension = skipMany $
25                   do _ ← char ';'
26                      _ ← token
27                      _ ← char '='
28                      _ ← token <|> quotedStr
29                      return ()
30
31 chunkFooterP ∷ Parser ()
32 chunkFooterP = crlf
33
34 chunkTrailerP ∷ Parser Headers
35 chunkTrailerP = headersP