{-# 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, BufferSize, BufferOverrun(..))
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
(HIndex -> HIndex -> Bool)
-> (HIndex -> HIndex -> Bool) -> Eq HIndex
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
Eq HIndex
-> (HIndex -> HIndex -> Ordering)
-> (HIndex -> HIndex -> Bool)
-> (HIndex -> HIndex -> Bool)
-> (HIndex -> HIndex -> Bool)
-> (HIndex -> HIndex -> Bool)
-> (HIndex -> HIndex -> HIndex)
-> (HIndex -> HIndex -> HIndex)
-> Ord 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
$cp1Ord :: Eq HIndex
Ord, Int -> HIndex -> ShowS
[HIndex] -> ShowS
HIndex -> String
(Int -> HIndex -> ShowS)
-> (HIndex -> String) -> ([HIndex] -> ShowS) -> Show HIndex
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
(CompressionAlgo -> CompressionAlgo -> Bool)
-> (CompressionAlgo -> CompressionAlgo -> Bool)
-> Eq CompressionAlgo
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
(Int -> CompressionAlgo -> ShowS)
-> (CompressionAlgo -> String)
-> ([CompressionAlgo] -> ShowS)
-> Show CompressionAlgo
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
(EncodeStrategy -> EncodeStrategy -> Bool)
-> (EncodeStrategy -> EncodeStrategy -> Bool) -> Eq EncodeStrategy
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
(Int -> EncodeStrategy -> ShowS)
-> (EncodeStrategy -> String)
-> ([EncodeStrategy] -> ShowS)
-> Show EncodeStrategy
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 -> Bool -> EncodeStrategy
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
(DecodeError -> DecodeError -> Bool)
-> (DecodeError -> DecodeError -> Bool) -> Eq DecodeError
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
(Int -> DecodeError -> ShowS)
-> (DecodeError -> String)
-> ([DecodeError] -> ShowS)
-> Show DecodeError
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