{-# 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.ByteString (ByteString)
import Data.Typeable
import Data.Word (Word8)
import Foreign.Ptr (Ptr)
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
type Buffer = Ptr Word8
type BufferSize = Int
data BufferOverrun = BufferOverrun
deriving (Eq,Show,Typeable)
instance Exception BufferOverrun