@@ -1,11 +1,16 @@
11module Network.Wai.HTTP2
22 ( Http2Application
3+ , Response(..)
34 , Trailers
5+ , responseStatus
6+ , responseHeaders
47 ) where
58
9+import Blaze.ByteString.Builder (Builder)
10+import qualified Data.ByteString as B
611import qualified Network.HTTP.Types as H
712
8−import Network.Wai.Internal (Request, Response)
13+import Network.Wai.Internal (Request, FilePart)
914
1015-- | Headers sent after the end of a data stream, as defined by section 4.1.2 of
1116-- the HTTP\/1.1 spec (RFC 7230), and section 8.1 of the HTTP\/2 spec.
@@ -13,3 +18,21 @@ type Trailers = H.ResponseHeaders
1318
1419-- | The HTTP\/2-aware equivalent of 'Network.Wai.Application'.
1520type Http2Application = Request -> (Response -> IO ()) -> IO Trailers
21+
22+type StreamingBody = (Builder -> IO ()) -> IO () -> IO ()
23+
24+data Response
25+ = ResponseFile H.Status H.ResponseHeaders FilePath (Maybe FilePart)
26+ | ResponseBuilder H.Status H.ResponseHeaders Builder
27+ | ResponseStream H.Status H.ResponseHeaders StreamingBody
28+ | ResponseRaw (IO B.ByteString -> (B.ByteString -> IO ()) -> IO ()) Response
29+
30+responseStatus :: Response -> H.Status
31+responseStatus (ResponseFile s _ _ _) = s
32+responseStatus (ResponseBuilder s _ _) = s
33+responseStatus (ResponseStream s _ _) = s
34+responseStatus (ResponseRaw _ res) = responseStatus res
35+
36+responseHeaders :: Response -> H.ResponseHeaders
37+responseHeaders _ = []
38+