{-# LANGUAGE DeriveDataTypeable #-}
module Network.HPACK.Types (
HeaderName,
HeaderValue,
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, BufferOverrun (..), BufferSize)
import Imports
import Network.HPACK.Token (Token)
type = ByteString
type = ByteString
type = (HeaderName, HeaderValue)
type = [Header]
type = (Token, HeaderValue)
type = [TokenHeader]
type Index = Int
data HIndex = SIndex Int | DIndex Int deriving (HIndex -> HIndex -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HIndex -> HIndex -> Bool
$c/= :: HIndex -> HIndex -> Bool
== :: HIndex -> HIndex -> Bool
$c== :: HIndex -> HIndex -> Bool
Eq, Eq HIndex
HIndex -> HIndex -> Bool
HIndex -> HIndex -> Ordering
HIndex -> HIndex -> HIndex
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: HIndex -> HIndex -> HIndex
$cmin :: HIndex -> HIndex -> HIndex
max :: HIndex -> HIndex -> HIndex
$cmax :: HIndex -> HIndex -> HIndex
>= :: HIndex -> HIndex -> Bool
$c>= :: HIndex -> HIndex -> Bool
> :: HIndex -> HIndex -> Bool
$c> :: HIndex -> HIndex -> Bool
<= :: HIndex -> HIndex -> Bool
$c<= :: HIndex -> HIndex -> Bool
< :: HIndex -> HIndex -> Bool
$c< :: HIndex -> HIndex -> Bool
compare :: HIndex -> HIndex -> Ordering
$ccompare :: HIndex -> HIndex -> Ordering
Ord, Int -> HIndex -> ShowS
[HIndex] -> ShowS
HIndex -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HIndex] -> ShowS
$cshowList :: [HIndex] -> ShowS
show :: HIndex -> String
$cshow :: HIndex -> String
showsPrec :: Int -> HIndex -> ShowS
$cshowsPrec :: Int -> HIndex -> ShowS
Show)
data CompressionAlgo
=
Naive
|
Static
|
Linear
deriving (CompressionAlgo -> CompressionAlgo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompressionAlgo -> CompressionAlgo -> Bool
$c/= :: CompressionAlgo -> CompressionAlgo -> Bool
== :: CompressionAlgo -> CompressionAlgo -> Bool
$c== :: CompressionAlgo -> CompressionAlgo -> Bool
Eq, Int -> CompressionAlgo -> ShowS
[CompressionAlgo] -> ShowS
CompressionAlgo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompressionAlgo] -> ShowS
$cshowList :: [CompressionAlgo] -> ShowS
show :: CompressionAlgo -> String
$cshow :: CompressionAlgo -> String
showsPrec :: Int -> CompressionAlgo -> ShowS
$cshowsPrec :: Int -> CompressionAlgo -> ShowS
Show)
data EncodeStrategy = EncodeStrategy
{ EncodeStrategy -> CompressionAlgo
compressionAlgo :: CompressionAlgo
, EncodeStrategy -> Bool
useHuffman :: Bool
}
deriving (EncodeStrategy -> EncodeStrategy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncodeStrategy -> EncodeStrategy -> Bool
$c/= :: EncodeStrategy -> EncodeStrategy -> Bool
== :: EncodeStrategy -> EncodeStrategy -> Bool
$c== :: EncodeStrategy -> EncodeStrategy -> Bool
Eq, Int -> EncodeStrategy -> ShowS
[EncodeStrategy] -> ShowS
EncodeStrategy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncodeStrategy] -> ShowS
$cshowList :: [EncodeStrategy] -> ShowS
show :: EncodeStrategy -> String
$cshow :: EncodeStrategy -> String
showsPrec :: Int -> EncodeStrategy -> ShowS
$cshowsPrec :: Int -> EncodeStrategy -> ShowS
Show)
defaultEncodeStrategy :: EncodeStrategy
defaultEncodeStrategy :: EncodeStrategy
defaultEncodeStrategy =
EncodeStrategy
{ compressionAlgo :: CompressionAlgo
compressionAlgo = CompressionAlgo
Linear
, useHuffman :: Bool
useHuffman = Bool
False
}
data DecodeError
=
IndexOverrun Index
|
EosInTheMiddle
|
IllegalEos
|
TooLongEos
|
TooSmallTableSize
|
TooLargeTableSize
|
IllegalTableSizeUpdate
|
|
|
deriving (DecodeError -> DecodeError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DecodeError -> DecodeError -> Bool
$c/= :: DecodeError -> DecodeError -> Bool
== :: DecodeError -> DecodeError -> Bool
$c== :: DecodeError -> DecodeError -> Bool
Eq, Int -> DecodeError -> ShowS
[DecodeError] -> ShowS
DecodeError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DecodeError] -> ShowS
$cshowList :: [DecodeError] -> ShowS
show :: DecodeError -> String
$cshow :: DecodeError -> String
showsPrec :: Int -> DecodeError -> ShowS
$cshowsPrec :: Int -> DecodeError -> ShowS
Show, Typeable)
instance Exception DecodeError