on master help sign in
Move HTTP2 connection handler to Http2Application
72684a7Andrew Pritchard
warp/Network/Wai/Handler/Warp/HTTP2.hs+4−2
@@ -7,9 +7,11 @@ import Control.Concurrent (forkIO, killThread)
7import qualified Control.Exception as E
7import qualified Control.Exception as E
8import Control.Monad (when, unless, replicateM_)
8import Control.Monad (when, unless, replicateM_)
9import Data.ByteString (ByteString)
9import Data.ByteString (ByteString)
10+
10import Network.HTTP2
11import Network.HTTP2
11import Network.Socket (SockAddr)
12import Network.Socket (SockAddr)
13+
12−import Network.Wai
14+import Network.Wai.HTTP2 (Http2Application)
13import Network.Wai.Handler.Warp.HTTP2.EncodeFrame
15import Network.Wai.Handler.Warp.HTTP2.EncodeFrame
14import Network.Wai.Handler.Warp.HTTP2.Manager
16import Network.Wai.Handler.Warp.HTTP2.Manager
15import Network.Wai.Handler.Warp.HTTP2.Receiver
17import Network.Wai.Handler.Warp.HTTP2.Receiver
@@ -22,7 +24,7 @@ import Network.Wai.Handler.Warp.Types
22
24
23----------------------------------------------------------------
25----------------------------------------------------------------
24
26
25−http2 :: Connection -> InternalInfo -> SockAddr -> Transport -> S.Settings -> (BufSize -> IO ByteString) -> Application -> IO ()
27+http2 :: Connection -> InternalInfo -> SockAddr -> Transport -> S.Settings -> (BufSize -> IO ByteString) -> Http2Application -> IO ()
26http2 conn ii addr transport settings readN app = do
28http2 conn ii addr transport settings readN app = do
27 checkTLS
29 checkTLS
28 ok <- checkPreface
30 ok <- checkPreface
warp/Network/Wai/Handler/Warp/HTTP2/Worker.hs+6−4
@@ -22,6 +22,7 @@ import qualified Network.HTTP.Types as H
22import Network.HTTP2
22import Network.HTTP2
23import Network.HTTP2.Priority
23import Network.HTTP2.Priority
24import Network.Wai
24import Network.Wai
25+import Network.Wai.HTTP2 (Http2Application)
25import Network.Wai.Handler.Warp.HTTP2.EncodeFrame
26import Network.Wai.Handler.Warp.HTTP2.EncodeFrame
26import Network.Wai.Handler.Warp.HTTP2.Manager
27import Network.Wai.Handler.Warp.HTTP2.Manager
27import Network.Wai.Handler.Warp.HTTP2.Types
28import Network.Wai.Handler.Warp.HTTP2.Types
@@ -33,14 +34,14 @@ import Network.Wai.Internal (Response(..), ResponseReceived(..), ResponseReceive
33
34
34----------------------------------------------------------------
35----------------------------------------------------------------
35
36
36−-- | The wai definition is 'type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived'.
37+-- | The wai definition is @type Http2Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived@.
37−-- This type implements the second argument (Response -> IO ResponseReceived)
38+-- This type implements the second argument @Response -> IO ResponseReceived@
38-- with extra arguments.
39-- with extra arguments.
39type Responder = ThreadContinue -> T.Handle -> Stream -> Request ->
40type Responder = ThreadContinue -> T.Handle -> Stream -> Request ->
40 Response -> IO ResponseReceived
41 Response -> IO ResponseReceived
41
42
42-- | This function is passed to workers.
43-- | This function is passed to workers.
43−-- They also pass 'Response's from 'Application's to this function.
44+-- They also pass 'Response's from 'Http2Application's to this function.
44-- This function enqueues commands for the HTTP/2 sender.
45-- This function enqueues commands for the HTTP/2 sender.
45response :: Context -> Manager -> Responder
46response :: Context -> Manager -> Responder
46response Context{outputQ} mgr tconf th strm req rsp = do
47response Context{outputQ} mgr tconf th strm req rsp = do
@@ -83,7 +84,8 @@ data Break = Break deriving (Show, Typeable)
83
84
84instance Exception Break
85instance Exception Break
85
86
87+worker ::
86−worker :: Context -> S.Settings -> T.Manager -> Application -> Responder -> IO ()
88+ Context -> S.Settings -> T.Manager -> Http2Application -> Responder -> IO ()
87worker ctx@Context{inputQ,outputQ} set tm app responder = do
89worker ctx@Context{inputQ,outputQ} set tm app responder = do
88 tid <- myThreadId
90 tid <- myThreadId
89 sinfo <- newStreamInfo
91 sinfo <- newStreamInfo