5 module Network.HTTP.Lucu.ContentCoding
13 import Control.Applicative
14 import Data.Ascii (CIAscii, toCIAscii)
15 import Data.Attoparsec.Char8
18 import Network.HTTP.Lucu.Parser.Http
19 import Prelude.Unicode
24 , aeQValue ∷ !(Maybe Double)
28 instance Ord AcceptEncoding where
29 (AcceptEncoding c1 q1) `compare` (AcceptEncoding c2 q2)
32 | otherwise = compare c1 c2
37 acceptEncodingList ∷ Parser [AcceptEncoding]
38 acceptEncodingList = listOf accEnc
40 accEnc ∷ Parser AcceptEncoding
41 accEnc = do coding ← toCIAscii <$> token
46 return $ AcceptEncoding (normalizeCoding coding) qVal
48 normalizeCoding ∷ CIAscii → CIAscii
49 normalizeCoding coding
50 | coding ≡ "x-gzip" = "gzip"
51 | coding ≡ "x-compress" = "compress"
54 unnormalizeCoding ∷ CIAscii → CIAscii
55 unnormalizeCoding coding
56 | coding ≡ "gzip" = "x-gzip"
57 | coding ≡ "compress" = "x-compress"