packages feed

http2 5.3.4 → 5.3.5

raw patch · 35 files changed

+112/−100 lines, 35 filesdep −unliftiodep ~http-semanticsPVP ok

version bump matches the API change (PVP)

Dependencies removed: unliftio

Dependency ranges changed: http-semantics

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,13 @@ # ChangeLog for http2 +## 5.3.5++* Using `http-semantics` v0.3.+* Deprecating `numberOfWorkers`.+* Removing `unliftio`.+* Avoid `undefined` in client.+  [#146](https://github.com/kazu-yamamoto/http2/pull/146)+ ## 5.3.4  * Support stream cancellation
Network/HPACK/HeaderBlock/Decode.hs view
@@ -14,6 +14,7 @@     decodeSimple, -- testing ) where +import Control.Exception (catch, throwIO) import Data.Array.Base (unsafeRead, unsafeWrite) import qualified Data.Array.IO as IOA import qualified Data.Array.Unsafe as Unsafe@@ -22,7 +23,6 @@ import Data.Char (isUpper) import Network.ByteOrder import Network.HTTP.Semantics-import UnliftIO.Exception (catch, throwIO)  import Imports hiding (empty) import Network.HPACK.Builder
Network/HPACK/HeaderBlock/Encode.hs view
@@ -8,6 +8,8 @@     encodeS, ) where +import Control.Exception (bracket, throwIO)+import qualified Control.Exception as E import qualified Data.ByteString as BS import Data.ByteString.Internal (create) import Data.IORef@@ -16,8 +18,6 @@ import Foreign.Ptr (minusPtr) import Network.ByteOrder import Network.HTTP.Semantics-import UnliftIO.Exception (bracket, throwIO)-import qualified UnliftIO.Exception as E  import Imports import Network.HPACK.HeaderBlock.Integer
Network/HPACK/Huffman/Decode.hs view
@@ -9,11 +9,11 @@     GCBuffer, ) where +import Control.Exception (throwIO) import Data.Array (Array, listArray) import Data.Array.Base (unsafeAt) import qualified Data.ByteString as BS import Network.ByteOrder-import UnliftIO.Exception (throwIO)  import Imports import Network.HPACK.Huffman.Bit
Network/HPACK/Huffman/Encode.hs view
@@ -6,6 +6,7 @@     encodeHuffman, ) where +import Control.Exception (throwIO) import Data.Array.Base (unsafeAt) import Data.Array.IArray (listArray) import Data.Array.Unboxed (UArray)@@ -13,7 +14,6 @@ import Foreign.Ptr (minusPtr, plusPtr) import Foreign.Storable (poke) import Network.ByteOrder hiding (copy)-import UnliftIO.Exception (throwIO)  import Imports import Network.HPACK.Huffman.Params (idxEos)
Network/HPACK/Table/Dynamic.hs view
@@ -24,11 +24,11 @@     getRevIndex, ) where +import Control.Exception (throwIO) import Data.Array.Base (unsafeRead, unsafeWrite) import Data.Array.IO (IOArray, newArray) import qualified Data.ByteString.Char8 as BS import Data.IORef-import UnliftIO.Exception (throwIO)  import Imports import Network.HPACK.Huffman
Network/HPACK/Table/RevIndex.hs view
@@ -17,6 +17,8 @@ import Data.Array.Base (unsafeAt) import Data.Function (on) import Data.IORef+import Data.List.NonEmpty (NonEmpty (..))+import qualified Data.List.NonEmpty as NE import Data.Map.Strict (Map) import qualified Data.Map.Strict as M import Network.HTTP.Semantics@@ -64,15 +66,15 @@     toEnt (k, xs) = (tokenIx $ toToken $ foldedCase k, m)       where         m = case xs of-            [] -> error "staticRevIndex"-            [("", i)] -> StaticEntry i Nothing-            (_, i) : _ ->-                let vs = M.fromList xs+            ("", i) :| [] -> StaticEntry i Nothing+            (_, i) :| _ ->+                let vs = M.fromList $ NE.toList xs                  in StaticEntry i (Just vs)-    zs = map extract $ groupBy ((==) `on` fst) lst+    zs = map extract $ NE.groupBy ((==) `on` fst) lst       where         lst = zipWith (\(k, v) i -> (k, (v, i))) staticTableList $ map SIndex [1 ..]-        extract xs = (fst (head xs), map snd xs)++        extract xs = (fst (NE.head xs), NE.map snd xs)  {-# INLINE lookupStaticRevIndex #-} lookupStaticRevIndex
Network/HPACK/Types.hs view
@@ -22,8 +22,9 @@     BufferOverrun (..), ) where +import Control.Exception as E+import Data.Typeable import Network.ByteOrder (Buffer, BufferOverrun (..), BufferSize)-import UnliftIO.Exception as E  import Imports 
Network/HTTP2/Client.hs view
@@ -13,8 +13,8 @@ -- > import qualified Data.ByteString.Char8 as C8 -- > import Network.HTTP.Types -- > import Network.Run.TCP (runTCPClient) -- network-run--- > import UnliftIO.Async -- unliftio--- > import qualified UnliftIO.Exception as E -- unliftio+-- > import Control.Concurrent.Async -- unliftio+-- > import qualified Control.Exception as E -- unliftio -- > -- > import Network.HTTP2.Client -- >
Network/HTTP2/Client/Run.hs view
@@ -5,7 +5,10 @@  module Network.HTTP2.Client.Run where -import Control.Concurrent.STM (check)+import Control.Concurrent+import Control.Concurrent.Async+import Control.Concurrent.STM+import Control.Exception import qualified Data.ByteString.UTF8 as UTF8 import Data.IORef import Data.IP (IPv6)@@ -15,10 +18,6 @@ import Network.HTTP.Semantics.IO import Network.Socket (SockAddr) import Text.Read (readMaybe)-import UnliftIO.Async-import UnliftIO.Concurrent-import UnliftIO.Exception-import UnliftIO.STM  import Imports import Network.HTTP2.Frame@@ -142,7 +141,7 @@  runH2 :: Config -> Context -> IO a -> IO a runH2 conf ctx runClient = do-    stopAfter mgr (clientResult <$> race runBackgroundThreads runClient) $ \res ->+    stopAfter mgr runAll $ \res ->         closeAllStreams (oddStreamTable ctx) (evenStreamTable ctx) res   where     mgr = threadManager ctx@@ -152,9 +151,19 @@         labelMe "H2 runBackgroundThreads"         concurrently_ runReceiver runSender -    clientResult :: Either () a -> a-    clientResult (Left ()) = undefined -- unreachable-    clientResult (Right a) = a+    -- Run the background threads and client concurrently. If the client+    -- finishes first, cancel the background threads. If the background+    -- threads finish first, wait for the client.+    runAll = do+        withAsync runBackgroundThreads $ \runningBackgroundThreads ->+            withAsync runClient $ \runningClient -> do+                result <- waitEither runningBackgroundThreads runningClient+                case result of+                    Right clientResult -> do+                        cancel runningBackgroundThreads+                        return clientResult+                    Left () -> do+                        wait runningClient  sendRequest     :: Config@@ -200,11 +209,8 @@     (mnext, mtbq) <- case outObjBody of         OutBodyNone -> return (Nothing, Nothing)         OutBodyFile (FileSpec path fileoff bytecount) -> do-            (pread, closerOrRefresher) <- confPositionReadMaker path-            refresh <- case closerOrRefresher of-                Closer closer -> timeoutClose threadManager closer-                Refresher refresher -> return refresher-            let next = fillFileBodyGetNext pread fileoff bytecount refresh+            (pread, sentinel) <- confPositionReadMaker path+            let next = fillFileBodyGetNext pread fileoff bytecount sentinel             return (Just next, Nothing)         OutBodyBuilder builder -> do             let next = fillBuilderBodyGetNext builder
Network/HTTP2/Frame/Decode.hs view
@@ -24,12 +24,12 @@     decodeContinuationFrame, ) where +import Control.Exception (Exception) import Data.Array (Array, listArray, (!)) import qualified Data.ByteString as BS import Foreign.Ptr (Ptr, plusPtr) import qualified Network.ByteOrder as N import System.IO.Unsafe (unsafeDupablePerformIO)-import UnliftIO.Exception (Exception)  import Imports import Network.HTTP2.Frame.Types
Network/HTTP2/H2/Context.hs view
@@ -4,13 +4,13 @@  module Network.HTTP2.H2.Context where +import Control.Concurrent.STM+import Control.Exception+import qualified Control.Exception as E import Data.IORef import Network.Control import Network.Socket (SockAddr) import qualified System.TimeManager as T-import UnliftIO.Exception-import qualified UnliftIO.Exception as E-import UnliftIO.STM  import Imports hiding (insert) import Network.HPACK
Network/HTTP2/H2/HPACK.hs view
@@ -10,10 +10,10 @@     fixHeaders, ) where +import qualified Control.Exception as E import Network.ByteOrder import Network.HTTP.Semantics import Network.HTTP.Types-import qualified UnliftIO.Exception as E  import Imports import Network.HPACK
Network/HTTP2/H2/Manager.hs view
@@ -15,14 +15,14 @@     waitCounter0, ) where +import Control.Concurrent+import Control.Concurrent.STM+import Control.Exception+import qualified Control.Exception as E import Data.Foldable import Data.Map (Map) import qualified Data.Map.Strict as Map import qualified System.TimeManager as T-import UnliftIO.Concurrent-import UnliftIO.Exception-import qualified UnliftIO.Exception as E-import UnliftIO.STM  import Imports @@ -87,7 +87,7 @@ stopAfter :: Manager -> IO a -> (Maybe SomeException -> IO ()) -> IO a stopAfter (Manager q _ _) action cleanup = do     mask $ \unmask -> do-        ma <- trySyncOrAsync $ unmask action+        ma <- try $ unmask action         signalTimeoutsDisabled <- newEmptyMVar         atomically $             writeTQueue q $@@ -114,13 +114,13 @@ forkManagedUnmask     :: Manager -> String -> ((forall x. IO x -> IO x) -> IO ()) -> IO () forkManagedUnmask mgr label io =-    void $ mask_ $ forkIOWithUnmask $ \unmask -> E.handleSyncOrAsync handler $ do+    void $ mask_ $ forkIOWithUnmask $ \unmask -> E.handle handler $ do         labelMe label         addMyId mgr         incCounter mgr         -- We catch the exception and do not rethrow it: we don't want the         -- exception printed to stderr.-        io unmask `catchSyncOrAsync` \(_e :: SomeException) -> return ()+        io unmask `catch` \(_e :: SomeException) -> return ()         deleteMyId mgr         decCounter mgr   where@@ -205,4 +205,4 @@ waitCounter0 :: Manager -> IO () waitCounter0 (Manager _ cnt _) = atomically $ do     n <- readTVar cnt-    checkSTM (n < 1)+    check (n < 1)
Network/HTTP2/H2/Queue.hs view
@@ -2,7 +2,7 @@  module Network.HTTP2.H2.Queue where -import UnliftIO.STM+import Control.Concurrent.STM  import Network.HTTP2.H2.Types 
Network/HTTP2/H2/Receiver.hs view
@@ -8,6 +8,9 @@     frameReceiver, ) where +import Control.Concurrent+import Control.Concurrent.STM+import qualified Control.Exception as E import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as C8 import qualified Data.ByteString.Short as Short@@ -15,9 +18,6 @@ import Data.IORef import Network.Control import Network.HTTP.Semantics-import UnliftIO.Concurrent-import qualified UnliftIO.Exception as E-import UnliftIO.STM  import Imports hiding (delete, insert) import Network.HTTP2.Frame@@ -58,6 +58,9 @@                 loop      sendGoaway se+        | Just GoAwayIsSent <- E.fromException se = do+            waitCounter0 threadManager+            enqueueControl controlQ $ CFinish GoAwayIsSent         | Just ConnectionIsClosed <- E.fromException se = do             waitCounter0 threadManager             enqueueControl controlQ $ CFinish ConnectionIsClosed
Network/HTTP2/H2/Sender.hs view
@@ -7,14 +7,14 @@     frameSender, ) where +import Control.Concurrent.STM+import qualified Control.Exception as E import Data.IORef (modifyIORef', readIORef, writeIORef) import Data.IntMap.Strict (IntMap) import Foreign.Ptr (minusPtr, plusPtr) import Network.ByteOrder import Network.HTTP.Semantics.Client import Network.HTTP.Semantics.IO-import qualified UnliftIO.Exception as E-import UnliftIO.STM  import Imports import Network.HPACK (setLimitForEncoding, toTokenHeaderTable)@@ -104,7 +104,7 @@                     waitConnectionWindowSize ctx                     isEmptyO <- isEmptyTQueue outputQ                     if isEmptyO-                        then if off /= 0 then return Flush else retrySTM+                        then if off /= 0 then return Flush else retry                         else O <$> readTQueue outputQ                 else C <$> readTQueue controlQ 
Network/HTTP2/H2/Stream.hs view
@@ -6,16 +6,15 @@  module Network.HTTP2.H2.Stream where +import Control.Concurrent+import Control.Concurrent.STM+import Control.Exception import Control.Monad-import Control.Monad.STM (throwSTM) import Data.IORef import Data.Maybe (fromMaybe) import Network.Control import Network.HTTP.Semantics import Network.HTTP.Semantics.IO-import UnliftIO.Concurrent-import UnliftIO.Exception-import UnliftIO.STM  import Network.HTTP2.Frame import Network.HTTP2.H2.StreamTable
Network/HTTP2/H2/StreamTable.hs view
@@ -33,11 +33,11 @@  import Control.Concurrent import Control.Concurrent.STM+import Control.Exception import Data.IntMap.Strict (IntMap) import qualified Data.IntMap.Strict as IntMap import Network.Control (LRUCache) import qualified Network.Control as LRUCache-import UnliftIO.Exception  import Imports import Network.HTTP2.H2.Types (Stream (..))
Network/HTTP2/H2/Sync.hs view
@@ -3,8 +3,8 @@ module Network.HTTP2.H2.Sync (prepareSync, syncWithSender) where  import Control.Concurrent+import Control.Concurrent.STM import Network.HTTP.Semantics.IO-import UnliftIO.STM  import Network.HTTP2.H2.Context import Network.HTTP2.H2.Queue@@ -96,4 +96,4 @@ waitStreaming :: TBQueue a -> IO () waitStreaming tbq = atomically $ do     isEmpty <- isEmptyTBQueue tbq-    checkSTM (not isEmpty)+    check (not isEmpty)
Network/HTTP2/H2/Types.hs view
@@ -5,6 +5,10 @@  module Network.HTTP2.H2.Types where +import Control.Concurrent+import Control.Concurrent.STM+import Control.Exception (SomeException)+import qualified Control.Exception as E import Data.IORef import Data.Typeable import Network.Control@@ -13,10 +17,6 @@ import Network.Socket hiding (Stream) import System.IO.Unsafe import qualified System.TimeManager as T-import UnliftIO.Concurrent-import UnliftIO.Exception (SomeException)-import qualified UnliftIO.Exception as E-import UnliftIO.STM  import Imports import Network.HPACK
Network/HTTP2/H2/Window.hs view
@@ -3,11 +3,11 @@  module Network.HTTP2.H2.Window where +import Control.Concurrent.STM+import qualified Control.Exception as E import qualified Data.ByteString as BS import Data.IORef import Network.Control-import qualified UnliftIO.Exception as E-import UnliftIO.STM  import Imports import Network.HTTP2.Frame@@ -27,12 +27,12 @@ waitStreamWindowSize :: Stream -> IO () waitStreamWindowSize Stream{streamTxFlow} = atomically $ do     w <- txWindowSize <$> readTVar streamTxFlow-    checkSTM (w > 0)+    check (w > 0)  waitConnectionWindowSize :: Context -> STM () waitConnectionWindowSize Context{txFlow} = do     w <- txWindowSize <$> readTVar txFlow-    checkSTM (w > 0)+    check (w > 0)  ---------------------------------------------------------------- -- Receiving window update
Network/HTTP2/Server.hs view
@@ -7,7 +7,7 @@ -- > {-# LANGUAGE OverloadedStrings #-} -- > module Main (main) where -- >--- > import qualified UnliftIO.Exception as E+-- > import qualified Control.Exception as E -- > import Data.ByteString.Builder (byteString) -- > import Network.HTTP.Types (ok200) -- > import Network.Run.TCP (runTCPServer) -- network-run
Network/HTTP2/Server/Run.hs view
@@ -4,6 +4,7 @@  module Network.HTTP2.Server.Run where +import Control.Concurrent.Async (concurrently_) import Control.Concurrent.STM import Imports import Network.Control (defaultMaxData)@@ -11,7 +12,6 @@ import Network.HTTP.Semantics.Server import Network.HTTP.Semantics.Server.Internal import Network.Socket (SockAddr)-import UnliftIO.Async (concurrently_)  import Network.HTTP2.Frame import Network.HTTP2.H2@@ -20,13 +20,15 @@ -- | Server configuration data ServerConfig = ServerConfig     { numberOfWorkers :: Int-    -- ^ The number of workers+    -- ^ Deprecated field.     , connectionWindowSize :: WindowSize     -- ^ The window size of incoming streams     , settings :: Settings     -- ^ Settings     }     deriving (Eq, Show)++{-# DEPRECATED numberOfWorkers "No effect anymore" #-}  -- | The default server config. --
Network/HTTP2/Server/Worker.hs view
@@ -6,6 +6,7 @@     worker, ) where +import Control.Concurrent.STM import Data.IORef import Network.HTTP.Semantics import Network.HTTP.Semantics.IO@@ -13,7 +14,6 @@ import Network.HTTP.Semantics.Server.Internal import Network.HTTP.Types import qualified System.TimeManager as T-import UnliftIO.STM  import Imports hiding (insert) import Network.HTTP2.Frame@@ -56,7 +56,7 @@     -- Checking if all push are done.     waiter lim tvar = atomically $ do         n <- readTVar tvar-        checkSTM (n >= lim)+        check (n >= lim)     push _ [] n = return (n :: Int)     push tvar (pp : pps) n = do         forkManaged threadManager "H2 server push" $ do@@ -111,11 +111,8 @@     (mnext, mtbq) <- case outObjBody of         OutBodyNone -> return (Nothing, Nothing)         OutBodyFile (FileSpec path fileoff bytecount) -> do-            (pread, closerOrRefresher) <- confPositionReadMaker path-            refresh <- case closerOrRefresher of-                Closer closer -> timeoutClose threadManager closer-                Refresher refresher -> return refresher-            let next = fillFileBodyGetNext pread fileoff bytecount refresh+            (pread, sentinel) <- confPositionReadMaker path+            let next = fillFileBodyGetNext pread fileoff bytecount sentinel             return (Just next, Nothing)         OutBodyBuilder builder -> do             let next = fillBuilderBodyGetNext builder
bench-hpack/Main.hs view
@@ -2,10 +2,10 @@  module Main where +import Control.Exception import Criterion.Main import Data.ByteString (ByteString) import Network.HPACK-import UnliftIO.Exception  ---------------------------------------------------------------- 
http2.cabal view
@@ -1,6 +1,6 @@ cabal-version:      >=1.10 name:               http2-version:            5.3.4+version:            5.3.5 license:            BSD3 license-file:       LICENSE maintainer:         Kazu Yamamoto <kazu@iij.ad.jp>@@ -116,7 +116,7 @@         bytestring >=0.10,         case-insensitive >=1.2 && <1.3,         containers >=0.6,-        http-semantics >= 0.2.1 && <0.3,+        http-semantics >= 0.3 && <0.4,         http-types >=0.12 && <0.13,         iproute >= 1.7 && < 1.8,         network >=3.1,@@ -125,7 +125,6 @@         stm >=2.5 && <2.6,         time-manager >=0.1 && <0.2,         unix-time >=0.4.11 && <0.5,-        unliftio >=0.2 && <0.3,         utf8-string >=1.0 && <1.1  executable h2c-client@@ -142,8 +141,7 @@         http-types,         http2,         network-run >= 0.3 && <0.5,-        unix-time,-        unliftio+        unix-time      if flag(devel) @@ -163,8 +161,7 @@         crypton,         http2,         http-types,-        network-run,-        unliftio+        network-run      if flag(devel) @@ -221,7 +218,6 @@         http2,         network-byte-order,         text,-        unliftio,         unordered-containers,         vector,         word8@@ -315,7 +311,6 @@         network,         network-run >=0.3.0,         random,-        unliftio,         typed-process  test-suite spec2@@ -334,8 +329,7 @@         http-types,         http2,         network-run >=0.3.0,-        typed-process,-        unliftio+        typed-process      if flag(h2spec) @@ -365,7 +359,6 @@         hspec >=1.3,         http2,         text,-        unliftio,         unordered-containers,         vector @@ -413,5 +406,4 @@         criterion,         http2,         network-byte-order,-        stm,-        unliftio+        stm
test-hpack/HPACKDecode.hs view
@@ -12,13 +12,13 @@ #if __GLASGOW_HASKELL__ < 709 import Control.Applicative ((<$>)) #endif+import Control.Exception import Control.Monad (when) import qualified Data.ByteString.Base16 as B16 import qualified Data.ByteString.Char8 as B8 import Data.List (sort) import Network.HPACK import Network.HPACK.Table-import UnliftIO.Exception  import JSON 
test/HPACK/EncodeSpec.hs view
@@ -5,12 +5,12 @@ #if __GLASGOW_HASKELL__ < 709 import Control.Applicative ((<$>)) #endif+import qualified Control.Exception as E import Data.Bits import qualified Data.ByteString as BS import Data.Maybe (fromMaybe) import Network.HPACK import Test.Hspec-import qualified UnliftIO.Exception as E  spec :: Spec spec = do
test/HTTP2/ClientSpec.hs view
@@ -6,6 +6,7 @@ module HTTP2.ClientSpec (spec) where  import Control.Concurrent+import qualified Control.Exception as E import Control.Monad import Data.ByteString.Builder (byteString) import Data.Foldable (for_)@@ -18,7 +19,6 @@ import System.Random import System.Timeout (timeout) import Test.Hspec-import qualified UnliftIO.Exception as E  import Network.HTTP2.Client import qualified Network.HTTP2.Server as S
test/HTTP2/ServerSpec.hs view
@@ -6,8 +6,12 @@ module HTTP2.ServerSpec (spec) where  import Control.Concurrent+-- cryptonite++import Control.Concurrent.Async+import qualified Control.Exception as E import Control.Monad-import Crypto.Hash (Context, SHA1) -- cryptonite+import Crypto.Hash (Context, SHA1) import qualified Crypto.Hash as CH import Data.ByteString (ByteString) import qualified Data.ByteString as B@@ -23,8 +27,6 @@ import System.IO.Unsafe import System.Random import Test.Hspec-import UnliftIO.Async-import qualified UnliftIO.Exception as E  import Network.HPACK import Network.HPACK.Internal
test2/ServerSpec.hs view
@@ -4,13 +4,13 @@ module ServerSpec (spec) where  import Control.Concurrent+import qualified Control.Exception as E import Data.ByteString.Builder (byteString) import Network.HTTP.Types import Network.Run.TCP import System.Exit import System.Process.Typed import Test.Hspec-import qualified UnliftIO.Exception as E  import Network.HTTP2.Server 
util/Client.hs view
@@ -4,14 +4,14 @@  module Client where +import Control.Concurrent.Async+import qualified Control.Exception as E import Control.Monad import qualified Data.ByteString.Char8 as C8 import Data.UnixTime import Foreign.C.Types import Network.HTTP.Types import Text.Printf-import UnliftIO.Async-import qualified UnliftIO.Exception as E  import Network.HTTP2.Client 
util/h2c-client.hs view
@@ -4,13 +4,13 @@ module Main where  import Control.Concurrent+import qualified Control.Exception as E import qualified Data.ByteString.Char8 as C8 import Network.HTTP2.Client import Network.Run.TCP (runTCPClient) import System.Console.GetOpt import System.Environment import System.Exit-import qualified UnliftIO.Exception as E  import Client import Monitor
util/h2c-server.hs view
@@ -5,12 +5,12 @@ module Main (main) where  import Control.Concurrent+import qualified Control.Exception as E import Network.HTTP2.Server import Network.Run.TCP import System.Console.GetOpt import System.Environment import System.Exit-import qualified UnliftIO.Exception as E  import Monitor import Server