http2-tls 0.5.4 → 0.5.5
raw patch · 4 files changed
+24/−34 lines, 4 filesdep ~network-rundep ~time-managerPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: network-run, time-manager
API changes (from Hackage documentation)
- Network.HTTP2.TLS.Client: instance GHC.Classes.Eq Network.HTTP2.TLS.Client.H2TlsTimeout
- Network.HTTP2.TLS.Client: instance GHC.Exception.Type.Exception Network.HTTP2.TLS.Client.H2TlsTimeout
- Network.HTTP2.TLS.Client: instance GHC.Show.Show Network.HTTP2.TLS.Client.H2TlsTimeout
Files
- Network/HTTP2/TLS/Client.hs +13/−25
- Network/HTTP2/TLS/Client/Settings.hs +3/−0
- Network/HTTP2/TLS/Config.hs +5/−6
- http2-tls.cabal +3/−3
Network/HTTP2/TLS/Client.hs view
@@ -61,7 +61,6 @@ import qualified Network.Run.TCP as TCP import Network.Socket import Network.TLS hiding (HostName)-import System.Timeout (timeout) import System.X509 (getSystemCertificateStore) import Network.HTTP2.TLS.Client.Settings@@ -70,9 +69,6 @@ import qualified Network.HTTP2.TLS.Server.Settings as Server import Network.HTTP2.TLS.Supported -data H2TlsTimeout = H2TlsTimeout deriving (Eq, Show)-instance E.Exception H2TlsTimeout- ---------------------------------------------------------------- -- Default API @@ -145,16 +141,15 @@ runWithConfig :: ClientConfig -> Settings -> HostName -> PortNumber -> Client a -> IO a runWithConfig cliconf settings serverName port client =- runTLSWithConfig cliconf settings serverName port "h2" $ \ctx mysa peersa -> do- let tout = settingsTimeout settings- recv- | tout > 0 = do- mx <- timeout (tout * 1000000) $ recvTLS ctx- case mx of- Nothing -> E.throwIO H2TlsTimeout- Just x -> return x- | otherwise = recvTLS ctx- run' cliconf' (sendTLS ctx) recv mysa peersa client+ runTLSWithConfig cliconf settings serverName port "h2" $ \ctx mysa peersa ->+ run'+ cliconf'+ (settingsTimeout settings)+ (sendTLS ctx)+ (recvTLS ctx)+ mysa+ peersa+ client where cliconf' :: ClientConfig cliconf' = cliconf{H2Client.scheme = "https"}@@ -167,15 +162,7 @@ mysa <- getSocketName sock peersa <- getPeerName sock recv <- mkRecvTCP Server.defaultSettings sock- let tout = settingsTimeout- recv'- | tout > 0 = do- mx <- timeout (tout * 1000000) recv- case mx of- Nothing -> E.throwIO H2TlsTimeout- Just x -> return x- | otherwise = recv- run' cliconf' (sendTCP sock) recv' mysa peersa client+ run' cliconf' settingsTimeout (sendTCP sock) recv mysa peersa client where cliconf' :: ClientConfig cliconf' = cliconf{H2Client.scheme = "http"}@@ -186,15 +173,16 @@ run' :: ClientConfig+ -> Int -> (ByteString -> IO ()) -> IO ByteString -> SockAddr -> SockAddr -> Client a -> IO a-run' cliconf send recv mysa peersa client =+run' cliconf tout send recv mysa peersa client = E.bracket- (allocConfigForClient send recv mysa peersa)+ (allocConfigForClient tout send recv mysa peersa) freeConfigForClient (\conf -> H2Client.run cliconf conf client)
Network/HTTP2/TLS/Client/Settings.hs view
@@ -126,6 +126,9 @@ , settingsTimeout :: Int -- ^ Timeout in seconds. Non-positive values mean no timeout. (H2 and H2c) --+ -- If nothing is received from the server for this long, the connection is+ -- closed with 'Network.HTTP2.Client.ConnectionIsTimeout'.+ -- -- >>> settingsTimeout defaultSettings -- 0 }
Network/HTTP2/TLS/Config.hs view
@@ -43,14 +43,15 @@ freeConfigForServer conf = free $ C.confWriteBuffer conf allocConfigForClient- :: (ByteString -> IO ()) -> IO ByteString -> SockAddr -> SockAddr -> IO Config-allocConfigForClient send recv mysa peersa = do+ :: Int -> (ByteString -> IO ()) -> IO ByteString -> SockAddr -> SockAddr -> IO Config+allocConfigForClient tout send recv mysa peersa = do let wbufsiz = 4096 -- fixme buf <- mallocBytes wbufsiz recvN <- makeRecvN "" recv -- A global manager does not exist. -- So, a timeout manager is created per connection.- mgr <- T.initialize 30000000 -- fixme+ -- The receiver of http2 uses it as an idle timeout.+ mgr <- T.initialize (tout * 1000000) let config = C.defaultConfig { C.confWriteBuffer = buf@@ -67,6 +68,4 @@ -- | Deallocating the resource of the simple configuration. freeConfigForClient :: Config -> IO ()-freeConfigForClient conf = do- free $ C.confWriteBuffer conf- T.killManager $ C.confTimeoutManager conf+freeConfigForClient conf = free $ C.confWriteBuffer conf
http2-tls.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: http2-tls-version: 0.5.4+version: 0.5.5 license: BSD3 license-file: LICENSE maintainer: Kazu Yamamoto <kazu@iij.ad.jp>@@ -44,9 +44,9 @@ http2 >=5.4 && <5.5, network >=3.1.4, network-control >=0.1 && <0.2,- network-run >=0.5 && <0.6,+ network-run >=0.6 && <0.7, recv >=0.1.0 && <0.2,- time-manager >=0.2 && <0.4,+ time-manager >=0.3 && <0.4, tls >=2.3.0 && <2.5, utf8-string >=1.0 && <1.1