on master help sign in
Add 'promoteApplication'; use it in 'serveConnection'

This is the identity function for now, but eventually it will handle discarding the irrelevant functionality of the HTTP/2 application type.

commit8273bed81b7b369e1698352f1e4c18f6c8662171 authorAndrew Pritchard <awpr@google.com> dateWed 29 Jul 2015, 21:11 (11 years ago) parent2b6b5ff
2 files changed+13−3
warp/Network/Wai/Handler/Warp/HTTP2.hs+11−1 warp/Network/Wai/Handler/Warp/Run.hs+2−2
warp/Network/Wai/Handler/Warp/HTTP2.hs+11−1
@@ -1,7 +1,11 @@
11{-# LANGUAGE OverloadedStrings #-}
22{-# LANGUAGE RecordWildCards #-}
33
4−module Network.Wai.Handler.Warp.HTTP2 (isHTTP2, http2) where
4+module Network.Wai.Handler.Warp.HTTP2
5+ ( isHTTP2
6+ , http2
7+ , promoteApplication
8+ ) where
59
610import Control.Concurrent (forkIO, killThread)
711import qualified Control.Exception as E
@@ -11,6 +15,7 @@ import Data.ByteString (ByteString)
1115import Network.HTTP2
1216import Network.Socket (SockAddr)
1317
18+import Network.Wai (Application)
1419import Network.Wai.HTTP2 (Http2Application)
1520import Network.Wai.Handler.Warp.HTTP2.EncodeFrame
1621import Network.Wai.Handler.Warp.HTTP2.Manager
@@ -66,3 +71,8 @@ goaway :: Connection -> ErrorCodeId -> ByteString -> IO ()
6671goaway Connection{..} etype debugmsg = connSendAll bytestream
6772 where
6873 bytestream = goawayFrame 0 etype debugmsg
74+
75+-- | Promote a normal WAI 'Application' to an 'Http2Application' by ignoring
76+-- the HTTP/2-specific features.
77+promoteApplication :: Application -> Http2Application
78+promoteApplication app = app
warp/Network/Wai/Handler/Warp/Run.hs+2−2
@@ -25,7 +25,7 @@ import Network.Wai.Handler.Warp.Buffer
2525import Network.Wai.Handler.Warp.Counter
2626import qualified Network.Wai.Handler.Warp.Date as D
2727import qualified Network.Wai.Handler.Warp.FdCache as F
28−import Network.Wai.Handler.Warp.HTTP2
28+import Network.Wai.Handler.Warp.HTTP2 (http2, isHTTP2, promoteApplication)
2929import Network.Wai.Handler.Warp.Header
3030import Network.Wai.Handler.Warp.ReadInt
3131import Network.Wai.Handler.Warp.Recv
@@ -311,7 +311,7 @@ serveConnection conn ii origAddr transport settings app = do
311311 if h2 then do
312312 recvN <- makeReceiveN bs (connRecv conn) (connRecvBuf conn)
313313 -- fixme: origAddr
314− http2 conn ii origAddr transport settings recvN app
314+ http2 conn ii origAddr transport settings recvN $ promoteApplication app
315315 else do
316316 istatus <- newIORef False
317317 src <- mkSource (wrappedRecv conn th istatus (settingsSlowlorisSize settings))