@@ -20,7 +20,7 @@ import Control.Monad (void, when)
2020import Data.Typeable
2121import Network.HTTP2
2222import Network.HTTP2.Priority
23−import Network.Wai.HTTP2 (Http2Application, Response(..))
23+import Network.Wai.HTTP2 (Http2Application, Response)
2424import Network.Wai hiding (Response, responseStatus)
2525import Network.Wai.Handler.Warp.HTTP2.EncodeFrame
2626import Network.Wai.Handler.Warp.HTTP2.Manager
@@ -41,32 +41,30 @@ type Responder = ThreadContinue -> T.Handle -> Stream ->
4141-- They also pass 'Response's from 'Http2Application's to this function.
4242-- This function enqueues commands for the HTTP/2 sender.
4343response :: Context -> Manager -> Responder
44−response Context{outputQ} mgr tconf th strm sq rsp = do
45− case rsp of
46− ResponseStream _ _ strmbdy -> do
47− -- TODO(awpr)r HEAD requests will still stream.
48− --
49− -- We must not exit this WAI application.
50− -- If the application exits, streaming would be also closed.
51− -- So, this work occupies this thread.
52− --
53− -- We need to increase the number of workers.
54− myThreadId >>= replaceWithAction mgr
55− -- After this work, this thread stops to decease
56− -- the number of workers.
57− setThreadContinue tconf False
58− tvar <- newTVarIO SyncNone
59− let out = OResponse strm rsp (Persist sq tvar)
60− -- Since we must not enqueue an empty queue to the priority
61− -- queue, we spawn a thread to ensure that the designated
62− -- queue is not empty.
63− void $ forkIO $ waiter tvar sq strm outputQ
64− atomically $ writeTVar tvar (SyncNext out)
65− let push b = do
66− atomically $ writeTBQueue sq (SBuilder b)
67− T.tickle th
68− flush = atomically $ writeTBQueue sq SFlush
69− strmbdy push flush
44+response Context{outputQ} mgr tconf th strm sq (s, h, strmbdy) = do
45+ -- TODO(awpr)r HEAD requests will still stream.
46+ --
47+ -- We must not exit this WAI application.
48+ -- If the application exits, streaming would be also closed.
49+ -- So, this work occupies this thread.
50+ --
51+ -- We need to increase the number of workers.
52+ myThreadId >>= replaceWithAction mgr
53+ -- After this work, this thread stops to decease
54+ -- the number of workers.
55+ setThreadContinue tconf False
56+ tvar <- newTVarIO SyncNone
57+ let out = OResponse strm s h (Persist sq tvar)
58+ -- Since we must not enqueue an empty queue to the priority
59+ -- queue, we spawn a thread to ensure that the designated
60+ -- queue is not empty.
61+ void $ forkIO $ waiter tvar sq strm outputQ
62+ atomically $ writeTVar tvar (SyncNext out)
63+ let push b = do
64+ atomically $ writeTBQueue sq (SBuilder b)
65+ T.tickle th
66+ flush = atomically $ writeTBQueue sq SFlush
67+ strmbdy push flush
7068
7169data Break = Break deriving (Show, Typeable)
7270