http2-4.1.0: HTTP/2 library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.HTTP2.Internal

Synopsis

File

type FileOffset = Int64 Source #

Offset for file.

type ByteCount = Int64 Source #

How many bytes to read

type PositionRead = FileOffset -> ByteCount -> Buffer -> IO ByteCount Source #

Position read for files.

data Sentinel Source #

Manipulating a file resource.

Constructors

Closer (IO ())

Closing a file resource. Its refresher is automatiaclly generated by the internal timer.

Refresher (IO ())

Refreshing a file resource while reading. Closing the file must be done by its own timer or something.

type PositionReadMaker = FilePath -> IO (PositionRead, Sentinel) Source #

Making a position read and its closer.

Types

type Scheme = ByteString Source #

"http" or "https".

type Authority = ByteString Source #

Authority.

type Path = ByteString Source #

Path.

Request and response

data InpObj Source #

Input object

Constructors

InpObj 

Fields

Instances

Instances details
Show InpObj Source # 
Instance details

Defined in Network.HTTP2.Arch.Types

data OutObj Source #

Output object

Constructors

OutObj 

Fields

Instances

Instances details
Show OutObj Source # 
Instance details

Defined in Network.HTTP2.Arch.Types

data OutBody Source #

Constructors

OutBodyNone 
OutBodyStreaming ((Builder -> IO ()) -> IO () -> IO ())

Streaming body takes a write action and a flush action.

OutBodyBuilder Builder 
OutBodyFile FileSpec 

data FileSpec Source #

File specification.

Instances

Instances details
Show FileSpec Source # 
Instance details

Defined in Network.HTTP2.Arch.Types

Eq FileSpec Source # 
Instance details

Defined in Network.HTTP2.Arch.Types

Sender

Trailer

type TrailersMaker = Maybe ByteString -> IO NextTrailersMaker Source #

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

defaultTrailersMaker :: TrailersMaker Source #

TrailersMake to create no trailers.

data NextTrailersMaker Source #

Either the next trailers maker or final trailers.

runTrailersMaker :: TrailersMaker -> Buffer -> Int -> IO NextTrailersMaker Source #

Running trailers-maker.

bufferIO buf siz $ \bs -> tlrmkr (Just bs)