on master help sign in
Curry the Http2Application type
commit2bceea06affce4a26942ad1a4f12e7c9a9dcaa07 authorAndrew Pritchard <awpr@google.com> dateThu 6 Aug 2015, 22:39 (11 years ago) parent0adedc1
3 files changed+6−8
wai/Network/Wai/HTTP2.hs+4−6 warp/Network/Wai/Handler/Warp/HTTP2.hs+1−1 warp/Network/Wai/Handler/Warp/HTTP2/Worker.hs+1−1
wai/Network/Wai/HTTP2.hs+4−6
@@ -14,7 +14,7 @@ import qualified Data.ByteString.Lazy as L
1414import Data.ByteString.Builder (Builder)
1515import qualified Network.HTTP.Types as H
1616
17−import qualified Network.Wai.Internal as H1 (Request)
17+import Network.Wai.Internal (Request)
1818
1919-- | Headers sent after the end of a data stream, as defined by section 4.1.2 of
2020-- the HTTP\/1.1 spec (RFC 7230), and section 8.1 of the HTTP\/2 spec.
@@ -29,12 +29,8 @@ data PushPromise = PushPromise
2929 , promisedHeader :: H.RequestHeaders
3030 }
3131
32−-- | The type of an HTTP\/2 request: a normal HTTP request and an action to
33−-- push streams associated with this request.
34−type Request = (H1.Request, PushPromise -> Responder -> IO Bool)
35−
3632-- | The HTTP\/2-aware equivalent of 'Network.Wai.Application'.
37−type Http2Application = Request -> Responder
33+type Http2Application = Request -> PushFunc -> Responder
3834
3935type Body a = (Builder -> IO ()) -> IO () -> IO a
4036
@@ -42,6 +38,8 @@ type RespondFunc = forall a. H.Status -> H.ResponseHeaders -> Body a -> IO a
4238
4339type Responder = RespondFunc -> IO Trailers
4440
41+type PushFunc = PushPromise -> Responder -> IO Bool
42+
4543promiseHeaders :: PushPromise -> H.RequestHeaders
4644promiseHeaders p =
4745 [ (":method", promisedMethod p)
warp/Network/Wai/Handler/Warp/HTTP2.hs+1−1
@@ -77,7 +77,7 @@ goaway Connection{..} etype debugmsg = connSendAll bytestream
7777-- | Promote a normal WAI 'Application' to an 'Http2Application' by ignoring
7878-- the HTTP/2-specific features.
7979promoteApplication :: Application -> Http2Application
80−promoteApplication app (req, _) respond = [] <$ app req respond'
80+promoteApplication app req _ respond = [] <$ app req respond'
8181 where
8282 respond' r = ResponseReceived <$ (withBody $ respond s h)
8383 where (s, h, withBody) = responseToStream r
warp/Network/Wai/Handler/Warp/HTTP2/Worker.hs+1−1
@@ -144,7 +144,7 @@ worker ctx@Context{inputQ} set tm app respond = do
144144 setStreamInfo sinfo strm req
145145 T.resume th
146146 T.tickle th
147− let responder = app (req, pushResponder ctx set strm)
147+ let responder = app req $ pushResponder ctx set strm
148148 runResponder responder (respond tcont) (T.tickle th) strm
149149 cont1 <- case ex of
150150 Right () -> return True