X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FHandleLike.hs;h=c4a4c62fc23298558b6ee48a0cc906f8191232f4;hp=f38fa5b88057090f3014289790b0674a6a0dc07c;hb=1f3ac4a;hpb=72a3e24a952616e32845eeb4fc05048e841c91a2 diff --git a/Network/HTTP/Lucu/HandleLike.hs b/Network/HTTP/Lucu/HandleLike.hs index f38fa5b..c4a4c62 100644 --- a/Network/HTTP/Lucu/HandleLike.hs +++ b/Network/HTTP/Lucu/HandleLike.hs @@ -1,5 +1,6 @@ {-# LANGUAGE - UnicodeSyntax + DoAndIfThenElse + , UnicodeSyntax #-} module Network.HTTP.Lucu.HandleLike ( HandleLike(..) @@ -17,7 +18,6 @@ import qualified System.IO as I 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 () @@ -28,10 +28,8 @@ class HandleLike h where hFlush ∷ h → IO () hClose ∷ h → IO () - instance HandleLike I.Handle where hGetLBS = L.hGetContents - hPutLBS = L.hPut hGetBS = B.hGet hPutBS = B.hPut @@ -39,23 +37,21 @@ instance HandleLike I.Handle where 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 #-}