tables.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package hpack
  5. func pair(name, value string) HeaderField {
  6. return HeaderField{Name: name, Value: value}
  7. }
  8. // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B
  9. var staticTable = [...]HeaderField{
  10. pair(":authority", ""), // index 1 (1-based)
  11. pair(":method", "GET"),
  12. pair(":method", "POST"),
  13. pair(":path", "/"),
  14. pair(":path", "/index.html"),
  15. pair(":scheme", "http"),
  16. pair(":scheme", "https"),
  17. pair(":status", "200"),
  18. pair(":status", "204"),
  19. pair(":status", "206"),
  20. pair(":status", "304"),
  21. pair(":status", "400"),
  22. pair(":status", "404"),
  23. pair(":status", "500"),
  24. pair("accept-charset", ""),
  25. pair("accept-encoding", "gzip, deflate"),
  26. pair("accept-language", ""),
  27. pair("accept-ranges", ""),
  28. pair("accept", ""),
  29. pair("access-control-allow-origin", ""),
  30. pair("age", ""),
  31. pair("allow", ""),
  32. pair("authorization", ""),
  33. pair("cache-control", ""),
  34. pair("content-disposition", ""),
  35. pair("content-encoding", ""),
  36. pair("content-language", ""),
  37. pair("content-length", ""),
  38. pair("content-location", ""),
  39. pair("content-range", ""),
  40. pair("content-type", ""),
  41. pair("cookie", ""),
  42. pair("date", ""),
  43. pair("etag", ""),
  44. pair("expect", ""),
  45. pair("expires", ""),
  46. pair("from", ""),
  47. pair("host", ""),
  48. pair("if-match", ""),
  49. pair("if-modified-since", ""),
  50. pair("if-none-match", ""),
  51. pair("if-range", ""),
  52. pair("if-unmodified-since", ""),
  53. pair("last-modified", ""),
  54. pair("link", ""),
  55. pair("location", ""),
  56. pair("max-forwards", ""),
  57. pair("proxy-authenticate", ""),
  58. pair("proxy-authorization", ""),
  59. pair("range", ""),
  60. pair("referer", ""),
  61. pair("refresh", ""),
  62. pair("retry-after", ""),
  63. pair("server", ""),
  64. pair("set-cookie", ""),
  65. pair("strict-transport-security", ""),
  66. pair("transfer-encoding", ""),
  67. pair("user-agent", ""),
  68. pair("vary", ""),
  69. pair("via", ""),
  70. pair("www-authenticate", ""),
  71. }
  72. var huffmanCodes = [256]uint32{
  73. 0x1ff8,
  74. 0x7fffd8,
  75. 0xfffffe2,
  76. 0xfffffe3,
  77. 0xfffffe4,
  78. 0xfffffe5,
  79. 0xfffffe6,
  80. 0xfffffe7,
  81. 0xfffffe8,
  82. 0xffffea,
  83. 0x3ffffffc,
  84. 0xfffffe9,
  85. 0xfffffea,
  86. 0x3ffffffd,
  87. 0xfffffeb,
  88. 0xfffffec,
  89. 0xfffffed,
  90. 0xfffffee,
  91. 0xfffffef,
  92. 0xffffff0,
  93. 0xffffff1,
  94. 0xffffff2,
  95. 0x3ffffffe,
  96. 0xffffff3,
  97. 0xffffff4,
  98. 0xffffff5,
  99. 0xffffff6,
  100. 0xffffff7,
  101. 0xffffff8,
  102. 0xffffff9,
  103. 0xffffffa,
  104. 0xffffffb,
  105. 0x14,
  106. 0x3f8,
  107. 0x3f9,
  108. 0xffa,
  109. 0x1ff9,
  110. 0x15,
  111. 0xf8,
  112. 0x7fa,
  113. 0x3fa,
  114. 0x3fb,
  115. 0xf9,
  116. 0x7fb,
  117. 0xfa,
  118. 0x16,
  119. 0x17,
  120. 0x18,
  121. 0x0,
  122. 0x1,
  123. 0x2,
  124. 0x19,
  125. 0x1a,
  126. 0x1b,
  127. 0x1c,
  128. 0x1d,
  129. 0x1e,
  130. 0x1f,
  131. 0x5c,
  132. 0xfb,
  133. 0x7ffc,
  134. 0x20,
  135. 0xffb,
  136. 0x3fc,
  137. 0x1ffa,
  138. 0x21,
  139. 0x5d,
  140. 0x5e,
  141. 0x5f,
  142. 0x60,
  143. 0x61,
  144. 0x62,
  145. 0x63,
  146. 0x64,
  147. 0x65,
  148. 0x66,
  149. 0x67,
  150. 0x68,
  151. 0x69,
  152. 0x6a,
  153. 0x6b,
  154. 0x6c,
  155. 0x6d,
  156. 0x6e,
  157. 0x6f,
  158. 0x70,
  159. 0x71,
  160. 0x72,
  161. 0xfc,
  162. 0x73,
  163. 0xfd,
  164. 0x1ffb,
  165. 0x7fff0,
  166. 0x1ffc,
  167. 0x3ffc,
  168. 0x22,
  169. 0x7ffd,
  170. 0x3,
  171. 0x23,
  172. 0x4,
  173. 0x24,
  174. 0x5,
  175. 0x25,
  176. 0x26,
  177. 0x27,
  178. 0x6,
  179. 0x74,
  180. 0x75,
  181. 0x28,
  182. 0x29,
  183. 0x2a,
  184. 0x7,
  185. 0x2b,
  186. 0x76,
  187. 0x2c,
  188. 0x8,
  189. 0x9,
  190. 0x2d,
  191. 0x77,
  192. 0x78,
  193. 0x79,
  194. 0x7a,
  195. 0x7b,
  196. 0x7ffe,
  197. 0x7fc,
  198. 0x3ffd,
  199. 0x1ffd,
  200. 0xffffffc,
  201. 0xfffe6,
  202. 0x3fffd2,
  203. 0xfffe7,
  204. 0xfffe8,
  205. 0x3fffd3,
  206. 0x3fffd4,
  207. 0x3fffd5,
  208. 0x7fffd9,
  209. 0x3fffd6,
  210. 0x7fffda,
  211. 0x7fffdb,
  212. 0x7fffdc,
  213. 0x7fffdd,
  214. 0x7fffde,
  215. 0xffffeb,
  216. 0x7fffdf,
  217. 0xffffec,
  218. 0xffffed,
  219. 0x3fffd7,
  220. 0x7fffe0,
  221. 0xffffee,
  222. 0x7fffe1,
  223. 0x7fffe2,
  224. 0x7fffe3,
  225. 0x7fffe4,
  226. 0x1fffdc,
  227. 0x3fffd8,
  228. 0x7fffe5,
  229. 0x3fffd9,
  230. 0x7fffe6,
  231. 0x7fffe7,
  232. 0xffffef,
  233. 0x3fffda,
  234. 0x1fffdd,
  235. 0xfffe9,
  236. 0x3fffdb,
  237. 0x3fffdc,
  238. 0x7fffe8,
  239. 0x7fffe9,
  240. 0x1fffde,
  241. 0x7fffea,
  242. 0x3fffdd,
  243. 0x3fffde,
  244. 0xfffff0,
  245. 0x1fffdf,
  246. 0x3fffdf,
  247. 0x7fffeb,
  248. 0x7fffec,
  249. 0x1fffe0,
  250. 0x1fffe1,
  251. 0x3fffe0,
  252. 0x1fffe2,
  253. 0x7fffed,
  254. 0x3fffe1,
  255. 0x7fffee,
  256. 0x7fffef,
  257. 0xfffea,
  258. 0x3fffe2,
  259. 0x3fffe3,
  260. 0x3fffe4,
  261. 0x7ffff0,
  262. 0x3fffe5,
  263. 0x3fffe6,
  264. 0x7ffff1,
  265. 0x3ffffe0,
  266. 0x3ffffe1,
  267. 0xfffeb,
  268. 0x7fff1,
  269. 0x3fffe7,
  270. 0x7ffff2,
  271. 0x3fffe8,
  272. 0x1ffffec,
  273. 0x3ffffe2,
  274. 0x3ffffe3,
  275. 0x3ffffe4,
  276. 0x7ffffde,
  277. 0x7ffffdf,
  278. 0x3ffffe5,
  279. 0xfffff1,
  280. 0x1ffffed,
  281. 0x7fff2,
  282. 0x1fffe3,
  283. 0x3ffffe6,
  284. 0x7ffffe0,
  285. 0x7ffffe1,
  286. 0x3ffffe7,
  287. 0x7ffffe2,
  288. 0xfffff2,
  289. 0x1fffe4,
  290. 0x1fffe5,
  291. 0x3ffffe8,
  292. 0x3ffffe9,
  293. 0xffffffd,
  294. 0x7ffffe3,
  295. 0x7ffffe4,
  296. 0x7ffffe5,
  297. 0xfffec,
  298. 0xfffff3,
  299. 0xfffed,
  300. 0x1fffe6,
  301. 0x3fffe9,
  302. 0x1fffe7,
  303. 0x1fffe8,
  304. 0x7ffff3,
  305. 0x3fffea,
  306. 0x3fffeb,
  307. 0x1ffffee,
  308. 0x1ffffef,
  309. 0xfffff4,
  310. 0xfffff5,
  311. 0x3ffffea,
  312. 0x7ffff4,
  313. 0x3ffffeb,
  314. 0x7ffffe6,
  315. 0x3ffffec,
  316. 0x3ffffed,
  317. 0x7ffffe7,
  318. 0x7ffffe8,
  319. 0x7ffffe9,
  320. 0x7ffffea,
  321. 0x7ffffeb,
  322. 0xffffffe,
  323. 0x7ffffec,
  324. 0x7ffffed,
  325. 0x7ffffee,
  326. 0x7ffffef,
  327. 0x7fffff0,
  328. 0x3ffffee,
  329. }
  330. var huffmanCodeLen = [256]uint8{
  331. 13, 23, 28, 28, 28, 28, 28, 28, 28, 24, 30, 28, 28, 30, 28, 28,
  332. 28, 28, 28, 28, 28, 28, 30, 28, 28, 28, 28, 28, 28, 28, 28, 28,
  333. 6, 10, 10, 12, 13, 6, 8, 11, 10, 10, 8, 11, 8, 6, 6, 6,
  334. 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 8, 15, 6, 12, 10,
  335. 13, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
  336. 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 8, 13, 19, 13, 14, 6,
  337. 15, 5, 6, 5, 6, 5, 6, 6, 6, 5, 7, 7, 6, 6, 6, 5,
  338. 6, 7, 6, 5, 5, 6, 7, 7, 7, 7, 7, 15, 11, 14, 13, 28,
  339. 20, 22, 20, 20, 22, 22, 22, 23, 22, 23, 23, 23, 23, 23, 24, 23,
  340. 24, 24, 22, 23, 24, 23, 23, 23, 23, 21, 22, 23, 22, 23, 23, 24,
  341. 22, 21, 20, 22, 22, 23, 23, 21, 23, 22, 22, 24, 21, 22, 23, 23,
  342. 21, 21, 22, 21, 23, 22, 23, 23, 20, 22, 22, 22, 23, 22, 22, 23,
  343. 26, 26, 20, 19, 22, 23, 22, 25, 26, 26, 26, 27, 27, 26, 24, 25,
  344. 19, 21, 26, 27, 27, 26, 27, 24, 21, 21, 26, 26, 28, 27, 27, 27,
  345. 20, 24, 20, 21, 22, 21, 21, 23, 22, 22, 25, 25, 24, 24, 26, 23,
  346. 26, 27, 26, 26, 27, 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, 26,
  347. }