4 module Network.HTTP.Lucu.HandleLike
8 import qualified Data.ByteString as B
9 import qualified Data.ByteString.Lazy.Char8 as L
10 import qualified OpenSSL.Session as SSL
12 import qualified System.IO as I
14 class HandleLike h where
15 hGetLBS ∷ h → IO L.ByteString
16 hPutLBS ∷ h → L.ByteString → IO ()
18 hGetBS ∷ h → Int → IO B.ByteString
19 hPutBS ∷ h → B.ByteString → IO ()
21 hGetPeerCert ∷ h → IO (Maybe X509)
22 hGetPeerCert = const $ return Nothing
28 instance HandleLike I.Handle where
29 hGetLBS = L.hGetContents
39 instance HandleLike SSL.SSL where
40 hGetLBS = SSL.lazyRead
41 hPutLBS = SSL.lazyWrite
47 = do isValid <- SSL.getVerifyResult s
49 SSL.getPeerCertificate s
53 hFlush _ = return () -- unneeded
54 hClose s = SSL.shutdown s SSL.Bidirectional