Skip to content

Commit

Permalink
ensuring to receive 4 bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed May 15, 2024
1 parent 55adf23 commit 5e508a2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions warp/Network/Wai/Handler/Warp/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,27 @@ serveConnection conn ii th origAddr transport settings app = do
if isHTTP2 transport
then return (True, "")
else do
bs0 <- connRecv conn
if S.length bs0 >= 4 && "PRI " `S.isPrefixOf` bs0
bs0 <- recv4
if "PRI " `S.isPrefixOf` bs0
then return (True, bs0)
else return (False, bs0)
if settingsHTTP2Enabled settings && h2
then do
http2 settings ii conn transport app origAddr th bs
else do
http1 settings ii conn transport app origAddr th bs
where
recv4 = do
bs0 <- connRecv conn
if S.length bs0 >= 4
then return bs0
else loop bs0
loop bs0 = do
bs1 <- connRecv conn
let bs = bs0 `S.append` bs1
if S.length bs >= 4
then return bs
else loop bs

-- | Set flag FileCloseOnExec flag on a socket (on Unix)
--
Expand Down

0 comments on commit 5e508a2

Please sign in to comment.