{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
module Network.HTTP2.Frame.Types where
import Data.Ix
import Network.Control (WindowSize)
import Text.Read
import qualified Text.Read.Lex as L
import Imports
frameHeaderLength :: Int
= StreamId
9
newtype ErrorCode = ErrorCode Word32 deriving (ErrorCode -> ErrorCode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorCode -> ErrorCode -> Bool
$c/= :: ErrorCode -> ErrorCode -> Bool
== :: ErrorCode -> ErrorCode -> Bool
$c== :: ErrorCode -> ErrorCode -> Bool
Eq, Eq ErrorCode
ErrorCode -> ErrorCode -> Bool
ErrorCode -> ErrorCode -> Ordering
ErrorCode -> ErrorCode -> ErrorCode
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 :: ErrorCode -> ErrorCode -> ErrorCode
$cmin :: ErrorCode -> ErrorCode -> ErrorCode
max :: ErrorCode -> ErrorCode -> ErrorCode
$cmax :: ErrorCode -> ErrorCode -> ErrorCode
>= :: ErrorCode -> ErrorCode -> Bool
$c>= :: ErrorCode -> ErrorCode -> Bool
> :: ErrorCode -> ErrorCode -> Bool
$c> :: ErrorCode -> ErrorCode -> Bool
<= :: ErrorCode -> ErrorCode -> Bool
$c<= :: ErrorCode -> ErrorCode -> Bool
< :: ErrorCode -> ErrorCode -> Bool
$c< :: ErrorCode -> ErrorCode -> Bool
compare :: ErrorCode -> ErrorCode -> Ordering
$ccompare :: ErrorCode -> ErrorCode -> Ordering
Ord, ReadPrec [ErrorCode]
ReadPrec ErrorCode
StreamId -> ReadS ErrorCode
ReadS [ErrorCode]
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorCode]
$creadListPrec :: ReadPrec [ErrorCode]
readPrec :: ReadPrec ErrorCode
$creadPrec :: ReadPrec ErrorCode
readList :: ReadS [ErrorCode]
$creadList :: ReadS [ErrorCode]
readsPrec :: StreamId -> ReadS ErrorCode
$creadsPrec :: StreamId -> ReadS ErrorCode
Read)
fromErrorCode :: ErrorCode -> Word32
fromErrorCode :: ErrorCode -> Word32
fromErrorCode (ErrorCode Word32
w) = Word32
w
toErrorCode :: Word32 -> ErrorCode
toErrorCode :: Word32 -> ErrorCode
toErrorCode = Word32 -> ErrorCode
ErrorCode
pattern NoError :: ErrorCode
pattern $bNoError :: ErrorCode
$mNoError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
NoError = ErrorCode 0x0
pattern ProtocolError :: ErrorCode
pattern $bProtocolError :: ErrorCode
$mProtocolError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
ProtocolError = ErrorCode 0x1
pattern InternalError :: ErrorCode
pattern $bInternalError :: ErrorCode
$mInternalError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
InternalError = ErrorCode 0x2
pattern FlowControlError :: ErrorCode
pattern $bFlowControlError :: ErrorCode
$mFlowControlError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
FlowControlError = ErrorCode 0x3
pattern SettingsTimeout :: ErrorCode
pattern $bSettingsTimeout :: ErrorCode
$mSettingsTimeout :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
SettingsTimeout = ErrorCode 0x4
pattern StreamClosed :: ErrorCode
pattern $bStreamClosed :: ErrorCode
$mStreamClosed :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
StreamClosed = ErrorCode 0x5
pattern FrameSizeError :: ErrorCode
pattern $bFrameSizeError :: ErrorCode
$mFrameSizeError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
FrameSizeError = ErrorCode 0x6
pattern RefusedStream :: ErrorCode
pattern $bRefusedStream :: ErrorCode
$mRefusedStream :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
RefusedStream = ErrorCode 0x7
pattern Cancel :: ErrorCode
pattern $bCancel :: ErrorCode
$mCancel :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
Cancel = ErrorCode 0x8
pattern CompressionError :: ErrorCode
pattern $bCompressionError :: ErrorCode
$mCompressionError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
CompressionError = ErrorCode 0x9
pattern ConnectError :: ErrorCode
pattern $bConnectError :: ErrorCode
$mConnectError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
ConnectError = ErrorCode 0xa
pattern EnhanceYourCalm :: ErrorCode
pattern $bEnhanceYourCalm :: ErrorCode
$mEnhanceYourCalm :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
EnhanceYourCalm = ErrorCode 0xb
pattern InadequateSecurity :: ErrorCode
pattern $bInadequateSecurity :: ErrorCode
$mInadequateSecurity :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
InadequateSecurity = ErrorCode 0xc
pattern HTTP11Required :: ErrorCode
pattern $bHTTP11Required :: ErrorCode
$mHTTP11Required :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
HTTP11Required = ErrorCode 0xd
instance Show ErrorCode where
show :: ErrorCode -> String
show ErrorCode
NoError = String
"NoError"
show ErrorCode
ProtocolError = String
"ProtocolError"
show ErrorCode
InternalError = String
"InternalError"
show ErrorCode
FlowControlError = String
"FlowControlError"
show ErrorCode
SettingsTimeout = String
"SettingsTimeout"
show ErrorCode
StreamClosed = String
"StreamClosed"
show ErrorCode
FrameSizeError = String
"FrameSizeError"
show ErrorCode
RefusedStream = String
"RefusedStream"
show ErrorCode
Cancel = String
"Cancel"
show ErrorCode
CompressionError = String
"CompressionError"
show ErrorCode
ConnectError = String
"ConnectError"
show ErrorCode
EnhanceYourCalm = String
"EnhanceYourCalm"
show ErrorCode
InadequateSecurity = String
"InadequateSecurity"
show ErrorCode
HTTP11Required = String
"HTTP11Required"
show (ErrorCode Word32
x) = String
"ErrorCode " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Word32
x
newtype SettingsKey = SettingsKey Word16 deriving (SettingsKey -> SettingsKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SettingsKey -> SettingsKey -> Bool
$c/= :: SettingsKey -> SettingsKey -> Bool
== :: SettingsKey -> SettingsKey -> Bool
$c== :: SettingsKey -> SettingsKey -> Bool
Eq, Eq SettingsKey
SettingsKey -> SettingsKey -> Bool
SettingsKey -> SettingsKey -> Ordering
SettingsKey -> SettingsKey -> SettingsKey
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 :: SettingsKey -> SettingsKey -> SettingsKey
$cmin :: SettingsKey -> SettingsKey -> SettingsKey
max :: SettingsKey -> SettingsKey -> SettingsKey
$cmax :: SettingsKey -> SettingsKey -> SettingsKey
>= :: SettingsKey -> SettingsKey -> Bool
$c>= :: SettingsKey -> SettingsKey -> Bool
> :: SettingsKey -> SettingsKey -> Bool
$c> :: SettingsKey -> SettingsKey -> Bool
<= :: SettingsKey -> SettingsKey -> Bool
$c<= :: SettingsKey -> SettingsKey -> Bool
< :: SettingsKey -> SettingsKey -> Bool
$c< :: SettingsKey -> SettingsKey -> Bool
compare :: SettingsKey -> SettingsKey -> Ordering
$ccompare :: SettingsKey -> SettingsKey -> Ordering
Ord)
fromSettingsKey :: SettingsKey -> Word16
fromSettingsKey :: SettingsKey -> Word16
fromSettingsKey (SettingsKey Word16
x) = Word16
x
toSettingsKey :: Word16 -> SettingsKey
toSettingsKey :: Word16 -> SettingsKey
toSettingsKey = Word16 -> SettingsKey
SettingsKey
minSettingsKey :: SettingsKey
minSettingsKey :: SettingsKey
minSettingsKey = Word16 -> SettingsKey
SettingsKey Word16
1
maxSettingsKey :: SettingsKey
maxSettingsKey :: SettingsKey
maxSettingsKey = Word16 -> SettingsKey
SettingsKey Word16
6
pattern SettingsHeaderTableSize :: SettingsKey
pattern = SettingsKey 1
pattern SettingsEnablePush :: SettingsKey
pattern $bSettingsEnablePush :: SettingsKey
$mSettingsEnablePush :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
SettingsEnablePush = SettingsKey 2
pattern SettingsMaxConcurrentStreams :: SettingsKey
pattern $bSettingsMaxConcurrentStreams :: SettingsKey
$mSettingsMaxConcurrentStreams :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
SettingsMaxConcurrentStreams = SettingsKey 3
pattern SettingsInitialWindowSize :: SettingsKey
pattern $bSettingsInitialWindowSize :: SettingsKey
$mSettingsInitialWindowSize :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
SettingsInitialWindowSize = SettingsKey 4
pattern SettingsMaxFrameSize :: SettingsKey
pattern $bSettingsMaxFrameSize :: SettingsKey
$mSettingsMaxFrameSize :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
SettingsMaxFrameSize = SettingsKey 5
pattern SettingsMaxHeaderListSize :: SettingsKey
pattern = SettingsKey 6
instance Show SettingsKey where
show :: SettingsKey -> String
show SettingsKey
SettingsHeaderTableSize = String
"SettingsHeaderTableSize"
show SettingsKey
SettingsEnablePush = String
"SettingsEnablePush"
show SettingsKey
SettingsMaxConcurrentStreams = String
"SettingsMaxConcurrentStreams"
show SettingsKey
SettingsInitialWindowSize = String
"SettingsInitialWindowSize"
show SettingsKey
SettingsMaxFrameSize = String
"SettingsMaxFrameSize"
show SettingsKey
SettingsMaxHeaderListSize = String
"SettingsMaxHeaderListSize"
show (SettingsKey Word16
x) = String
"SettingsKey " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Word16
x
instance Read SettingsKey where
readListPrec :: ReadPrec [SettingsKey]
readListPrec = forall a. Read a => ReadPrec [a]
readListPrecDefault
readPrec :: ReadPrec SettingsKey
readPrec = do
Ident String
idnt <- ReadPrec Lexeme
lexP
forall {a}. (Eq a, IsString a) => a -> ReadPrec SettingsKey
readSK String
idnt
where
readSK :: a -> ReadPrec SettingsKey
readSK a
"SettingsHeaderTableSize" = forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsHeaderTableSize
readSK a
"SettingsEnablePush" = forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsEnablePush
readSK a
"SettingsMaxConcurrentStreams" = forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsMaxConcurrentStreams
readSK a
"SettingsInitialWindowSize" = forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsInitialWindowSize
readSK a
"SettingsMaxFrameSize" = forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsMaxFrameSize
readSK a
"SettingsMaxHeaderListSize" = forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsMaxHeaderListSize
readSK a
"SettingsKey" = do
Number Number
ftyp <- ReadPrec Lexeme
lexP
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Word16 -> SettingsKey
SettingsKey forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ forall a. HasCallStack => Maybe a -> a
fromJust forall a b. (a -> b) -> a -> b
$ Number -> Maybe Integer
L.numberToInteger Number
ftyp
readSK a
_ = forall a. HasCallStack => String -> a
error String
"Read for SettingsKey"
type SettingsValue = Int
type SettingsList = [(SettingsKey, SettingsValue)]
defaultWindowSize :: WindowSize
defaultWindowSize :: StreamId
defaultWindowSize = StreamId
65535
maxWindowSize :: WindowSize
maxWindowSize :: StreamId
maxWindowSize = StreamId
2147483647
isWindowOverflow :: WindowSize -> Bool
isWindowOverflow :: StreamId -> Bool
isWindowOverflow StreamId
w = forall a. Bits a => a -> StreamId -> Bool
testBit StreamId
w StreamId
31
recommendedConcurrency :: Int
recommendedConcurrency :: StreamId
recommendedConcurrency = StreamId
100
type Weight = Int
data Priority = Priority
{ Priority -> Bool
exclusive :: Bool
, Priority -> StreamId
streamDependency :: StreamId
, Priority -> StreamId
weight :: Weight
}
deriving (StreamId -> Priority -> ShowS
[Priority] -> ShowS
Priority -> String
forall a.
(StreamId -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Priority] -> ShowS
$cshowList :: [Priority] -> ShowS
show :: Priority -> String
$cshow :: Priority -> String
showsPrec :: StreamId -> Priority -> ShowS
$cshowsPrec :: StreamId -> Priority -> ShowS
Show, ReadPrec [Priority]
ReadPrec Priority
StreamId -> ReadS Priority
ReadS [Priority]
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Priority]
$creadListPrec :: ReadPrec [Priority]
readPrec :: ReadPrec Priority
$creadPrec :: ReadPrec Priority
readList :: ReadS [Priority]
$creadList :: ReadS [Priority]
readsPrec :: StreamId -> ReadS Priority
$creadsPrec :: StreamId -> ReadS Priority
Read, Priority -> Priority -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Priority -> Priority -> Bool
$c/= :: Priority -> Priority -> Bool
== :: Priority -> Priority -> Bool
$c== :: Priority -> Priority -> Bool
Eq)
newtype FrameType = FrameType Word8 deriving (FrameType -> FrameType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FrameType -> FrameType -> Bool
$c/= :: FrameType -> FrameType -> Bool
== :: FrameType -> FrameType -> Bool
$c== :: FrameType -> FrameType -> Bool
Eq, Eq FrameType
FrameType -> FrameType -> Bool
FrameType -> FrameType -> Ordering
FrameType -> FrameType -> FrameType
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 :: FrameType -> FrameType -> FrameType
$cmin :: FrameType -> FrameType -> FrameType
max :: FrameType -> FrameType -> FrameType
$cmax :: FrameType -> FrameType -> FrameType
>= :: FrameType -> FrameType -> Bool
$c>= :: FrameType -> FrameType -> Bool
> :: FrameType -> FrameType -> Bool
$c> :: FrameType -> FrameType -> Bool
<= :: FrameType -> FrameType -> Bool
$c<= :: FrameType -> FrameType -> Bool
< :: FrameType -> FrameType -> Bool
$c< :: FrameType -> FrameType -> Bool
compare :: FrameType -> FrameType -> Ordering
$ccompare :: FrameType -> FrameType -> Ordering
Ord, Ord FrameType
(FrameType, FrameType) -> StreamId
(FrameType, FrameType) -> [FrameType]
(FrameType, FrameType) -> FrameType -> Bool
(FrameType, FrameType) -> FrameType -> StreamId
forall a.
Ord a
-> ((a, a) -> [a])
-> ((a, a) -> a -> StreamId)
-> ((a, a) -> a -> StreamId)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> StreamId)
-> ((a, a) -> StreamId)
-> Ix a
unsafeRangeSize :: (FrameType, FrameType) -> StreamId
$cunsafeRangeSize :: (FrameType, FrameType) -> StreamId
rangeSize :: (FrameType, FrameType) -> StreamId
$crangeSize :: (FrameType, FrameType) -> StreamId
inRange :: (FrameType, FrameType) -> FrameType -> Bool
$cinRange :: (FrameType, FrameType) -> FrameType -> Bool
unsafeIndex :: (FrameType, FrameType) -> FrameType -> StreamId
$cunsafeIndex :: (FrameType, FrameType) -> FrameType -> StreamId
index :: (FrameType, FrameType) -> FrameType -> StreamId
$cindex :: (FrameType, FrameType) -> FrameType -> StreamId
range :: (FrameType, FrameType) -> [FrameType]
$crange :: (FrameType, FrameType) -> [FrameType]
Ix)
fromFrameType :: FrameType -> Word8
fromFrameType :: FrameType -> FrameFlags
fromFrameType (FrameType FrameFlags
x) = FrameFlags
x
toFrameType :: Word8 -> FrameType
toFrameType :: FrameFlags -> FrameType
toFrameType = FrameFlags -> FrameType
FrameType
minFrameType :: FrameType
minFrameType :: FrameType
minFrameType = FrameFlags -> FrameType
FrameType FrameFlags
0
maxFrameType :: FrameType
maxFrameType :: FrameType
maxFrameType = FrameFlags -> FrameType
FrameType FrameFlags
9
pattern FrameData :: FrameType
pattern $bFrameData :: FrameType
$mFrameData :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
FrameData = FrameType 0
pattern FrameHeaders :: FrameType
pattern = FrameType 1
pattern FramePriority :: FrameType
pattern $bFramePriority :: FrameType
$mFramePriority :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
FramePriority = FrameType 2
pattern FrameRSTStream :: FrameType
pattern $bFrameRSTStream :: FrameType
$mFrameRSTStream :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
FrameRSTStream = FrameType 3
pattern FrameSettings :: FrameType
pattern $bFrameSettings :: FrameType
$mFrameSettings :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
FrameSettings = FrameType 4
pattern FramePushPromise :: FrameType
pattern $bFramePushPromise :: FrameType
$mFramePushPromise :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
FramePushPromise = FrameType 5
pattern FramePing :: FrameType
pattern $bFramePing :: FrameType
$mFramePing :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
FramePing = FrameType 6
pattern FrameGoAway :: FrameType
pattern $bFrameGoAway :: FrameType
$mFrameGoAway :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
FrameGoAway = FrameType 7
pattern FrameWindowUpdate :: FrameType
pattern $bFrameWindowUpdate :: FrameType
$mFrameWindowUpdate :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
FrameWindowUpdate = FrameType 8
pattern FrameContinuation :: FrameType
pattern $bFrameContinuation :: FrameType
$mFrameContinuation :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
FrameContinuation = FrameType 9
instance Show FrameType where
show :: FrameType -> String
show FrameType
FrameData = String
"FrameData"
show FrameType
FrameHeaders = String
"FrameHeaders"
show FrameType
FramePriority = String
"FramePriority"
show FrameType
FrameRSTStream = String
"FrameRSTStream"
show FrameType
FrameSettings = String
"FrameSettings"
show FrameType
FramePushPromise = String
"FramePushPromise"
show FrameType
FramePing = String
"FramePing"
show FrameType
FrameGoAway = String
"FrameGoAway"
show FrameType
FrameWindowUpdate = String
"FrameWindowUpdate"
show FrameType
FrameContinuation = String
"FrameContinuation"
show (FrameType FrameFlags
x) = String
"FrameType " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show FrameFlags
x
instance Read FrameType where
readListPrec :: ReadPrec [FrameType]
readListPrec = forall a. Read a => ReadPrec [a]
readListPrecDefault
readPrec :: ReadPrec FrameType
readPrec = do
Ident String
idnt <- ReadPrec Lexeme
lexP
forall {a}. (Eq a, IsString a) => a -> ReadPrec FrameType
readFT String
idnt
where
readFT :: a -> ReadPrec FrameType
readFT a
"FrameData" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameData
readFT a
"FrameHeaders" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameHeaders
readFT a
"FramePriority" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FramePriority
readFT a
"FrameRSTStream" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameRSTStream
readFT a
"FrameSettings" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameSettings
readFT a
"FramePushPromise" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FramePushPromise
readFT a
"FramePing" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FramePing
readFT a
"FrameGoAway" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameGoAway
readFT a
"FrameWindowUpdate" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameWindowUpdate
readFT a
"FrameContinuation" = forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameContinuation
readFT a
"FrameType" = do
Number Number
ftyp <- ReadPrec Lexeme
lexP
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ FrameFlags -> FrameType
FrameType forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ forall a. HasCallStack => Maybe a -> a
fromJust forall a b. (a -> b) -> a -> b
$ Number -> Maybe Integer
L.numberToInteger Number
ftyp
readFT a
_ = forall a. HasCallStack => String -> a
error String
"Read for FrameType"
maxPayloadLength :: Int
maxPayloadLength :: StreamId
maxPayloadLength = StreamId
2 forall a b. (Num a, Integral b) => a -> b -> a
^ (StreamId
24 :: Int) forall a. Num a => a -> a -> a
- StreamId
1
defaultPayloadLength :: Int
defaultPayloadLength :: StreamId
defaultPayloadLength = StreamId
2 forall a b. (Num a, Integral b) => a -> b -> a
^ (StreamId
14 :: Int)
type FrameFlags = Word8
defaultFlags :: FrameFlags
defaultFlags :: FrameFlags
defaultFlags = FrameFlags
0
testEndStream :: FrameFlags -> Bool
testEndStream :: FrameFlags -> Bool
testEndStream FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
0
testAck :: FrameFlags -> Bool
testAck :: FrameFlags -> Bool
testAck FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
0
testEndHeader :: FrameFlags -> Bool
FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
2
testPadded :: FrameFlags -> Bool
testPadded :: FrameFlags -> Bool
testPadded FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
3
testPriority :: FrameFlags -> Bool
testPriority :: FrameFlags -> Bool
testPriority FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
5
setEndStream :: FrameFlags -> FrameFlags
setEndStream :: FrameFlags -> FrameFlags
setEndStream FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
0
setAck :: FrameFlags -> FrameFlags
setAck :: FrameFlags -> FrameFlags
setAck FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
0
setEndHeader :: FrameFlags -> FrameFlags
FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
2
setPadded :: FrameFlags -> FrameFlags
setPadded :: FrameFlags -> FrameFlags
setPadded FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
3
setPriority :: FrameFlags -> FrameFlags
setPriority :: FrameFlags -> FrameFlags
setPriority FrameFlags
x = FrameFlags
x forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
5
type StreamId = Int
isControl :: StreamId -> Bool
isControl :: StreamId -> Bool
isControl StreamId
0 = Bool
True
isControl StreamId
_ = Bool
False
isClientInitiated :: StreamId -> Bool
isClientInitiated :: StreamId -> Bool
isClientInitiated = forall a. Integral a => a -> Bool
odd
isServerInitiated :: StreamId -> Bool
isServerInitiated :: StreamId -> Bool
isServerInitiated StreamId
0 = Bool
False
isServerInitiated StreamId
n = forall a. Integral a => a -> Bool
even StreamId
n
testExclusive :: StreamId -> Bool
testExclusive :: StreamId -> Bool
testExclusive StreamId
n = StreamId
n forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
31
setExclusive :: StreamId -> StreamId
setExclusive :: StreamId -> StreamId
setExclusive StreamId
n = StreamId
n forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
31
clearExclusive :: StreamId -> StreamId
clearExclusive :: StreamId -> StreamId
clearExclusive StreamId
n = StreamId
n forall a. Bits a => a -> StreamId -> a
`clearBit` StreamId
31
type = ByteString
type Padding = ByteString
data Frame = Frame
{ :: FrameHeader
, Frame -> FramePayload
framePayload :: FramePayload
}
deriving (StreamId -> Frame -> ShowS
[Frame] -> ShowS
Frame -> String
forall a.
(StreamId -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Frame] -> ShowS
$cshowList :: [Frame] -> ShowS
show :: Frame -> String
$cshow :: Frame -> String
showsPrec :: StreamId -> Frame -> ShowS
$cshowsPrec :: StreamId -> Frame -> ShowS
Show, ReadPrec [Frame]
ReadPrec Frame
StreamId -> ReadS Frame
ReadS [Frame]
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Frame]
$creadListPrec :: ReadPrec [Frame]
readPrec :: ReadPrec Frame
$creadPrec :: ReadPrec Frame
readList :: ReadS [Frame]
$creadList :: ReadS [Frame]
readsPrec :: StreamId -> ReadS Frame
$creadsPrec :: StreamId -> ReadS Frame
Read, Frame -> Frame -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Frame -> Frame -> Bool
$c/= :: Frame -> Frame -> Bool
== :: Frame -> Frame -> Bool
$c== :: Frame -> Frame -> Bool
Eq)
data =
{ FrameHeader -> StreamId
payloadLength :: Int
, FrameHeader -> FrameFlags
flags :: FrameFlags
, FrameHeader -> StreamId
streamId :: StreamId
}
deriving (StreamId -> FrameHeader -> ShowS
[FrameHeader] -> ShowS
FrameHeader -> String
forall a.
(StreamId -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FrameHeader] -> ShowS
$cshowList :: [FrameHeader] -> ShowS
show :: FrameHeader -> String
$cshow :: FrameHeader -> String
showsPrec :: StreamId -> FrameHeader -> ShowS
$cshowsPrec :: StreamId -> FrameHeader -> ShowS
Show, ReadPrec [FrameHeader]
ReadPrec FrameHeader
StreamId -> ReadS FrameHeader
ReadS [FrameHeader]
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FrameHeader]
$creadListPrec :: ReadPrec [FrameHeader]
readPrec :: ReadPrec FrameHeader
$creadPrec :: ReadPrec FrameHeader
readList :: ReadS [FrameHeader]
$creadList :: ReadS [FrameHeader]
readsPrec :: StreamId -> ReadS FrameHeader
$creadsPrec :: StreamId -> ReadS FrameHeader
Read, FrameHeader -> FrameHeader -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FrameHeader -> FrameHeader -> Bool
$c/= :: FrameHeader -> FrameHeader -> Bool
== :: FrameHeader -> FrameHeader -> Bool
$c== :: FrameHeader -> FrameHeader -> Bool
Eq)
data FramePayload
= DataFrame ByteString
| (Maybe Priority) HeaderBlockFragment
| PriorityFrame Priority
| RSTStreamFrame ErrorCode
| SettingsFrame SettingsList
| PushPromiseFrame StreamId HeaderBlockFragment
| PingFrame ByteString
| GoAwayFrame StreamId ErrorCode ByteString
| WindowUpdateFrame WindowSize
| ContinuationFrame HeaderBlockFragment
| UnknownFrame FrameType ByteString
deriving (StreamId -> FramePayload -> ShowS
[FramePayload] -> ShowS
FramePayload -> String
forall a.
(StreamId -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FramePayload] -> ShowS
$cshowList :: [FramePayload] -> ShowS
show :: FramePayload -> String
$cshow :: FramePayload -> String
showsPrec :: StreamId -> FramePayload -> ShowS
$cshowsPrec :: StreamId -> FramePayload -> ShowS
Show, ReadPrec [FramePayload]
ReadPrec FramePayload
StreamId -> ReadS FramePayload
ReadS [FramePayload]
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FramePayload]
$creadListPrec :: ReadPrec [FramePayload]
readPrec :: ReadPrec FramePayload
$creadPrec :: ReadPrec FramePayload
readList :: ReadS [FramePayload]
$creadList :: ReadS [FramePayload]
readsPrec :: StreamId -> ReadS FramePayload
$creadsPrec :: StreamId -> ReadS FramePayload
Read, FramePayload -> FramePayload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FramePayload -> FramePayload -> Bool
$c/= :: FramePayload -> FramePayload -> Bool
== :: FramePayload -> FramePayload -> Bool
$c== :: FramePayload -> FramePayload -> Bool
Eq)
framePayloadToFrameType :: FramePayload -> FrameType
framePayloadToFrameType :: FramePayload -> FrameType
framePayloadToFrameType DataFrame{} = FrameType
FrameData
framePayloadToFrameType HeadersFrame{} = FrameType
FrameHeaders
framePayloadToFrameType PriorityFrame{} = FrameType
FramePriority
framePayloadToFrameType RSTStreamFrame{} = FrameType
FrameRSTStream
framePayloadToFrameType SettingsFrame{} = FrameType
FrameSettings
framePayloadToFrameType PushPromiseFrame{} = FrameType
FramePushPromise
framePayloadToFrameType PingFrame{} = FrameType
FramePing
framePayloadToFrameType GoAwayFrame{} = FrameType
FrameGoAway
framePayloadToFrameType WindowUpdateFrame{} = FrameType
FrameWindowUpdate
framePayloadToFrameType ContinuationFrame{} = FrameType
FrameContinuation
framePayloadToFrameType (UnknownFrame FrameType
ft ByteString
_) = FrameType
ft
isPaddingDefined :: FramePayload -> Bool
isPaddingDefined :: FramePayload -> Bool
isPaddingDefined DataFrame{} = Bool
True
isPaddingDefined HeadersFrame{} = Bool
True
isPaddingDefined PriorityFrame{} = Bool
False
isPaddingDefined RSTStreamFrame{} = Bool
False
isPaddingDefined SettingsFrame{} = Bool
False
isPaddingDefined PushPromiseFrame{} = Bool
True
isPaddingDefined PingFrame{} = Bool
False
isPaddingDefined GoAwayFrame{} = Bool
False
isPaddingDefined WindowUpdateFrame{} = Bool
False
isPaddingDefined ContinuationFrame{} = Bool
False
isPaddingDefined UnknownFrame{} = Bool
False
type ErrorCodeId = ErrorCode
type SettingsKeyId = SettingsKey
type FrameTypeId = FrameType