-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | HTTP/2.0 library including frames and HPACK -- @package http2 @version 0.9.1 module Network.HTTP2.Internal newtype StreamIdentifier StreamIdentifier :: Int -> StreamIdentifier -- | Framing in HTTP/2. module Network.HTTP2 -- | The data type for HTTP/2 frames. data Frame Frame :: FrameHeader -> FramePayload -> Frame frameHeader :: Frame -> FrameHeader framePayload :: Frame -> FramePayload -- | The data type for HTTP/2 frame headers. data FrameHeader FrameHeader :: Int -> FrameFlags -> StreamIdentifier -> FrameHeader payloadLength :: FrameHeader -> Int flags :: FrameHeader -> FrameFlags streamId :: FrameHeader -> StreamIdentifier -- | The data type for HTTP/2 frame payloads. data FramePayload DataFrame :: ByteString -> FramePayload HeadersFrame :: (Maybe Priority) -> HeaderBlockFragment -> FramePayload PriorityFrame :: Priority -> FramePayload RSTStreamFrame :: ErrorCodeId -> FramePayload SettingsFrame :: SettingsList -> FramePayload PushPromiseFrame :: PromisedStreamId -> HeaderBlockFragment -> FramePayload PingFrame :: ByteString -> FramePayload GoAwayFrame :: LastStreamId -> ErrorCodeId -> ByteString -> FramePayload WindowUpdateFrame :: WindowSizeIncrement -> FramePayload ContinuationFrame :: HeaderBlockFragment -> FramePayload UnknownFrame :: FrameType -> ByteString -> FramePayload -- | Checking if padding is defined in this frame type. isPaddingDefined :: FramePayload -> Bool -- | 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"
--   
encodeFrame :: EncodeInfo -> FramePayload -> ByteString -- | Encoding an HTTP/2 frame to [ByteString]. This is suitable for -- sendMany. encodeFrameChunks :: EncodeInfo -> FramePayload -> [ByteString] -- | Encoding an HTTP/2 frame header. The frame header must be completed. encodeFrameHeader :: FrameTypeId -> FrameHeader -> ByteString -- | Encoding an HTTP/2 frame payload. This returns a complete frame header -- and chunks of payload. encodeFramePayload :: EncodeInfo -> FramePayload -> (FrameHeader, [ByteString]) -- | Auxiliary information for frame encoding. data EncodeInfo EncodeInfo :: FrameFlags -> StreamIdentifier -> Maybe Padding -> EncodeInfo -- | Flags to be set in a frame header encodeFlags :: EncodeInfo -> FrameFlags -- | Stream id to be set in a frame header encodeStreamId :: EncodeInfo -> StreamIdentifier -- | Padding 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. encodePadding :: EncodeInfo -> Maybe Padding -- | A smart builder of EncodeInfo. -- --
--   >>> encodeInfo setAck 0
--   EncodeInfo {encodeFlags = 1, encodeStreamId = StreamIdentifier 0, encodePadding = Nothing}
--   
encodeInfo :: (FrameFlags -> FrameFlags) -> Int -> EncodeInfo -- | 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. decodeFrame :: Settings -> ByteString -> Either HTTP2Error Frame -- | Decoding an HTTP/2 frame header. Must supply 9 bytes. decodeFrameHeader :: ByteString -> (FrameTypeId, FrameHeader) -- | Checking a frame header and reporting an error if any. -- --
--   >>> let stid = toStreamIdentifier 0
--   
--   >>> checkFrameHeader defaultSettings (FrameData,(FrameHeader 100 0 stid))
--   Left (ConnectionError ProtocolError "cannot used in control stream")
--   
checkFrameHeader :: Settings -> (FrameTypeId, FrameHeader) -> Either HTTP2Error (FrameTypeId, FrameHeader) -- | Decoding an HTTP/2 frame payload. decodeFramePayload :: FrameTypeId -> FramePayloadDecoder type FramePayloadDecoder = FrameHeader -> ByteString -> Either HTTP2Error FramePayload decodeDataFrame :: FramePayloadDecoder decodeHeadersFrame :: FramePayloadDecoder decodePriorityFrame :: FramePayloadDecoder decoderstStreamFrame :: FramePayloadDecoder decodeSettingsFrame :: FramePayloadDecoder decodePushPromiseFrame :: FramePayloadDecoder decodePingFrame :: FramePayloadDecoder decodeGoAwayFrame :: FramePayloadDecoder decodeWindowUpdateFrame :: FramePayloadDecoder decodeContinuationFrame :: FramePayloadDecoder data FrameTypeId FrameData :: FrameTypeId FrameHeaders :: FrameTypeId FramePriority :: FrameTypeId FrameRSTStream :: FrameTypeId FrameSettings :: FrameTypeId FramePushPromise :: FrameTypeId FramePing :: FrameTypeId FrameGoAway :: FrameTypeId FrameWindowUpdate :: FrameTypeId FrameContinuation :: FrameTypeId FrameUnknown :: FrameType -> FrameTypeId -- | Getting FrameType from FramePayload. -- --
--   >>> framePayloadToFrameTypeId (DataFrame "body")
--   FrameData
--   
framePayloadToFrameTypeId :: FramePayload -> FrameTypeId type FrameType = Word8 -- |
--   >>> fromFrameTypeId FrameData
--   0
--   
--   >>> fromFrameTypeId FrameContinuation
--   9
--   
--   >>> fromFrameTypeId (FrameUnknown 10)
--   10
--   
fromFrameTypeId :: FrameTypeId -> FrameType -- |
--   >>> toFrameTypeId 0
--   FrameData
--   
--   >>> toFrameTypeId 9
--   FrameContinuation
--   
--   >>> toFrameTypeId 10
--   FrameUnknown 10
--   
toFrameTypeId :: FrameType -> FrameTypeId type HeaderBlockFragment = ByteString type Padding = ByteString data Priority Priority :: Bool -> StreamIdentifier -> Int -> Priority exclusive :: Priority -> Bool streamDependency :: Priority -> StreamIdentifier weight :: Priority -> Int type PromisedStreamId = StreamIdentifier type LastStreamId = StreamIdentifier type StreamDependency = StreamIdentifier type WindowSizeIncrement = Word32 data StreamIdentifier -- |
--   >>> fromStreamIdentifier (toStreamIdentifier 0)
--   0
--   
fromStreamIdentifier :: StreamIdentifier -> Int -- |
--   >>> toStreamIdentifier 0
--   StreamIdentifier 0
--   
toStreamIdentifier :: Int -> StreamIdentifier -- |
--   >>> isControl $ toStreamIdentifier 0
--   True
--   
--   >>> isControl $ toStreamIdentifier 1
--   False
--   
isControl :: StreamIdentifier -> Bool -- |
--   >>> isRequest $ toStreamIdentifier 0
--   False
--   
--   >>> isRequest $ toStreamIdentifier 1
--   True
--   
isRequest :: StreamIdentifier -> Bool -- |
--   >>> isResponse $ toStreamIdentifier 0
--   False
--   
--   >>> isResponse $ toStreamIdentifier 2
--   True
--   
isResponse :: StreamIdentifier -> Bool testExclusive :: Int -> Bool setExclusive :: Int -> Int type FrameFlags = Word8 -- |
--   >>> defaultFlags
--   0
--   
defaultFlags :: FrameFlags -- |
--   >>> testEndStream 0x1
--   True
--   
testEndStream :: FrameFlags -> Bool -- |
--   >>> testAck 0x1
--   True
--   
testAck :: FrameFlags -> Bool -- |
--   >>> testEndHeader 0x4
--   True
--   
testEndHeader :: FrameFlags -> Bool -- |
--   >>> testPadded 0x8
--   True
--   
testPadded :: FrameFlags -> Bool -- |
--   >>> testPriority 0x20
--   True
--   
testPriority :: FrameFlags -> Bool -- |
--   >>> setEndStream 0
--   1
--   
setEndStream :: FrameFlags -> FrameFlags -- |
--   >>> setAck 0
--   1
--   
setAck :: FrameFlags -> FrameFlags -- |
--   >>> setEndHeader 0
--   4
--   
setEndHeader :: FrameFlags -> FrameFlags -- |
--   >>> setPadded 0
--   8
--   
setPadded :: FrameFlags -> FrameFlags -- |
--   >>> setPriority 0
--   32
--   
setPriority :: FrameFlags -> FrameFlags -- | Settings containing raw values. type SettingsList = [(SettingsKeyId, SettingsValue)] type SettingsValue = Int data SettingsKeyId SettingsHeaderTableSize :: SettingsKeyId SettingsEnablePush :: SettingsKeyId SettingsMaxConcurrentStreams :: SettingsKeyId SettingsInitialWindowSize :: SettingsKeyId SettingsMaxFrameSize :: SettingsKeyId SettingsMaxHeaderBlockSize :: SettingsKeyId -- |
--   >>> fromSettingsKeyId SettingsHeaderTableSize
--   1
--   
--   >>> fromSettingsKeyId SettingsMaxHeaderBlockSize
--   6
--   
fromSettingsKeyId :: SettingsKeyId -> Word16 -- |
--   >>> toSettingsKeyId 0
--   Nothing
--   
--   >>> toSettingsKeyId 1
--   Just SettingsHeaderTableSize
--   
--   >>> toSettingsKeyId 6
--   Just SettingsMaxHeaderBlockSize
--   
--   >>> toSettingsKeyId 7
--   Nothing
--   
toSettingsKeyId :: Word16 -> Maybe SettingsKeyId -- | Checking SettingsList and reporting an error if any. -- --
--   >>> checkSettingsList [(SettingsEnablePush,2)]
--   Just (ConnectionError ProtocolError "enable push must be 0 or 1")
--   
checkSettingsList :: SettingsList -> Maybe HTTP2Error -- | Cooked version of settings. This is suitable to be stored in a HTTP/2 -- context. data Settings Settings :: Int -> Bool -> Maybe Int -> Int -> Int -> Maybe Int -> Settings headerTableSize :: Settings -> Int enablePush :: Settings -> Bool maxConcurrentStreams :: Settings -> Maybe Int initialWindowSize :: Settings -> Int maxFrameSize :: Settings -> Int maxHeaderBlockSize :: Settings -> Maybe Int -- | The default settings. -- --
--   >>> defaultSettings
--   Settings {headerTableSize = 4096, enablePush = True, maxConcurrentStreams = Nothing, initialWindowSize = 65535, maxFrameSize = 16384, maxHeaderBlockSize = Nothing}
--   
defaultSettings :: Settings -- | Updating settings. -- --
--   >>> updateSettings defaultSettings [(SettingsEnablePush,0),(SettingsMaxHeaderBlockSize,200)]
--   Settings {headerTableSize = 4096, enablePush = False, maxConcurrentStreams = Nothing, initialWindowSize = 65535, maxFrameSize = 16384, maxHeaderBlockSize = Just 200}
--   
updateSettings :: Settings -> SettingsList -> Settings type ErrorCode = Word32 data ErrorCodeId NoError :: ErrorCodeId ProtocolError :: ErrorCodeId InternalError :: ErrorCodeId FlowControlError :: ErrorCodeId SettingsTimeout :: ErrorCodeId StreamClosed :: ErrorCodeId FrameSizeError :: ErrorCodeId RefusedStream :: ErrorCodeId Cancel :: ErrorCodeId CompressionError :: ErrorCodeId ConnectError :: ErrorCodeId EnhanceYourCalm :: ErrorCodeId InadequateSecurity :: ErrorCodeId HTTP11Required :: ErrorCodeId UnknownErrorCode :: ErrorCode -> ErrorCodeId -- |
--   >>> fromErrorCodeId NoError
--   0
--   
--   >>> fromErrorCodeId InadequateSecurity
--   12
--   
fromErrorCodeId :: ErrorCodeId -> ErrorCode -- |
--   >>> toErrorCodeId 0
--   NoError
--   
--   >>> toErrorCodeId 0xc
--   InadequateSecurity
--   
--   >>> toErrorCodeId 0xe
--   UnknownErrorCode 14
--   
toErrorCodeId :: ErrorCode -> ErrorCodeId -- | The connection error or the stream error. data HTTP2Error ConnectionError :: ErrorCodeId -> ByteString -> HTTP2Error StreamError :: ErrorCodeId -> StreamIdentifier -> HTTP2Error -- | Obtaining ErrorCodeId from HTTP2Error. errorCodeId :: HTTP2Error -> ErrorCodeId -- | The preface of HTTP/2. -- --
--   >>> connectionPreface
--   "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
--   
connectionPreface :: ByteString -- | Length of the preface. -- --
--   >>> connectionPrefaceLength
--   24
--   
connectionPrefaceLength :: Int -- | The length of HTTP/2 frame header. -- --
--   >>> frameHeaderLength
--   9
--   
frameHeaderLength :: Int -- | The maximum length of HTTP/2 payload. -- --
--   >>> maxPayloadLength
--   16384
--   
maxPayloadLength :: Int -- | HPACK: encoding and decoding a header list. module Network.HPACK -- | HPACK encoding, from HeaderList to ByteString. type HPACKEncoding = DynamicTable -> HeaderList -> IO (DynamicTable, ByteString) -- | HPACK decoding, from ByteString to HeaderList. type HPACKDecoding = DynamicTable -> ByteString -> IO (DynamicTable, HeaderList) -- | Converting HeaderList for HTTP request to the low level format. encodeHeader :: EncodeStrategy -> HPACKEncoding -- | Converting the low level format for HTTP request to HeaderList. -- DecodeError would be thrown. decodeHeader :: HPACKDecoding -- | Type for dynamic table. data DynamicTable -- | Creating DynamicTable. The default maxDynamicTableSize is 4096 -- bytes, an array has 128 entries, resulting 1024 bytes in 64bit machine newDynamicTableForEncoding :: Size -> IO DynamicTable -- | Creating DynamicTable. The default maxDynamicTableSize is 4096 -- bytes, an array has 128 entries, resulting 1024 bytes in 64bit machine newDynamicTableForDecoding :: Size -> IO DynamicTable -- | Compression algorithms for HPACK encoding. data CompressionAlgo -- | No compression Naive :: CompressionAlgo -- | Using the static table only Static :: CompressionAlgo -- | Using indices only Linear :: CompressionAlgo -- | Strategy for HPACK encoding. data EncodeStrategy EncodeStrategy :: CompressionAlgo -> Bool -> EncodeStrategy -- | Which compression algorithm is used. compressionAlgo :: EncodeStrategy -> CompressionAlgo -- | Whether or not to use Huffman encoding for strings. useHuffman :: EncodeStrategy -> Bool -- | Default EncodeStrategy. -- --
--   >>> defaultEncodeStrategy
--   EncodeStrategy {compressionAlgo = Linear, useHuffman = True}
--   
defaultEncodeStrategy :: EncodeStrategy -- | Errors for decoder. data DecodeError -- | Index is out of range IndexOverrun :: Index -> DecodeError -- | Eos appears in the middle of huffman string EosInTheMiddle :: DecodeError -- | Non-eos appears in the end of huffman string IllegalEos :: DecodeError -- | Eos of huffman string is more than 7 bits TooLongEos :: DecodeError -- | Encoded string has no length EmptyEncodedString :: DecodeError -- | Header block is empty EmptyBlock :: DecodeError -- | Header list. type HeaderList = [Header] -- | Header. type Header = (HeaderName, HeaderValue) -- | Header name. type HeaderName = ByteString -- | Header value. type HeaderValue = ByteString -- | Size in bytes. type Size = Int -- | Index for table. type Index = Int