The data type for HTTP/2 frames.
Modulehttp2-5.4.8Haskell2010
Network.HTTP2.Frame
Framing in HTTP/2(https://www.rfc-editor.org/rfc/rfc9113).
Contents
Synopsis
- data Frame
- data FrameHeader
- data FramePayload
- type HeaderBlockFragment
- type Padding
- value isPaddingDefined
- value encodeFrame
- value encodeFrameChunks
- value encodeFrameHeader
- value encodeFrameHeaderBuf
- value encodeFramePayload
- data EncodeInfo
- value encodeInfo
- value checkFrameHeader
- value decodeContinuationFrame
- value decodeDataFrame
- value decodeFrame
- value decodeFrameHeader
- value decodeFramePayload
- value decodeGoAwayFrame
- value decodeHeadersFrame
- value decodePingFrame
- value decodePriorityFrame
- value decodePushPromiseFrame
- value decodeRSTStreamFrame
- value decodeSettingsFrame
- value decodeWindowUpdateFrame
- data FrameDecodeError
- type FramePayloadDecoder
- newtype FrameType
- pattern FrameData
- pattern FrameHeaders
- pattern FramePriority
- pattern FrameRSTStream
- pattern FrameSettings
- pattern FramePushPromise
- pattern FramePing
- pattern FrameGoAway
- pattern FrameWindowUpdate
- pattern FrameContinuation
- value fromFrameType
- value toFrameType
- value minFrameType
- value maxFrameType
- value framePayloadToFrameType
- data Priority
- type Weight
- type StreamId
- value isControl
- value isClientInitiated
- value isServerInitiated
- value testExclusive
- value setExclusive
- value clearExclusive
- type FrameFlags
- value defaultFlags
- value testEndStream
- value testAck
- value testEndHeader
- value testPadded
- value testPriority
- value setEndStream
- value setAck
- value setEndHeader
- value setPadded
- value setPriority
- type SettingsList
- newtype SettingsKey
- pattern SettingsTokenHeaderTableSize
- pattern SettingsEnablePush
- pattern SettingsMaxConcurrentStreams
- pattern SettingsInitialWindowSize
- pattern SettingsMaxFrameSize
- pattern SettingsMaxHeaderListSize
- type SettingsValue
- value fromSettingsKey
- value toSettingsKey
- value defaultPayloadLength
- value maxPayloadLength
- type WindowSize
- value defaultWindowSize
- value maxWindowSize
- value isWindowOverflow
- newtype ErrorCode
- pattern NoError
- pattern ProtocolError
- pattern InternalError
- pattern FlowControlError
- pattern SettingsTimeout
- pattern StreamClosed
- pattern FrameSizeError
- pattern RefusedStream
- pattern Cancel
- pattern CompressionError
- pattern ConnectError
- pattern EnhanceYourCalm
- pattern InadequateSecurity
- pattern HTTP11Required
- value fromErrorCode
- value toErrorCode
- value connectionPreface
- value connectionPrefaceLength
- value frameHeaderLength
- value recommendedConcurrency
- type ErrorCodeId
- type SettingsKeyId
- type FrameTypeId
- Packagehttp2-5.4.8
- Exports107
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceFrame.hs
Frame
The data type for HTTP/2 frame headers.
Constructors
Instances3Eq, Read, Show
Eq FrameHeaderDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesRead FrameHeaderDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesShow FrameHeaderDefined in http2-5.4.8 · Network.HTTP2.Frame.Types
The data type for HTTP/2 frame payloads.
Constructors
DataFrame ByteStringHeadersFrame (Maybe Priority) HeaderBlockFragmentPriorityFrame PriorityRSTStreamFrame ErrorCodeSettingsFrame SettingsListPushPromiseFrame StreamId HeaderBlockFragmentPingFrame ByteStringGoAwayFrame StreamId ErrorCode ByteStringWindowUpdateFrame WindowSizeContinuationFrame HeaderBlockFragmentUnknownFrame FrameType ByteString
Instances3Eq, Read, Show
Eq FramePayloadDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesRead FramePayloadDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesShow FramePayloadDefined in http2-5.4.8 · Network.HTTP2.Frame.Types
The type for fragments of a header encoded with HPACK.
The type for padding in payloads.
Checking if padding is defined in this frame type.
isPaddingDefined $ DataFrame ""TrueisPaddingDefined $ PingFrame ""False
Encoding
Encoding an HTTP/2 frame to ByteString. This function is not efficient enough for high performace program because of the concatenation of ByteString.
encodeFrame (encodeInfo id 1) (DataFrame "body")"\NUL\NUL\EOT\NUL\NUL\NUL\NUL\NUL\SOHbody"
Encoding an HTTP/2 frame to [ByteString]. This is suitable for sendMany.
Encoding an HTTP/2 frame header. The frame header must be completed.
Writing an encoded HTTP/2 frame header to the buffer. The length of the buffer must be larger than or equal to 9 bytes.
Encoding an HTTP/2 frame payload. This returns a complete frame header and chunks of payload.
Auxiliary information for frame encoding.
Constructors
EncodeInfoencodeFlags :: FrameFlagsFlags to be set in a frame header
encodeStreamId :: StreamIdStream id to be set in a frame header
encodePadding :: Maybe PaddingPadding if any. In the case where this value is set but the priority flag is not set, this value gets preference over the priority flag. So, if this value is set, the priority flag is also set.
Instances2Read, Show
Read EncodeInfoDefined in http2-5.4.8 · Network.HTTP2.Frame.EncodeShow EncodeInfoDefined in http2-5.4.8 · Network.HTTP2.Frame.Encode
A smart builder of EncodeInfo.
encodeInfo setAck 0EncodeInfo {encodeFlags = 1, encodeStreamId = 0, encodePadding = Nothing}
Checking a frame header and reporting an error if any.
checkFrameHeader (FrameData,(FrameHeader 100 0 0))Left (FrameDecodeError ProtocolError 0 "cannot used in control stream")
Frame payload decoder for CONTINUATION frame.
Frame payload decoder for DATA frame.
Decoding an HTTP/2 frame to ByteString. The second argument must be include the entire of frame. So, this function is not useful for real applications but useful for testing.
Decoding an HTTP/2 frame header. Must supply 9 bytes.
Decoding an HTTP/2 frame payload. This function is considered to return a frame payload decoder according to a frame type.
Frame payload decoder for GOAWAY frame.
Frame payload decoder for HEADERS frame.
Frame payload decoder for PING frame.
Frame payload decoder for PRIORITY frame.
Frame payload decoder for PUSH_PROMISE frame.
Frame payload decoder for RST_STREAM frame.
Frame payload decoder for SETTINGS frame.
Frame payload decoder for WINDOW_UPDATE frame.
Constructors
Instances3Eq, Show, Exception
Eq FrameDecodeErrorDefined in http2-5.4.8 · Network.HTTP2.Frame.DecodeShow FrameDecodeErrorDefined in http2-5.4.8 · Network.HTTP2.Frame.DecodeException FrameDecodeErrorDefined in http2-5.4.8 · Network.HTTP2.Frame.Decode
type FramePayloadDecoder = FrameHeader -> ByteString -> Either FrameDecodeError FramePayloadThe type for frame payload decoder.
Frame type
Instances5Eq, Ord, Read, Show, Ix
Eq FrameTypeDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesOrd FrameTypeDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesRead FrameTypeDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesShow FrameTypeDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesIx FrameTypeDefined in http2-5.4.8 · Network.HTTP2.Frame.Types
Getting FrameType from FramePayload.
framePayloadToFrameType (DataFrame "body")FrameData
Priority
Type for stream priority. Deprecated in RFC 9113 but provided for FrameHeaders.
The type for weight in priority. Its values are from 1 to 256. Deprecated in RFC 9113.
Stream identifier
The type for stream identifier
Checking if the stream identifier for control.
isControl 0TrueisControl 1False
Checking if the stream identifier is from a client.
isClientInitiated 0FalseisClientInitiated 1True
Checking if the stream identifier is from a server.
isServerInitiated 0FalseisServerInitiated 2True
Stream identifier related
Checking if the exclusive flag is set.
Setting the exclusive flag.
Clearing the exclusive flag.
Flags
The type for flags.
The initial value of flags. No flags are set.
defaultFlags0
Checking if the END_STREAM flag is set. >>> testEndStream 0x1 True
Checking if the ACK flag is set. >>> testAck 0x1 True
Checking if the END_HEADERS flag is set.
testEndHeader 0x4True
Checking if the PADDED flag is set.
testPadded 0x8True
Checking if the PRIORITY flag is set.
testPriority 0x20True
Setting the END_STREAM flag.
setEndStream 01
Setting the ACK flag.
setAck 01
Setting the END_HEADERS flag.
setEndHeader 04
Setting the PADDED flag.
setPadded 08
Setting the PRIORITY flag.
setPriority 032
SettingsList
Association list of SETTINGS.
The type for SETTINGS key.
Constructors
Instances4Eq, Ord, Read, Show
Eq SettingsKeyDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesOrd SettingsKeyDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesRead SettingsKeyDefined in http2-5.4.8 · Network.HTTP2.Frame.TypesShow SettingsKeyDefined in http2-5.4.8 · Network.HTTP2.Frame.Types
The type for raw SETTINGS value.
Payload length
The default payload length of HTTP/2 payload.
defaultPayloadLength16384
The maximum payload length of HTTP/2 payload.
maxPayloadLength16777215
Window
Window size.
The default initial window size.
defaultWindowSize65535
The maximum window size.
maxWindowSize2147483647
Checking if a window size exceeds the maximum window size.
isWindowOverflow 10FalseisWindowOverflow maxWindowSizeFalseisWindowOverflow (maxWindowSize + 1)True
Error code
The type for error code. See https://www.rfc-editor.org/rfc/rfc9113#ErrorCodes.
Predefined values
The preface of HTTP/2.
connectionPreface"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
Length of the preface.
connectionPrefaceLength24
The length of HTTP/2 frame header.
frameHeaderLength9
Default concurrency.
recommendedConcurrency100
Deprecated
Deprecated. Use ErrorCode instead
Deprecated. Use SettingsKey instead
Deprecated. Use FrameType instead