on master help sign in
fixing a test failure of h2spec.

Priority frame to a closed stream.

commitbc060b6af2ac74bbe441844aab275f6bc22748ff authorKazu Yamamoto <kazu@iij.ad.jp> dateTue 31 Jan 2017, 15:12 (10 years ago) parent67cf9d3
1 file changed+17−13
warp/Network/Wai/Handler/Warp/HTTP2/Receiver.hs+17−13
warp/Network/Wai/Handler/Warp/HTTP2/Receiver.hs+17−13
@@ -166,19 +166,23 @@ frameReceiver ctx mkreq recvN = loop 0 `E.catch` sendGoaway
166166 when (ftyp `notElem` [FrameHeaders,FramePriority]) $
167167 E.throwIO $ ConnectionError ProtocolError "this frame is not allowed in an idel stream"
168168 csid <- readIORef clientStreamId
169− when (streamId <= csid) $
170− E.throwIO $ ConnectionError ProtocolError "stream identifier must not decrease"
171− when (ftyp == FrameHeaders) $ do
172− writeIORef clientStreamId streamId
173− cnt <- readIORef concurrency
174− -- Checking the limitation of concurrency
175− when (cnt >= maxConcurrency) $
176− E.throwIO $ StreamError RefusedStream streamId
177− ws <- initialWindowSize <$> readIORef http2settings
178− newstrm <- newStream streamId (fromIntegral ws)
179− when (ftyp == FrameHeaders) $ opened ctx newstrm
180− insert streamTable streamId newstrm
181− return $ Just newstrm
169+ if streamId <= csid then do
170+ if ftyp == FramePriority then
171+ return Nothing -- will be ignored
172+ else
173+ E.throwIO $ ConnectionError ProtocolError "stream identifier must not decrease"
174+ else do
175+ when (ftyp == FrameHeaders) $ do
176+ writeIORef clientStreamId streamId
177+ cnt <- readIORef concurrency
178+ -- Checking the limitation of concurrency
179+ when (cnt >= maxConcurrency) $
180+ E.throwIO $ StreamError RefusedStream streamId
181+ ws <- initialWindowSize <$> readIORef http2settings
182+ newstrm <- newStream streamId (fromIntegral ws)
183+ when (ftyp == FrameHeaders) $ opened ctx newstrm
184+ insert streamTable streamId newstrm
185+ return $ Just newstrm
182186
183187 consume = void . recvN
184188