OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_SPDY_HPACK_HPACK_CONSTANTS_H_ | |
6 #define NET_SPDY_HPACK_HPACK_CONSTANTS_H_ | |
7 | |
8 #include <stddef.h> | |
9 #include <stdint.h> | |
10 | |
11 #include <vector> | |
12 | |
13 #include "net/base/net_export.h" | |
14 | |
15 // All section references below are to | |
16 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 | |
17 | |
18 namespace net { | |
19 | |
20 // An HpackPrefix signifies |bits| stored in the top |bit_size| bits | |
21 // of an octet. | |
22 struct HpackPrefix { | |
23 uint8_t bits; | |
24 size_t bit_size; | |
25 }; | |
26 | |
27 // Represents a symbol and its Huffman code (stored in most-significant bits). | |
28 struct HpackHuffmanSymbol { | |
29 uint32_t code; | |
30 uint8_t length; | |
31 uint16_t id; | |
32 }; | |
33 | |
34 // An entry in the static table. Must be a POD in order to avoid static | |
35 // initializers, i.e. no user-defined constructors or destructors. | |
36 struct HpackStaticEntry { | |
37 const char* const name; | |
38 const size_t name_len; | |
39 const char* const value; | |
40 const size_t value_len; | |
41 }; | |
42 | |
43 class HpackHuffmanTable; | |
44 class HpackStaticTable; | |
45 | |
46 // Defined in RFC 7540 section 6.5.2. | |
47 const uint32_t kDefaultHeaderTableSizeSetting = 4096; | |
48 | |
49 // 6.2: Flag for a string literal that is stored unmodified (i.e., | |
50 // without Huffman encoding). | |
51 const HpackPrefix kStringLiteralIdentityEncoded = {0x0, 1}; | |
52 | |
53 // 6.2: Flag for a Huffman-coded string literal. | |
54 const HpackPrefix kStringLiteralHuffmanEncoded = {0x1, 1}; | |
55 | |
56 // 7.1: Opcode for an indexed header field. | |
57 const HpackPrefix kIndexedOpcode = {0x1, 1}; | |
58 | |
59 // 7.2.1: Opcode for a literal header field with incremental indexing. | |
60 const HpackPrefix kLiteralIncrementalIndexOpcode = {0x1, 2}; | |
61 | |
62 // 7.2.2: Opcode for a literal header field without indexing. | |
63 const HpackPrefix kLiteralNoIndexOpcode = {0x0, 4}; | |
64 | |
65 // 7.2.3: Opcode for a literal header field which is never indexed. | |
66 const HpackPrefix kLiteralNeverIndexOpcode = {0x1, 4}; | |
67 | |
68 // 7.3: Opcode for maximum header table size update. Begins a varint-encoded | |
69 // table size with a 5-bit prefix. | |
70 const HpackPrefix kHeaderTableSizeUpdateOpcode = {0x1, 3}; | |
71 | |
72 // Returns symbol code table from "Appendix C. Huffman Code". | |
73 NET_EXPORT_PRIVATE std::vector<HpackHuffmanSymbol> HpackHuffmanCode(); | |
74 | |
75 // Returns static table from "Appendix B. Static Table Definition". | |
76 NET_EXPORT_PRIVATE std::vector<HpackStaticEntry> HpackStaticTableVector(); | |
77 | |
78 // Returns a HpackHuffmanTable instance initialized with |kHpackHuffmanCode|. | |
79 // The instance is read-only, has static lifetime, and is safe to share amoung | |
80 // threads. This function is thread-safe. | |
81 NET_EXPORT_PRIVATE const HpackHuffmanTable& ObtainHpackHuffmanTable(); | |
82 | |
83 // Returns a HpackStaticTable instance initialized with |kHpackStaticTable|. | |
84 // The instance is read-only, has static lifetime, and is safe to share amoung | |
85 // threads. This function is thread-safe. | |
86 NET_EXPORT_PRIVATE const HpackStaticTable& ObtainHpackStaticTable(); | |
87 | |
88 // Pseudo-headers start with a colon. (HTTP2 8.1.2.1., HPACK 3.1.) | |
89 const char kPseudoHeaderPrefix = ':'; | |
90 | |
91 } // namespace net | |
92 | |
93 #endif // NET_SPDY_HPACK_HPACK_CONSTANTS_H_ | |
OLD | NEW |