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