{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module Network.Wai.Handler.Warp.HTTP2.Types where
import qualified Data.ByteString as BS
import qualified Network.HTTP.Types as H
import Network.HTTP2.Frame
import qualified Network.HTTP2.Server as H2
import Network.Wai.Handler.Warp.Imports
import Network.Wai.Handler.Warp.Types
isHTTP2 :: Transport -> Bool
isHTTP2 :: Transport -> Bool
isHTTP2 Transport
TCP = Bool
False
isHTTP2 Transport
tls = Bool
useHTTP2
where
useHTTP2 :: Bool
useHTTP2 = case Transport -> Maybe ByteString
tlsNegotiatedProtocol Transport
tls of
Maybe ByteString
Nothing -> Bool
False
Just ByteString
proto -> ByteString
"h2" ByteString -> ByteString -> Bool
`BS.isPrefixOf` ByteString
proto
data HTTP2Data = HTTP2Data
{ HTTP2Data -> [PushPromise]
http2dataPushPromise :: [PushPromise]
, HTTP2Data -> TrailersMaker
http2dataTrailers :: H2.TrailersMaker
}
defaultHTTP2Data :: HTTP2Data
defaultHTTP2Data :: HTTP2Data
defaultHTTP2Data = [PushPromise] -> TrailersMaker -> HTTP2Data
HTTP2Data [] TrailersMaker
H2.defaultTrailersMaker
data PushPromise = PushPromise
{ PushPromise -> ByteString
promisedPath :: ByteString
, PushPromise -> FilePath
promisedFile :: FilePath
, :: H.ResponseHeaders
, PushPromise -> Weight
promisedWeight :: Weight
}
deriving (PushPromise -> PushPromise -> Bool
(PushPromise -> PushPromise -> Bool)
-> (PushPromise -> PushPromise -> Bool) -> Eq PushPromise
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PushPromise -> PushPromise -> Bool
== :: PushPromise -> PushPromise -> Bool
$c/= :: PushPromise -> PushPromise -> Bool
/= :: PushPromise -> PushPromise -> Bool
Eq, Eq PushPromise
Eq PushPromise =>
(PushPromise -> PushPromise -> Ordering)
-> (PushPromise -> PushPromise -> Bool)
-> (PushPromise -> PushPromise -> Bool)
-> (PushPromise -> PushPromise -> Bool)
-> (PushPromise -> PushPromise -> Bool)
-> (PushPromise -> PushPromise -> PushPromise)
-> (PushPromise -> PushPromise -> PushPromise)
-> Ord PushPromise
PushPromise -> PushPromise -> Bool
PushPromise -> PushPromise -> Ordering
PushPromise -> PushPromise -> PushPromise
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PushPromise -> PushPromise -> Ordering
compare :: PushPromise -> PushPromise -> Ordering
$c< :: PushPromise -> PushPromise -> Bool
< :: PushPromise -> PushPromise -> Bool
$c<= :: PushPromise -> PushPromise -> Bool
<= :: PushPromise -> PushPromise -> Bool
$c> :: PushPromise -> PushPromise -> Bool
> :: PushPromise -> PushPromise -> Bool
$c>= :: PushPromise -> PushPromise -> Bool
>= :: PushPromise -> PushPromise -> Bool
$cmax :: PushPromise -> PushPromise -> PushPromise
max :: PushPromise -> PushPromise -> PushPromise
$cmin :: PushPromise -> PushPromise -> PushPromise
min :: PushPromise -> PushPromise -> PushPromise
Ord, Weight -> PushPromise -> ShowS
[PushPromise] -> ShowS
PushPromise -> FilePath
(Weight -> PushPromise -> ShowS)
-> (PushPromise -> FilePath)
-> ([PushPromise] -> ShowS)
-> Show PushPromise
forall a.
(Weight -> a -> ShowS)
-> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Weight -> PushPromise -> ShowS
showsPrec :: Weight -> PushPromise -> ShowS
$cshow :: PushPromise -> FilePath
show :: PushPromise -> FilePath
$cshowList :: [PushPromise] -> ShowS
showList :: [PushPromise] -> ShowS
Show)
defaultPushPromise :: PushPromise
defaultPushPromise :: PushPromise
defaultPushPromise = ByteString -> FilePath -> ResponseHeaders -> Weight -> PushPromise
PushPromise ByteString
"" FilePath
"" [] Weight
16