static_table.go 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. package qpack
  2. var staticTableEntries = [...]HeaderField{
  3. {Name: ":authority"},
  4. {Name: ":path", Value: "/"},
  5. {Name: "age", Value: "0"},
  6. {Name: "content-disposition"},
  7. {Name: "content-length", Value: "0"},
  8. {Name: "cookie"},
  9. {Name: "date"},
  10. {Name: "etag"},
  11. {Name: "if-modified-since"},
  12. {Name: "if-none-match"},
  13. {Name: "last-modified"},
  14. {Name: "link"},
  15. {Name: "location"},
  16. {Name: "referer"},
  17. {Name: "set-cookie"},
  18. {Name: ":method", Value: "CONNECT"},
  19. {Name: ":method", Value: "DELETE"},
  20. {Name: ":method", Value: "GET"},
  21. {Name: ":method", Value: "HEAD"},
  22. {Name: ":method", Value: "OPTIONS"},
  23. {Name: ":method", Value: "POST"},
  24. {Name: ":method", Value: "PUT"},
  25. {Name: ":scheme", Value: "http"},
  26. {Name: ":scheme", Value: "https"},
  27. {Name: ":status", Value: "103"},
  28. {Name: ":status", Value: "200"},
  29. {Name: ":status", Value: "304"},
  30. {Name: ":status", Value: "404"},
  31. {Name: ":status", Value: "503"},
  32. {Name: "accept", Value: "*/*"},
  33. {Name: "accept", Value: "application/dns-message"},
  34. {Name: "accept-encoding", Value: "gzip, deflate, br"},
  35. {Name: "accept-ranges", Value: "bytes"},
  36. {Name: "access-control-allow-headers", Value: "cache-control"},
  37. {Name: "access-control-allow-headers", Value: "content-type"},
  38. {Name: "access-control-allow-origin", Value: "*"},
  39. {Name: "cache-control", Value: "max-age=0"},
  40. {Name: "cache-control", Value: "max-age=2592000"},
  41. {Name: "cache-control", Value: "max-age=604800"},
  42. {Name: "cache-control", Value: "no-cache"},
  43. {Name: "cache-control", Value: "no-store"},
  44. {Name: "cache-control", Value: "public, max-age=31536000"},
  45. {Name: "content-encoding", Value: "br"},
  46. {Name: "content-encoding", Value: "gzip"},
  47. {Name: "content-type", Value: "application/dns-message"},
  48. {Name: "content-type", Value: "application/javascript"},
  49. {Name: "content-type", Value: "application/json"},
  50. {Name: "content-type", Value: "application/x-www-form-urlencoded"},
  51. {Name: "content-type", Value: "image/gif"},
  52. {Name: "content-type", Value: "image/jpeg"},
  53. {Name: "content-type", Value: "image/png"},
  54. {Name: "content-type", Value: "text/css"},
  55. {Name: "content-type", Value: "text/html; charset=utf-8"},
  56. {Name: "content-type", Value: "text/plain"},
  57. {Name: "content-type", Value: "text/plain;charset=utf-8"},
  58. {Name: "range", Value: "bytes=0-"},
  59. {Name: "strict-transport-security", Value: "max-age=31536000"},
  60. {Name: "strict-transport-security", Value: "max-age=31536000; includesubdomains"},
  61. {Name: "strict-transport-security", Value: "max-age=31536000; includesubdomains; preload"},
  62. {Name: "vary", Value: "accept-encoding"},
  63. {Name: "vary", Value: "origin"},
  64. {Name: "x-content-type-options", Value: "nosniff"},
  65. {Name: "x-xss-protection", Value: "1; mode=block"},
  66. {Name: ":status", Value: "100"},
  67. {Name: ":status", Value: "204"},
  68. {Name: ":status", Value: "206"},
  69. {Name: ":status", Value: "302"},
  70. {Name: ":status", Value: "400"},
  71. {Name: ":status", Value: "403"},
  72. {Name: ":status", Value: "421"},
  73. {Name: ":status", Value: "425"},
  74. {Name: ":status", Value: "500"},
  75. {Name: "accept-language"},
  76. {Name: "access-control-allow-credentials", Value: "FALSE"},
  77. {Name: "access-control-allow-credentials", Value: "TRUE"},
  78. {Name: "access-control-allow-headers", Value: "*"},
  79. {Name: "access-control-allow-methods", Value: "get"},
  80. {Name: "access-control-allow-methods", Value: "get, post, options"},
  81. {Name: "access-control-allow-methods", Value: "options"},
  82. {Name: "access-control-expose-headers", Value: "content-length"},
  83. {Name: "access-control-request-headers", Value: "content-type"},
  84. {Name: "access-control-request-method", Value: "get"},
  85. {Name: "access-control-request-method", Value: "post"},
  86. {Name: "alt-svc", Value: "clear"},
  87. {Name: "authorization"},
  88. {Name: "content-security-policy", Value: "script-src 'none'; object-src 'none'; base-uri 'none'"},
  89. {Name: "early-data", Value: "1"},
  90. {Name: "expect-ct"},
  91. {Name: "forwarded"},
  92. {Name: "if-range"},
  93. {Name: "origin"},
  94. {Name: "purpose", Value: "prefetch"},
  95. {Name: "server"},
  96. {Name: "timing-allow-origin", Value: "*"},
  97. {Name: "upgrade-insecure-requests", Value: "1"},
  98. {Name: "user-agent"},
  99. {Name: "x-forwarded-for"},
  100. {Name: "x-frame-options", Value: "deny"},
  101. {Name: "x-frame-options", Value: "sameorigin"},
  102. }
  103. // Only needed for tests.
  104. // use go:linkname to retrieve the static table.
  105. //
  106. //nolint:deadcode,unused
  107. func getStaticTable() []HeaderField {
  108. return staticTableEntries[:]
  109. }
  110. type indexAndValues struct {
  111. idx uint8
  112. values map[string]uint8
  113. }
  114. // A map of the header names from the static table to their index in the table.
  115. // This is used by the encoder to quickly find if a header is in the static table
  116. // and what value should be used to encode it.
  117. // There's a second level of mapping for the headers that have some predefined
  118. // values in the static table.
  119. var encoderMap = map[string]indexAndValues{
  120. ":authority": {0, nil},
  121. ":path": {1, map[string]uint8{"/": 1}},
  122. "age": {2, map[string]uint8{"0": 2}},
  123. "content-disposition": {3, nil},
  124. "content-length": {4, map[string]uint8{"0": 4}},
  125. "cookie": {5, nil},
  126. "date": {6, nil},
  127. "etag": {7, nil},
  128. "if-modified-since": {8, nil},
  129. "if-none-match": {9, nil},
  130. "last-modified": {10, nil},
  131. "link": {11, nil},
  132. "location": {12, nil},
  133. "referer": {13, nil},
  134. "set-cookie": {14, nil},
  135. ":method": {15, map[string]uint8{
  136. "CONNECT": 15,
  137. "DELETE": 16,
  138. "GET": 17,
  139. "HEAD": 18,
  140. "OPTIONS": 19,
  141. "POST": 20,
  142. "PUT": 21,
  143. }},
  144. ":scheme": {22, map[string]uint8{
  145. "http": 22,
  146. "https": 23,
  147. }},
  148. ":status": {24, map[string]uint8{
  149. "103": 24,
  150. "200": 25,
  151. "304": 26,
  152. "404": 27,
  153. "503": 28,
  154. "100": 63,
  155. "204": 64,
  156. "206": 65,
  157. "302": 66,
  158. "400": 67,
  159. "403": 68,
  160. "421": 69,
  161. "425": 70,
  162. "500": 71,
  163. }},
  164. "accept": {29, map[string]uint8{
  165. "*/*": 29,
  166. "application/dns-message": 30,
  167. }},
  168. "accept-encoding": {31, map[string]uint8{"gzip, deflate, br": 31}},
  169. "accept-ranges": {32, map[string]uint8{"bytes": 32}},
  170. "access-control-allow-headers": {33, map[string]uint8{
  171. "cache-control": 33,
  172. "content-type": 34,
  173. "*": 75,
  174. }},
  175. "access-control-allow-origin": {35, map[string]uint8{"*": 35}},
  176. "cache-control": {36, map[string]uint8{
  177. "max-age=0": 36,
  178. "max-age=2592000": 37,
  179. "max-age=604800": 38,
  180. "no-cache": 39,
  181. "no-store": 40,
  182. "public, max-age=31536000": 41,
  183. }},
  184. "content-encoding": {42, map[string]uint8{
  185. "br": 42,
  186. "gzip": 43,
  187. }},
  188. "content-type": {44, map[string]uint8{
  189. "application/dns-message": 44,
  190. "application/javascript": 45,
  191. "application/json": 46,
  192. "application/x-www-form-urlencoded": 47,
  193. "image/gif": 48,
  194. "image/jpeg": 49,
  195. "image/png": 50,
  196. "text/css": 51,
  197. "text/html; charset=utf-8": 52,
  198. "text/plain": 53,
  199. "text/plain;charset=utf-8": 54,
  200. }},
  201. "range": {55, map[string]uint8{"bytes=0-": 55}},
  202. "strict-transport-security": {56, map[string]uint8{
  203. "max-age=31536000": 56,
  204. "max-age=31536000; includesubdomains": 57,
  205. "max-age=31536000; includesubdomains; preload": 58,
  206. }},
  207. "vary": {59, map[string]uint8{
  208. "accept-encoding": 59,
  209. "origin": 60,
  210. }},
  211. "x-content-type-options": {61, map[string]uint8{"nosniff": 61}},
  212. "x-xss-protection": {62, map[string]uint8{"1; mode=block": 62}},
  213. // ":status" is duplicated and takes index 63 to 71
  214. "accept-language": {72, nil},
  215. "access-control-allow-credentials": {73, map[string]uint8{
  216. "FALSE": 73,
  217. "TRUE": 74,
  218. }},
  219. // "access-control-allow-headers" is duplicated and takes index 75
  220. "access-control-allow-methods": {76, map[string]uint8{
  221. "get": 76,
  222. "get, post, options": 77,
  223. "options": 78,
  224. }},
  225. "access-control-expose-headers": {79, map[string]uint8{"content-length": 79}},
  226. "access-control-request-headers": {80, map[string]uint8{"content-type": 80}},
  227. "access-control-request-method": {81, map[string]uint8{
  228. "get": 81,
  229. "post": 82,
  230. }},
  231. "alt-svc": {83, map[string]uint8{"clear": 83}},
  232. "authorization": {84, nil},
  233. "content-security-policy": {85, map[string]uint8{
  234. "script-src 'none'; object-src 'none'; base-uri 'none'": 85,
  235. }},
  236. "early-data": {86, map[string]uint8{"1": 86}},
  237. "expect-ct": {87, nil},
  238. "forwarded": {88, nil},
  239. "if-range": {89, nil},
  240. "origin": {90, nil},
  241. "purpose": {91, map[string]uint8{"prefetch": 91}},
  242. "server": {92, nil},
  243. "timing-allow-origin": {93, map[string]uint8{"*": 93}},
  244. "upgrade-insecure-requests": {94, map[string]uint8{"1": 94}},
  245. "user-agent": {95, nil},
  246. "x-forwarded-for": {96, nil},
  247. "x-frame-options": {97, map[string]uint8{
  248. "deny": 97,
  249. "sameorigin": 98,
  250. }},
  251. }