-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | HTTP/3 library -- -- HTTP/3 library including frames, QPACK, client and server. @package http3 @version 0.0.21 module Network.HTTP3.Internal -- | Application protocol errors of QUIC. data () => ApplicationProtocolError pattern H3NoError :: ApplicationProtocolError pattern H3GeneralProtocolError :: ApplicationProtocolError pattern H3InternalError :: ApplicationProtocolError pattern H3StreamCreationError :: ApplicationProtocolError pattern H3ClosedCriticalStream :: ApplicationProtocolError pattern H3FrameUnexpected :: ApplicationProtocolError pattern H3FrameError :: ApplicationProtocolError pattern H3ExcessiveLoad :: ApplicationProtocolError pattern H3IdError :: ApplicationProtocolError pattern H3SettingsError :: ApplicationProtocolError pattern H3MissingSettings :: ApplicationProtocolError pattern H3RequestRejected :: ApplicationProtocolError pattern H3RequestCancelled :: ApplicationProtocolError pattern H3RequestIncomplete :: ApplicationProtocolError pattern H3MessageError :: ApplicationProtocolError pattern H3ConnectError :: ApplicationProtocolError pattern H3VersionFallback :: ApplicationProtocolError data H3Frame H3Frame :: H3FrameType -> ByteString -> H3Frame data H3FrameType H3FrameData :: H3FrameType H3FrameHeaders :: H3FrameType H3FrameCancelPush :: H3FrameType H3FrameSettings :: H3FrameType H3FramePushPromise :: H3FrameType H3FrameGoaway :: H3FrameType H3FrameMaxPushId :: H3FrameType H3FrameUnknown :: Int64 -> H3FrameType fromH3FrameType :: H3FrameType -> Int64 toH3FrameType :: Int64 -> H3FrameType encodeH3Frame :: H3Frame -> IO ByteString encodeH3Frames :: [H3Frame] -> [ByteString] decodeH3Frame :: ByteString -> IO H3Frame data IFrame -- | Parsing is about to start IInit :: IFrame -- | Parsing type IType :: QInt -> IFrame -- | Parsing length ILen :: H3FrameType -> QInt -> IFrame -- | Parsing payload IPay :: H3FrameType -> Int -> Int -> [ByteString] -> IFrame -- | Parsing done IDone :: H3FrameType -> ByteString -> ByteString -> IFrame parseH3Frame :: IFrame -> ByteString -> IFrame data QInt QInit :: QInt QMore :: Word8 -> Int -> Int -> [ByteString] -> QInt QDone :: Int64 -> ByteString -> QInt parseQInt :: QInt -> ByteString -> QInt permittedInControlStream :: H3FrameType -> Bool permittedInRequestStream :: H3FrameType -> Bool permittedInPushStream :: H3FrameType -> Bool module Network.QPACK.Internal -- | Application protocol errors of QUIC. data () => ApplicationProtocolError pattern QpackDecompressionFailed :: ApplicationProtocolError pattern QpackEncoderStreamError :: ApplicationProtocolError pattern QpackDecoderStreamError :: ApplicationProtocolError data DecodeError IllegalStaticIndex :: DecodeError IllegalInsertCount :: DecodeError data EncoderInstructionError EncoderInstructionError :: EncoderInstructionError data DecoderInstructionError DecoderInstructionError :: DecoderInstructionError -- | Dynamic table for QPACK. data DynamicTable -- | Creating DynamicTable for encoding. newDynamicTableForEncoding :: Size -> IO DynamicTable -- | Creating DynamicTable for decoding. newDynamicTableForDecoding :: Size -> Size -> IO DynamicTable getMaxNumOfEntries :: DynamicTable -> IO Int setBasePointToInsersionPoint :: DynamicTable -> IO () getBasePoint :: DynamicTable -> IO BasePoint getInsertionPoint :: DynamicTable -> IO InsertionPoint getInsertionPointSTM :: DynamicTable -> STM InsertionPoint checkInsertionPoint :: DynamicTable -> InsertionPoint -> IO () getLargestReference :: DynamicTable -> IO InsertionPoint updateLargestReference :: DynamicTable -> AbsoluteIndex -> IO () insertEntryToEncoder :: Entry -> DynamicTable -> IO AbsoluteIndex insertEntryToDecoder :: Entry -> DynamicTable -> STM () toIndexedEntry :: DynamicTable -> HIndex -> STM Entry data RevIndex data RevResult N :: RevResult K :: HIndex -> RevResult KV :: HIndex -> RevResult getRevIndex :: DynamicTable -> RevIndex lookupRevIndex :: Token -> FieldValue -> RevIndex -> IO RevResult getHuffmanDecoder :: DynamicTable -> HuffmanDecoder setDebugQPACK :: DynamicTable -> IO () getDebugQPACK :: DynamicTable -> IO Bool qpackDebug :: DynamicTable -> IO () -> IO () data HIndex SIndex :: AbsoluteIndex -> HIndex DIndex :: AbsoluteIndex -> HIndex data EncoderInstruction SetDynamicTableCapacity :: Int -> EncoderInstruction InsertWithNameReference :: InsIndex -> FieldValue -> EncoderInstruction InsertWithoutNameReference :: Token -> FieldValue -> EncoderInstruction Duplicate :: InsRelativeIndex -> EncoderInstruction type InsIndex = Either AbsoluteIndex InsRelativeIndex encodeEncoderInstructions :: [EncoderInstruction] -> Bool -> IO ByteString decodeEncoderInstructions :: HuffmanDecoder -> ByteString -> IO ([EncoderInstruction], ByteString) decodeEncoderInstructions' :: ByteString -> IO ([EncoderInstruction], ByteString) encodeEI :: WriteBuffer -> Bool -> EncoderInstruction -> IO () decodeEI :: HuffmanDecoder -> ReadBuffer -> IO EncoderInstruction data DecoderInstruction SectionAcknowledgement :: Int -> DecoderInstruction StreamCancellation :: Int -> DecoderInstruction InsertCountIncrement :: Int -> DecoderInstruction encodeDecoderInstructions :: [DecoderInstruction] -> IO ByteString decodeDecoderInstructions :: ByteString -> IO ([DecoderInstruction], ByteString) encodeDI :: WriteBuffer -> DecoderInstruction -> IO () decodeDI :: ReadBuffer -> IO DecoderInstruction -- | Encoding headers with QPACK. Header block with prefix and instructions -- are returned. 2048, 32, and 2048 bytes-buffers are temporally -- allocated for header block, prefix and encoder instructions. encodeHeader :: EncodeStrategy -> DynamicTable -> [Header] -> IO (EncodedFieldSection, EncodedEncoderInstruction) -- | Converting TokenHeaderList to the QPACK format. encodeTokenHeader :: WriteBuffer -> WriteBuffer -> EncodeStrategy -> DynamicTable -> TokenHeaderList -> IO TokenHeaderList -- | Encoded field section including prefix. type EncodedFieldSection = ByteString -- | Encoded encoder instruction. type EncodedEncoderInstruction = ByteString -- | 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 -- | Compression algorithms for HPACK encoding. data () => CompressionAlgo -- | No compression Naive :: CompressionAlgo -- | Using indices in the static table only Static :: CompressionAlgo -- | Using indices Linear :: CompressionAlgo -- | Encoding the prefix part of header block. This should be used after -- encodeTokenHeader. encodePrefix :: WriteBuffer -> DynamicTable -> IO () decodeTokenHeader :: DynamicTable -> ReadBuffer -> IO TokenHeaderTable decodeTokenHeaderS :: DynamicTable -> ReadBuffer -> IO [Header] -- | Encoding the prefix part of header block. This should be used after -- encodeTokenHeader. encodePrefix :: WriteBuffer -> DynamicTable -> IO () -- | Decoding the prefix part of header block. decodePrefix :: ReadBuffer -> DynamicTable -> IO (InsertionPoint, BasePoint) -- |
--   >>> encodeRequiredInsertCount 3 9
--   4
--   
--   >>> encodeRequiredInsertCount 128 1000
--   233
--   
encodeRequiredInsertCount :: Int -> InsertionPoint -> Int -- | for decoder -- --
--   >>> decodeRequiredInsertCount 3 10 4
--   InsertionPoint 9
--   
--   >>> decodeRequiredInsertCount 128 990 233
--   InsertionPoint 1000
--   
decodeRequiredInsertCount :: Int -> InsertionPoint -> Int -> InsertionPoint -- |
--   >>> encodeBase 6 9
--   (False,3)
--   
--   >>> encodeBase 9 6
--   (True,2)
--   
encodeBase :: InsertionPoint -> BasePoint -> (Bool, Int) -- |
--   >>> decodeBase 6 False 3
--   BasePoint 9
--   
--   >>> decodeBase 9 True 2
--   BasePoint 6
--   
decodeBase :: InsertionPoint -> Bool -> Int -> BasePoint newtype AbsoluteIndex AbsoluteIndex :: Int -> AbsoluteIndex newtype InsRelativeIndex InsRelativeIndex :: Int -> InsRelativeIndex newtype HBRelativeIndex HBRelativeIndex :: Int -> HBRelativeIndex newtype PostBaseIndex PostBaseIndex :: Int -> PostBaseIndex newtype InsertionPoint InsertionPoint :: Int -> InsertionPoint newtype BasePoint BasePoint :: Int -> BasePoint data HIndex SIndex :: AbsoluteIndex -> HIndex DIndex :: AbsoluteIndex -> HIndex -- |
--   >>> toInsRelativeIndex 99 100
--   InsRelativeIndex 0
--   
--   >>> toInsRelativeIndex 98 100
--   InsRelativeIndex 1
--   
--   >>> toInsRelativeIndex 97 100
--   InsRelativeIndex 2
--   
--   >>> toInsRelativeIndex 96 100
--   InsRelativeIndex 3
--   
toInsRelativeIndex :: AbsoluteIndex -> InsertionPoint -> InsRelativeIndex -- |
--   >>> fromInsRelativeIndex 0 100
--   AbsoluteIndex 99
--   
--   >>> fromInsRelativeIndex 1 100
--   AbsoluteIndex 98
--   
--   >>> fromInsRelativeIndex 2 100
--   AbsoluteIndex 97
--   
--   >>> fromInsRelativeIndex 3 100
--   AbsoluteIndex 96
--   
fromInsRelativeIndex :: InsRelativeIndex -> InsertionPoint -> AbsoluteIndex -- |
--   >>> toHBRelativeIndex 96 98
--   HBRelativeIndex 1
--   
--   >>> toHBRelativeIndex 97 98
--   HBRelativeIndex 0
--   
toHBRelativeIndex :: AbsoluteIndex -> BasePoint -> HBRelativeIndex -- |
--   >>> fromHBRelativeIndex 1 98
--   AbsoluteIndex 96
--   
--   >>> fromHBRelativeIndex 0 98
--   AbsoluteIndex 97
--   
fromHBRelativeIndex :: HBRelativeIndex -> BasePoint -> AbsoluteIndex -- |
--   >>> toPostBaseIndex 98 98
--   PostBaseIndex 0
--   
--   >>> toPostBaseIndex 99 98
--   PostBaseIndex 1
--   
toPostBaseIndex :: AbsoluteIndex -> BasePoint -> PostBaseIndex -- |
--   >>> fromPostBaseIndex 0 98
--   AbsoluteIndex 98
--   
--   >>> fromPostBaseIndex 1 98
--   AbsoluteIndex 99
--   
fromPostBaseIndex :: PostBaseIndex -> BasePoint -> AbsoluteIndex type Setter = Word8 -> Word8 set1 :: Setter set01 :: Setter set10 :: Setter set11 :: Setter set001 :: Setter set0001 :: Setter set0100 :: Setter set0101 :: Setter set0010 :: Setter set00001 :: Setter set0 :: Setter set00 :: Setter set000 :: Setter set0000 :: Setter -- | Thread-safe QPACK encoder/decoder. module Network.QPACK -- | Configuration for QPACK encoder. data QEncoderConfig QEncoderConfig :: Size -> Size -> Size -> Size -> EncodeStrategy -> QEncoderConfig [ecDynamicTableSize] :: QEncoderConfig -> Size [ecHeaderBlockBufferSize] :: QEncoderConfig -> Size [ecPrefixBufferSize] :: QEncoderConfig -> Size [ecInstructionBufferSize] :: QEncoderConfig -> Size [encStrategy] :: QEncoderConfig -> EncodeStrategy -- | Default configuration for QPACK encoder. -- --
--   >>> defaultQEncoderConfig
--   QEncoderConfig {ecDynamicTableSize = 4096, ecHeaderBlockBufferSize = 4096, ecPrefixBufferSize = 128, ecInstructionBufferSize = 4096, encStrategy = EncodeStrategy {compressionAlgo = Static, useHuffman = True}}
--   
defaultQEncoderConfig :: QEncoderConfig -- | QPACK encoder. type QEncoder = TokenHeaderList -> IO (EncodedFieldSection, EncodedEncoderInstruction) -- | Creating a new QPACK encoder. newQEncoder :: QEncoderConfig -> IO (QEncoder, DecoderInstructionHandler) -- | Configuration for QPACK decoder. data QDecoderConfig QDecoderConfig :: Size -> Size -> QDecoderConfig [dcDynamicTableSize] :: QDecoderConfig -> Size [dcHuffmanBufferSize] :: QDecoderConfig -> Size -- | Default configuration for QPACK decoder. -- --
--   >>> defaultQDecoderConfig
--   QDecoderConfig {dcDynamicTableSize = 4096, dcHuffmanBufferSize = 4096}
--   
defaultQDecoderConfig :: QDecoderConfig -- | QPACK decoder. type QDecoder = EncodedFieldSection -> IO TokenHeaderTable -- | Creating a new QPACK decoder. newQDecoder :: QDecoderConfig -> IO (QDecoder, EncoderInstructionHandler) -- | QPACK simple decoder. type QDecoderS = EncodedFieldSection -> IO [Header] -- | Creating a new simple QPACK decoder. newQDecoderS :: QDecoderConfig -> Bool -> IO (QDecoderS, EncoderInstructionHandlerS) -- | Encoded encoder instruction. type EncodedEncoderInstruction = ByteString -- | Encoder instruction handler. type EncoderInstructionHandler = (Int -> IO EncodedEncoderInstruction) -> IO () -- | Simple encoder instruction handler. type EncoderInstructionHandlerS = EncodedEncoderInstruction -> IO () -- | Encoded decoder instruction. type EncodedDecoderInstruction = ByteString -- | Decoder instruction handler. type DecoderInstructionHandler = (Int -> IO EncodedDecoderInstruction) -> IO () -- | A type to integrating handlers. type InstructionHandler = (Int -> IO ByteString) -> IO () -- | Size in bytes. type Size = Int -- | 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 -- | Compression algorithms for HPACK encoding. data () => CompressionAlgo -- | No compression Naive :: CompressionAlgo -- | Using indices in the static table only Static :: CompressionAlgo -- | Using indices Linear :: CompressionAlgo -- | A pair of token list and value table. type TokenHeaderTable = (TokenHeaderList, ValueTable) -- | TokenBased header list. type TokenHeaderList = [TokenHeader] -- | An array to get FieldValue quickly. getHeaderValue -- should be used. Internally, the key is tokenIx. type ValueTable = Array Int Maybe FieldValue -- | A full HTTP header field with the name and value separated. -- -- E.g. "Content-Length: 28" parsed into a Header would -- turn into ("Content-Length", "28") type Header = (HeaderName, ByteString) -- | Accessing FieldValue with Token. getFieldValue :: Token -> ValueTable -> Maybe FieldValue -- | Converting a header list of the http-types style to -- TokenHeaderList and ValueTable. toTokenHeaderTable :: [Header] -> IO TokenHeaderTable -- | Retrieve the original string-like value. original :: CI s -> s -- | Retrieve the case folded string-like value. (Also see -- foldCase). foldedCase :: CI s -> s -- | Make the given string-like value case insensitive. mk :: FoldCase s => s -> CI s instance GHC.Show.Show Network.QPACK.QEncoderConfig instance GHC.Show.Show Network.QPACK.QDecoderConfig -- | A server library for HTTP/3. module Network.HTTP3.Server -- | Running an HTTP/3 server. run :: Connection -> Config -> Server -> IO () -- | Configuration for HTTP/3 or HQ. data Config Config :: Hooks -> PositionReadMaker -> Manager -> Config [confHooks] :: Config -> Hooks [confPositionReadMaker] :: Config -> PositionReadMaker [confTimeoutManager] :: Config -> Manager -- | Allocating a simple configuration with a handle-based position reader -- and a locally allocated timeout manager. allocSimpleConfig :: IO Config -- | Freeing a simple configration. freeSimpleConfig :: Config -> IO () -- | Hooks mainly for error testing. data Hooks Hooks :: ([H3Frame] -> [H3Frame]) -> ([H3Frame] -> [H3Frame]) -> (Stream -> IO ()) -> (Stream -> IO ()) -> (Stream -> IO ()) -> Hooks [onControlFrameCreated] :: Hooks -> [H3Frame] -> [H3Frame] [onHeadersFrameCreated] :: Hooks -> [H3Frame] -> [H3Frame] [onControlStreamCreated] :: Hooks -> Stream -> IO () [onEncoderStreamCreated] :: Hooks -> Stream -> IO () [onDecoderStreamCreated] :: Hooks -> Stream -> IO () -- | Default hooks. defaultHooks :: Hooks runIO :: Connection -> Config -> (ServerIO Stream -> IO (IO ())) -> IO () data () => ServerIO a ServerIO :: SockAddr -> SockAddr -> IO (a, Request) -> (a -> Response -> IO ()) -> ServerIO a [sioMySockAddr] :: ServerIO a -> SockAddr [sioPeerSockAddr] :: ServerIO a -> SockAddr [sioReadRequest] :: ServerIO a -> IO (a, Request) -- | Response MUST be created with responseBuilder. Others -- are not supported. [sioWriteResponse] :: ServerIO a -> a -> Response -> IO () -- | A server library for HTTP/0.9. module Network.HQ.Server -- | Running an HQ server. run :: Connection -> Config -> Server -> IO () -- | Configuration for HTTP/3 or HQ. data Config Config :: Hooks -> PositionReadMaker -> Manager -> Config [confHooks] :: Config -> Hooks [confPositionReadMaker] :: Config -> PositionReadMaker [confTimeoutManager] :: Config -> Manager -- | Allocating a simple configuration with a handle-based position reader -- and a locally allocated timeout manager. allocSimpleConfig :: IO Config -- | Freeing a simple configration. freeSimpleConfig :: Config -> IO () -- | Server type. Server takes a HTTP request, should generate a HTTP -- response and push promises, then should give them to the sending -- function. The sending function would throw exceptions so that they can -- be logged. -- -- The sending function must only be called once. type Server = Request -> Aux -> Response -> [PushPromise] -> IO () -> IO () -- | Request from client. data () => Request -- | Getting the path from a request. requestPath :: Request -> Maybe Path -- | Response from server. data () => Response -- | Creating response without body. responseNoBody :: Status -> ResponseHeaders -> Response -- | Creating response with file. responseFile :: Status -> ResponseHeaders -> FileSpec -> Response -- | Creating response with streaming. responseStreaming :: Status -> ResponseHeaders -> ((Builder -> IO ()) -> IO () -> IO ()) -> Response -- | Creating response with builder. responseBuilder :: Status -> ResponseHeaders -> Builder -> Response -- | A client library for HTTP/3. module Network.HTTP3.Client -- | Running an HTTP/3 client. run :: Connection -> ClientConfig -> Config -> Client a -> IO a -- | Configuration for HTTP/3 or HQ client. For HQ, authority is not -- used and an server's IP address is used in Request. data ClientConfig ClientConfig :: Scheme -> Authority -> ClientConfig [scheme] :: ClientConfig -> Scheme [authority] :: ClientConfig -> Authority -- | Configuration for HTTP/3 or HQ. data Config Config :: Hooks -> PositionReadMaker -> Manager -> Config [confHooks] :: Config -> Hooks [confPositionReadMaker] :: Config -> PositionReadMaker [confTimeoutManager] :: Config -> Manager -- | Allocating a simple configuration with a handle-based position reader -- and a locally allocated timeout manager. allocSimpleConfig :: IO Config -- | Freeing a simple configration. freeSimpleConfig :: Config -> IO () -- | Hooks mainly for error testing. data Hooks Hooks :: ([H3Frame] -> [H3Frame]) -> ([H3Frame] -> [H3Frame]) -> (Stream -> IO ()) -> (Stream -> IO ()) -> (Stream -> IO ()) -> Hooks [onControlFrameCreated] :: Hooks -> [H3Frame] -> [H3Frame] [onHeadersFrameCreated] :: Hooks -> [H3Frame] -> [H3Frame] [onControlStreamCreated] :: Hooks -> Stream -> IO () [onEncoderStreamCreated] :: Hooks -> Stream -> IO () [onDecoderStreamCreated] :: Hooks -> Stream -> IO () -- | Default hooks. defaultHooks :: Hooks -- | A client library for HTTP/0.9. module Network.HQ.Client -- | Running an HQ client. run :: Connection -> ClientConfig -> Config -> Client a -> IO a -- | Configuration for HTTP/3 or HQ client. For HQ, authority is not -- used and an server's IP address is used in Request. data ClientConfig ClientConfig :: Scheme -> Authority -> ClientConfig [scheme] :: ClientConfig -> Scheme [authority] :: ClientConfig -> Authority -- | Configuration for HTTP/3 or HQ. data Config Config :: Hooks -> PositionReadMaker -> Manager -> Config [confHooks] :: Config -> Hooks [confPositionReadMaker] :: Config -> PositionReadMaker [confTimeoutManager] :: Config -> Manager -- | Allocating a simple configuration with a handle-based position reader -- and a locally allocated timeout manager. allocSimpleConfig :: IO Config -- | Freeing a simple configration. freeSimpleConfig :: Config -> IO () -- | "http" or "https". type Scheme = ByteString -- | Authority. type Authority = String -- | Client type. type Client a = SendRequest -> Aux -> IO a -- | Request from client. data () => Request -- | Creating request without body. requestNoBody :: Method -> Path -> RequestHeaders -> Request -- | Response from server. data () => Response -- | Reading a chunk of the response body. An empty ByteString -- returned when finished. getResponseBodyChunk :: Response -> IO ByteString