File: Static.hs

package info (click to toggle)
haskell-http2 5.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,180 kB
  • sloc: haskell: 8,657; makefile: 5
file content (101 lines) | stat: -rw-r--r-- 2,804 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{-# LANGUAGE OverloadedStrings #-}

module Network.HPACK.Table.Static (
    toStaticEntry,
    staticTableSize,
    staticTableList,
) where

import Data.Array (Array, listArray)
import Data.Array.Base (unsafeAt)
import Network.HPACK.Table.Entry

----------------------------------------------------------------

-- | The size of static table.
staticTableSize :: Size
staticTableSize = length staticTableList

{-# INLINE toStaticEntry #-}

-- | Get 'Entry' from the static table.
--
-- >>> toStaticEntry 1
-- Entry 42 (Token {tokenIx = 0, shouldBeIndexed = True, isPseudo = True, tokenKey = ":authority"}) ""
-- >>> toStaticEntry 8
-- Entry 42 (Token {tokenIx = 4, shouldBeIndexed = True, isPseudo = True, tokenKey = ":status"}) "200"
-- >>> toStaticEntry 50
-- Entry 37 (Token {tokenIx = 40, shouldBeIndexed = True, isPseudo = False, tokenKey = "Range"}) ""
toStaticEntry :: Index -> Entry
toStaticEntry sidx = staticTable `unsafeAt` (sidx - 1)

-- | Pre-defined static table.
staticTable :: Array Index Entry
staticTable = listArray (1, staticTableSize) $ map toEntry staticTableList

----------------------------------------------------------------

staticTableList :: [Header]
staticTableList =
    [ (":authority", "")
    , (":method", "GET")
    , (":method", "POST")
    , (":path", "/")
    , (":path", "/index.html")
    , (":scheme", "http")
    , (":scheme", "https")
    , (":status", "200")
    , (":status", "204")
    , (":status", "206")
    , (":status", "304")
    , (":status", "400")
    , (":status", "404")
    , (":status", "500")
    , ("accept-charset", "")
    , ("accept-encoding", "gzip, deflate")
    , ("accept-language", "")
    , ("accept-ranges", "")
    , ("accept", "")
    , ("access-control-allow-origin", "")
    , ("age", "")
    , ("allow", "")
    , ("authorization", "")
    , ("cache-control", "")
    , ("content-disposition", "")
    , ("content-encoding", "")
    , ("content-language", "")
    , ("content-length", "")
    , ("content-location", "")
    , ("content-range", "")
    , ("content-type", "")
    , ("cookie", "")
    , ("date", "")
    , ("etag", "")
    , ("expect", "")
    , ("expires", "")
    , ("from", "")
    , ("host", "")
    , ("if-match", "")
    , ("if-modified-since", "")
    , ("if-none-match", "")
    , ("if-range", "")
    , ("if-unmodified-since", "")
    , ("last-modified", "")
    , ("link", "")
    , ("location", "")
    , ("max-forwards", "")
    , ("proxy-authenticate", "")
    , ("proxy-authorization", "")
    , ("range", "")
    , ("referer", "")
    , ("refresh", "")
    , ("retry-after", "")
    , ("server", "")
    , ("set-cookie", "")
    , ("strict-transport-security", "")
    , ("transfer-encoding", "")
    , ("user-agent", "")
    , ("vary", "")
    , ("via", "")
    , ("www-authenticate", "")
    ]