6 {-# OPTIONS_HADDOCK prune #-}
8 -- |Manipulation of HTTP version string.
9 module Network.HTTP.Lucu.HttpVersion
15 import Control.Monad.Unicode
16 import Data.Attoparsec.Char8
17 import Network.HTTP.Lucu.HandleLike
18 import Prelude hiding (min)
20 -- |@'HttpVersion' major minor@ represents \"HTTP\/major.minor\".
22 = HttpVersion !Int !Int
25 instance Ord HttpVersion where
26 (HttpVersion majA minA) `compare` (HttpVersion majB minB)
33 httpVersionP ∷ Parser HttpVersion
34 httpVersionP = string "HTTP/"
36 choice [ string "1.1" ≫ return (HttpVersion 1 1)
37 , string "1.0" ≫ return (HttpVersion 1 0)
41 return $ HttpVersion major minor
44 hPutHttpVersion ∷ HandleLike h ⇒ h → HttpVersion → IO ()
48 HttpVersion 1 0 → hPutBS h "HTTP/1.0"
49 HttpVersion 1 1 → hPutBS h "HTTP/1.1"