{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Network.Wai.Handler.Warp.HTTP2.Types where
import qualified Data.ByteString as BS
import qualified Network.HTTP.Types as H
import Network.HTTP2
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
/= :: PushPromise -> PushPromise -> Bool
$c/= :: PushPromise -> PushPromise -> Bool
== :: PushPromise -> PushPromise -> Bool
$c== :: 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
min :: PushPromise -> PushPromise -> PushPromise
$cmin :: PushPromise -> PushPromise -> PushPromise
max :: PushPromise -> PushPromise -> PushPromise
$cmax :: PushPromise -> PushPromise -> PushPromise
>= :: PushPromise -> PushPromise -> Bool
$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
compare :: PushPromise -> PushPromise -> Ordering
$ccompare :: PushPromise -> PushPromise -> Ordering
$cp1Ord :: Eq 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
showList :: [PushPromise] -> ShowS
$cshowList :: [PushPromise] -> ShowS
show :: PushPromise -> FilePath
$cshow :: PushPromise -> FilePath
showsPrec :: Weight -> PushPromise -> ShowS
$cshowsPrec :: Weight -> PushPromise -> ShowS
Show)
defaultPushPromise :: PushPromise
defaultPushPromise :: PushPromise
defaultPushPromise = ByteString -> FilePath -> ResponseHeaders -> Weight -> PushPromise
PushPromise ByteString
"" FilePath
"" [] Weight
16