{-# LANGUAGE
- UnicodeSyntax
+ DoAndIfThenElse
+ , UnicodeSyntax
#-}
module Network.HTTP.Lucu.HandleLike
( HandleLike(..)
class HandleLike h where
hGetLBS ∷ h → IO L.ByteString
- hPutLBS ∷ h → L.ByteString → IO ()
hGetBS ∷ h → Int → IO B.ByteString
hPutBS ∷ h → B.ByteString → IO ()
hFlush ∷ h → IO ()
hClose ∷ h → IO ()
-
instance HandleLike I.Handle where
hGetLBS = L.hGetContents
- hPutLBS = L.hPut
hGetBS = B.hGet
hPutBS = B.hPut
hFlush = I.hFlush
hClose = I.hClose
-
instance HandleLike SSL.SSL where
- hGetLBS = SSL.lazyRead
- hPutLBS = SSL.lazyWrite
+ hGetLBS = SSL.lazyRead
- hGetBS = SSL.read
- hPutBS = SSL.write
+ hGetBS = SSL.read
+ hPutBS = SSL.write
hGetPeerCert s
= do isValid <- SSL.getVerifyResult s
if isValid then
SSL.getPeerCertificate s
- else
+ else
return Nothing
- hFlush _ = return () -- No need to do anything.
- hClose s = SSL.shutdown s SSL.Bidirectional
+ hFlush _ = return () -- No need to do anything.
+ hClose s = SSL.shutdown s SSL.Bidirectional
hPutBuilder ∷ HandleLike h ⇒ h → Builder → IO ()
{-# INLINE hPutBuilder #-}