| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_SPDY_HPACK_CONSTANTS_H_ | 5 #ifndef NET_SPDY_HPACK_CONSTANTS_H_ |
| 6 #define NET_SPDY_HPACK_CONSTANTS_H_ | 6 #define NET_SPDY_HPACK_CONSTANTS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 | 12 |
| 13 // All section references below are to | 13 // All section references below are to |
| 14 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07 | 14 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 // An HpackPrefix signifies |bits| stored in the top |bit_size| bits | 18 // An HpackPrefix signifies |bits| stored in the top |bit_size| bits |
| 19 // of an octet. | 19 // of an octet. |
| 20 struct HpackPrefix { | 20 struct HpackPrefix { |
| 21 uint8 bits; | 21 uint8 bits; |
| 22 size_t bit_size; | 22 size_t bit_size; |
| 23 }; | 23 }; |
| 24 | 24 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // Largest string literal an HpackDecoder/HpackEncoder will attempt to process | 36 // Largest string literal an HpackDecoder/HpackEncoder will attempt to process |
| 37 // before returning an error. | 37 // before returning an error. |
| 38 const uint32 kDefaultMaxStringLiteralSize = 16 * 1024; | 38 const uint32 kDefaultMaxStringLiteralSize = 16 * 1024; |
| 39 | 39 |
| 40 // Maximum amount of encoded header buffer HpackDecoder will retain before | 40 // Maximum amount of encoded header buffer HpackDecoder will retain before |
| 41 // returning an error. | 41 // returning an error. |
| 42 // TODO(jgraettinger): Remove with SpdyHeadersHandlerInterface switch. | 42 // TODO(jgraettinger): Remove with SpdyHeadersHandlerInterface switch. |
| 43 const uint32 kMaxDecodeBufferSize = 32 * 1024; | 43 const uint32 kMaxDecodeBufferSize = 32 * 1024; |
| 44 | 44 |
| 45 // 4.1.2: Flag for a string literal that is stored unmodified (i.e., | 45 // 6.2: Flag for a string literal that is stored unmodified (i.e., |
| 46 // without Huffman encoding). | 46 // without Huffman encoding). |
| 47 const HpackPrefix kStringLiteralIdentityEncoded = { 0x0, 1 }; | 47 const HpackPrefix kStringLiteralIdentityEncoded = { 0x0, 1 }; |
| 48 | 48 |
| 49 // 4.1.2: Flag for a Huffman-coded string literal. | 49 // 6.2: Flag for a Huffman-coded string literal. |
| 50 const HpackPrefix kStringLiteralHuffmanEncoded = { 0x1, 1 }; | 50 const HpackPrefix kStringLiteralHuffmanEncoded = { 0x1, 1 }; |
| 51 | 51 |
| 52 // 4.2: Opcode for an indexed header field. | 52 // 7.1: Opcode for an indexed header field. |
| 53 const HpackPrefix kIndexedOpcode = { 0x1, 1 }; | 53 const HpackPrefix kIndexedOpcode = { 0x1, 1 }; |
| 54 | 54 |
| 55 // 4.3.1: Opcode for a literal header field with incremental indexing. | 55 // 7.2.1: Opcode for a literal header field with incremental indexing. |
| 56 const HpackPrefix kLiteralIncrementalIndexOpcode = { 0x1, 2 }; | 56 const HpackPrefix kLiteralIncrementalIndexOpcode = { 0x1, 2 }; |
| 57 | 57 |
| 58 // 4.3.2: Opcode for a literal header field without indexing. | 58 // 7.2.2: Opcode for a literal header field without indexing. |
| 59 const HpackPrefix kLiteralNoIndexOpcode = { 0x0, 4 }; | 59 const HpackPrefix kLiteralNoIndexOpcode = { 0x0, 4 }; |
| 60 | 60 |
| 61 // 4.3.3: Opcode for a literal header field which is never indexed. | 61 // 7.2.3: Opcode for a literal header field which is never indexed. |
| 62 const HpackPrefix kLiteralNeverIndexOpcode = { 0x1, 4 }; | 62 const HpackPrefix kLiteralNeverIndexOpcode = { 0x1, 4 }; |
| 63 | 63 |
| 64 // 4.4: Opcode for an encoding context update. | 64 // 7.3: Opcode for an encoding context update. |
| 65 const HpackPrefix kEncodingContextOpcode = { 0x1, 3 }; | 65 const HpackPrefix kEncodingContextOpcode = { 0x1, 3 }; |
| 66 | 66 |
| 67 // 4.4: Flag following an |kEncodingContextOpcode|, which indicates | 67 // 7.3: Flag following an |kEncodingContextOpcode|, which indicates |
| 68 // the reference set should be cleared. | 68 // the reference set should be cleared. |
| 69 const HpackPrefix kEncodingContextEmptyReferenceSet = { 0x10, 5 }; | 69 const HpackPrefix kEncodingContextEmptyReferenceSet = { 0x10, 5 }; |
| 70 | 70 |
| 71 // 4.4: Flag following an |kEncodingContextOpcode|, which indicates | 71 // 7.3: Flag following an |kEncodingContextOpcode|, which indicates |
| 72 // the encoder is using a new maximum headers table size. Begins a | 72 // the encoder is using a new maximum headers table size. Begins a |
| 73 // varint-encoded table size with a 4-bit prefix. | 73 // varint-encoded table size with a 4-bit prefix. |
| 74 const HpackPrefix kEncodingContextNewMaximumSize = { 0x0, 1 }; | 74 const HpackPrefix kEncodingContextNewMaximumSize = { 0x0, 1 }; |
| 75 | 75 |
| 76 // Returns symbol code table from "Appendix C. Huffman Codes". | 76 // Returns symbol code table from "Appendix C. Huffman Codes". |
| 77 NET_EXPORT_PRIVATE std::vector<HpackHuffmanSymbol> HpackHuffmanCode(); | 77 NET_EXPORT_PRIVATE std::vector<HpackHuffmanSymbol> HpackHuffmanCode(); |
| 78 | 78 |
| 79 // Returns a HpackHuffmanTable instance initialized with |kHpackHuffmanCode|. | 79 // Returns a HpackHuffmanTable instance initialized with |kHpackHuffmanCode|. |
| 80 // The instance is read-only, has static lifetime, and is safe to share amoung | 80 // The instance is read-only, has static lifetime, and is safe to share amoung |
| 81 // threads. This function is thread-safe. | 81 // threads. This function is thread-safe. |
| 82 NET_EXPORT_PRIVATE const HpackHuffmanTable& ObtainHpackHuffmanTable(); | 82 NET_EXPORT_PRIVATE const HpackHuffmanTable& ObtainHpackHuffmanTable(); |
| 83 | 83 |
| 84 } // namespace net | 84 } // namespace net |
| 85 | 85 |
| 86 #endif // NET_SPDY_HPACK_CONSTANTS_H_ | 86 #endif // NET_SPDY_HPACK_CONSTANTS_H_ |
| OLD | NEW |