on master help sign in
Use 'unlessClosed' to guard trailers as well
8d13737Andrew Pritchard
warp/Network/Wai/Handler/Warp/HTTP2/Sender.hs+14−10
@@ -108,18 +108,22 @@ frameSender ctx@Context{outputQ,connectionWindow}
108 sendResponse strm s h aux lim
108 sendResponse strm s h aux lim
109 loop
109 loop
110 switch (OTrailers strm []) = do
110 switch (OTrailers strm []) = do
111+ unlessClosed conn strm $ do
112+ -- An empty data frame should be used to end the stream instead
113+ -- when there are no trailers.
111− let flag = setEndStream defaultFlags
114+ let flag = setEndStream defaultFlags
112− fillFrameHeader FrameData 0 (streamNumber strm) flag connWriteBuffer
115+ fillFrameHeader FrameData 0 (streamNumber strm) flag connWriteBuffer
113− closed strm Finished
116+ closed strm Finished
114− flushN frameHeaderLength
117+ flushN frameHeaderLength
115 loop
118 loop
116 switch (OTrailers strm trailers) = do
119 switch (OTrailers strm trailers) = do
120+ unlessClosed conn strm $ do
117− -- Trailers always indicate the end of a stream; send them in
121+ -- Trailers always indicate the end of a stream; send them in
118− -- consecutive header+continuation frames and end the stream.
122+ -- consecutive header+continuation frames and end the stream.
119− builder <- hpackEncodeCIHeaders ctx trailers
123+ builder <- hpackEncodeCIHeaders ctx trailers
120− off <- headerContinue (streamNumber strm) builder True
124+ off <- headerContinue (streamNumber strm) builder True
121− closed strm Finished
125+ closed strm Finished
122− flushN $ off + frameHeaderLength
126+ flushN $ off + frameHeaderLength
123 loop
127 loop
124
128
125 -- Send the response headers and as much of the response as is immediately
129 -- Send the response headers and as much of the response as is immediately