]> gitweb @ CieloNegro.org - Lucu.git/blob - Network/HTTP/Lucu/Chunk.hs
New file: Parsable.hs
[Lucu.git] / Network / HTTP / Lucu / Chunk.hs
1 {-# LANGUAGE
2     UnicodeSyntax
3   #-}
4 module Network.HTTP.Lucu.Chunk
5     ( chunkHeader
6     , chunkFooter
7     , chunkTrailer
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 chunkHeader ∷ (Integral a, Bits a) ⇒ Parser a
17 {-# INLINEABLE chunkHeader #-}
18 chunkHeader = do len ← hexadecimal
19                  extension
20                  crlf
21                  return len
22     where
23       extension ∷ Parser ()
24       extension
25           = skipMany ( char ';' *>
26                        token    *>
27                        char '=' *>
28                        (token <|> quotedStr) )
29
30 chunkFooter ∷ Parser ()
31 chunkFooter = crlf
32
33 chunkTrailer ∷ Parser Headers
34 chunkTrailer = headers