-- 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.4 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 -> HeaderValue -> 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 -> HeaderValue -> EncoderInstruction InsertWithoutNameReference :: Token -> HeaderValue -> 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 -> HeaderList -> 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 HeaderTable decodeTokenHeaderS :: DynamicTable -> ReadBuffer -> IO HeaderList -- | 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 HeaderTable -- | Creating a new QPACK decoder. newQDecoder :: QDecoderConfig -> IO (QDecoder, EncoderInstructionHandler) -- | QPACK simple decoder. type QDecoderS = EncodedFieldSection -> IO HeaderList -- | 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 HeaderTable = (TokenHeaderList, ValueTable) -- | TokenBased header list. type TokenHeaderList = [TokenHeader] -- | An array to get HeaderValue quickly. getHeaderValue -- should be used. Internally, the key is tokenIx. type ValueTable = Array Int Maybe HeaderValue -- | Header. type Header = (HeaderName, HeaderValue) -- | Header list. type HeaderList = [Header] -- | Accessing HeaderValue with Token. getHeaderValue :: Token -> ValueTable -> Maybe HeaderValue -- | Converting a header list of the http-types style to -- TokenHeaderList and ValueTable. toHeaderTable :: [(CI HeaderName, HeaderValue)] -> IO HeaderTable -- | 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 -- | 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. type Server = Request -> Aux -> Response -> [PushPromise] -> IO () -> IO () -- | Request from client. data Request -- | Getting the method from a request. requestMethod :: Request -> Maybe Method -- | Getting the path from a request. requestPath :: Request -> Maybe Path -- | Getting the authority from a request. requestAuthority :: Request -> Maybe Authority -- | Getting the scheme from a request. requestScheme :: Request -> Maybe Scheme -- | Getting the headers from a request. requestHeaders :: Request -> HeaderTable -- | Getting the body size from a request. requestBodySize :: Request -> Maybe Int -- | Reading a chunk of the request body. An empty ByteString -- returned when finished. getRequestBodyChunk :: Request -> IO ByteString -- | Reading request trailers. This function must be called after -- getRequestBodyChunk returns an empty. getRequestTrailers :: Request -> IO (Maybe HeaderTable) -- | Additional information. data Aux -- | Time handle for the worker processing this request and response. auxTimeHandle :: Aux -> Handle -- | 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 -- | Getter for response body size. This value is available for file body. responseBodySize :: Response -> Maybe Int -- | Trailers maker. A chunks of the response body is passed with -- Just. The maker should update internal state with the -- ByteString and return the next trailers maker. When response -- body reaches its end, Nothing is passed and the maker should -- generate trailers. An example: -- --
--   {-# LANGUAGE BangPatterns #-}
--   import Data.ByteString (ByteString)
--   import qualified Data.ByteString.Char8 as C8
--   import Crypto.Hash (Context, SHA1) -- cryptonite
--   import qualified Crypto.Hash as CH
--   
--   -- Strictness is important for Context.
--   trailersMaker :: Context SHA1 -> Maybe ByteString -> IO NextTrailersMaker
--   trailersMaker ctx Nothing = return $ Trailers [("X-SHA1", sha1)]
--     where
--       !sha1 = C8.pack $ show $ CH.hashFinalize ctx
--   trailersMaker ctx (Just bs) = return $ NextTrailersMaker $ trailersMaker ctx'
--     where
--       !ctx' = CH.hashUpdate ctx bs
--   
-- -- Usage example: -- --
--   let h2rsp = responseFile ...
--       maker = trailersMaker (CH.hashInit :: Context SHA1)
--       h2rsp' = setResponseTrailersMaker h2rsp maker
--   
type TrailersMaker = Maybe ByteString -> IO NextTrailersMaker -- | Either the next trailers maker or final trailers. data NextTrailersMaker NextTrailersMaker :: TrailersMaker -> NextTrailersMaker Trailers :: [Header] -> NextTrailersMaker -- | TrailersMake to create no trailers. defaultTrailersMaker :: TrailersMaker -- | Setting TrailersMaker to Response. setResponseTrailersMaker :: Response -> TrailersMaker -> Response -- | HTTP/2 push promise or sever push. Pseudo REQUEST headers in push -- promise is automatically generated. Then, a server push is sent -- according to promiseResponse. data PushPromise -- | Creating push promise. The third argument is traditional, not used. pushPromise :: ByteString -> Response -> Weight -> PushPromise -- | Accessor for a URL path in a push promise (a virtual request from a -- server). E.g. "/style/default.css". promiseRequestPath :: PushPromise -> ByteString -- | Accessor for response actually pushed from a server. promiseResponse :: PushPromise -> Response -- | Path. type Path = ByteString -- | Authority. type Authority = ByteString -- | "http" or "https". type Scheme = ByteString -- | File specification. data FileSpec FileSpec :: FilePath -> FileOffset -> ByteCount -> FileSpec -- | Offset for file. type FileOffset = Int64 -- | How many bytes to read type ByteCount = Int64 -- | Naive implementation for readN. defaultReadN :: Socket -> IORef (Maybe ByteString) -> Int -> IO ByteString -- | Making a position read and its closer. type PositionReadMaker = FilePath -> IO (PositionRead, Sentinel) -- | Position read for files. type PositionRead = FileOffset -> ByteCount -> Buffer -> IO ByteCount -- | Manipulating a file resource. data Sentinel -- | Closing a file resource. Its refresher is automatiaclly generated by -- the internal timer. Closer :: IO () -> Sentinel -- | Refreshing a file resource while reading. Closing the file must be -- done by its own timer or something. Refresher :: IO () -> Sentinel -- | Position read based on Handle. defaultPositionReadMaker :: PositionReadMaker -- | 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. 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 -- | "http" or "https". type Scheme = ByteString -- | Authority. type Authority = ByteString -- | Client type. type Client a = Request -> Response -> IO a -> IO a -> IO a -- | Request from client. data Request -- | Creating request without body. requestNoBody :: Method -> Path -> RequestHeaders -> Request -- | Creating request with file. requestFile :: Method -> Path -> RequestHeaders -> FileSpec -> Request -- | Creating request with streaming. requestStreaming :: Method -> Path -> RequestHeaders -> ((Builder -> IO ()) -> IO () -> IO ()) -> Request -- | Creating request with builder. requestBuilder :: Method -> Path -> RequestHeaders -> Builder -> Request -- | Trailers maker. A chunks of the response body is passed with -- Just. The maker should update internal state with the -- ByteString and return the next trailers maker. When response -- body reaches its end, Nothing is passed and the maker should -- generate trailers. An example: -- --
--   {-# LANGUAGE BangPatterns #-}
--   import Data.ByteString (ByteString)
--   import qualified Data.ByteString.Char8 as C8
--   import Crypto.Hash (Context, SHA1) -- cryptonite
--   import qualified Crypto.Hash as CH
--   
--   -- Strictness is important for Context.
--   trailersMaker :: Context SHA1 -> Maybe ByteString -> IO NextTrailersMaker
--   trailersMaker ctx Nothing = return $ Trailers [("X-SHA1", sha1)]
--     where
--       !sha1 = C8.pack $ show $ CH.hashFinalize ctx
--   trailersMaker ctx (Just bs) = return $ NextTrailersMaker $ trailersMaker ctx'
--     where
--       !ctx' = CH.hashUpdate ctx bs
--   
-- -- Usage example: -- --
--   let h2rsp = responseFile ...
--       maker = trailersMaker (CH.hashInit :: Context SHA1)
--       h2rsp' = setResponseTrailersMaker h2rsp maker
--   
type TrailersMaker = Maybe ByteString -> IO NextTrailersMaker -- | Either the next trailers maker or final trailers. data NextTrailersMaker NextTrailersMaker :: TrailersMaker -> NextTrailersMaker Trailers :: [Header] -> NextTrailersMaker -- | TrailersMake to create no trailers. defaultTrailersMaker :: TrailersMaker -- | Setting TrailersMaker to Response. setRequestTrailersMaker :: Request -> TrailersMaker -> Request -- | Response from server. data Response -- | Getting the status of a response. responseStatus :: Response -> Maybe Status -- | Getting the headers from a response. responseHeaders :: Response -> HeaderTable -- | Getting the body size from a response. responseBodySize :: Response -> Maybe Int -- | Reading a chunk of the response body. An empty ByteString -- returned when finished. getResponseBodyChunk :: Response -> IO ByteString -- | Reading response trailers. This function must be called after -- getResponseBodyChunk returns an empty. getResponseTrailers :: Response -> IO (Maybe HeaderTable) -- | HTTP method (flat string type). type Method = ByteString -- | Path. type Path = ByteString -- | File specification. data FileSpec FileSpec :: FilePath -> FileOffset -> ByteCount -> FileSpec -- | Offset for file. type FileOffset = Int64 -- | How many bytes to read type ByteCount = Int64 -- | Naive implementation for readN. defaultReadN :: Socket -> IORef (Maybe ByteString) -> Int -> IO ByteString -- | Making a position read and its closer. type PositionReadMaker = FilePath -> IO (PositionRead, Sentinel) -- | Position read for files. type PositionRead = FileOffset -> ByteCount -> Buffer -> IO ByteCount -- | Manipulating a file resource. data Sentinel -- | Closing a file resource. Its refresher is automatiaclly generated by -- the internal timer. Closer :: IO () -> Sentinel -- | Refreshing a file resource while reading. Closing the file must be -- done by its own timer or something. Refresher :: IO () -> Sentinel -- | Position read based on Handle. defaultPositionReadMaker :: PositionReadMaker -- | 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 = ByteString -- | Client type. type Client a = Request -> Response -> IO a -> IO a -> 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