@@ -2,6 +2,7 @@
22{-# LANGUAGE OverloadedStrings #-}
33{-# LANGUAGE ScopedTypeVariables #-}
44{-# LANGUAGE TupleSections #-}
5+{-# LANGUAGE PatternGuards #-}
56{-# OPTIONS_GHC -fno-warn-deprecations #-}
67
78module Network.Wai.Handler.Warp.Run where
@@ -445,9 +446,13 @@ serveHTTP2 app2 app conn ii origAddr transport settings = do
445446
446447 th = threadHandle ii
447448
449+ shouldSendErrorResponse se
450+ | Just ConnectionClosedByPeer <- fromException se = False
451+ | otherwise = True
452+
448453 sendErrorResponse addr istatus e = do
449454 status <- readIORef istatus
450− when status $ void $
455+ when (shouldSendErrorResponse e && status) $ void $
451456 sendResponse settings conn ii (dummyreq addr) defaultIndexRequestHeader (return S.empty) (errorResponse e)
452457
453458 dummyreq addr = defaultRequest { remoteHost = addr }