{-# LANGUAGE DeriveDataTypeable #-}
module Network.HPACK.Types (
HeaderName
, HeaderValue
, HeaderStuff
, Header
, HeaderList
, TokenHeader
, TokenHeaderList
, Index
, HIndex(..)
, CompressionAlgo(..)
, EncodeStrategy(..)
, defaultEncodeStrategy
, DecodeError(..)
, Buffer
, BufferSize
, BufferOverrun(..)
) where
import Control.Exception as E
import Data.Typeable
import Network.ByteOrder (Buffer, BufferSize, BufferOverrun(..))
import Imports
import Network.HPACK.Token (Token)
type HeaderName = ByteString
type HeaderValue = ByteString
type Header = (HeaderName, HeaderValue)
type HeaderList = [Header]
type HeaderStuff = ByteString
type TokenHeader = (Token, HeaderValue)
type TokenHeaderList = [TokenHeader]
type Index = Int
data HIndex = SIndex Int | DIndex Int deriving (Eq, Ord, Show)
data CompressionAlgo = Naive
| Static
| Linear
deriving (Eq, Show)
data EncodeStrategy = EncodeStrategy {
compressionAlgo :: !CompressionAlgo
, useHuffman :: !Bool
} deriving (Eq, Show)
defaultEncodeStrategy :: EncodeStrategy
defaultEncodeStrategy = EncodeStrategy {
compressionAlgo = Linear
, useHuffman = False
}
data DecodeError = IndexOverrun Index
| EosInTheMiddle
| IllegalEos
| TooLongEos
| EmptyEncodedString
| TooSmallTableSize
| TooLargeTableSize
| IllegalTableSizeUpdate
| HeaderBlockTruncated
| IllegalHeaderName
deriving (Eq,Show,Typeable)
instance Exception DecodeError