1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef HPACK_P_H |
5 | #define HPACK_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists for the convenience |
12 | // of other Qt classes. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include "hpacktable_p.h" |
19 | |
20 | #include <QtCore/qglobal.h> |
21 | |
22 | #include <vector> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QByteArray; |
27 | |
28 | namespace HPack |
29 | { |
30 | |
31 | using = std::vector<HeaderField>; |
32 | HeaderSize (const HttpHeader &); |
33 | |
34 | class Q_AUTOTEST_EXPORT Encoder |
35 | { |
36 | public: |
37 | Encoder(quint32 maxTableSize, bool compressStrings); |
38 | |
39 | quint32 dynamicTableSize() const; |
40 | |
41 | bool (class BitOStream &outputStream, |
42 | const HttpHeader &); |
43 | bool (BitOStream &outputStream, |
44 | const HttpHeader &); |
45 | |
46 | bool encodeSizeUpdate(BitOStream &outputStream, |
47 | quint32 newSize); |
48 | |
49 | void setMaxDynamicTableSize(quint32 size); |
50 | void setCompressStrings(bool compress); |
51 | |
52 | private: |
53 | bool (BitOStream &outputStream, |
54 | const HttpHeader &); |
55 | bool (BitOStream &outputStream, |
56 | const HeaderField &field); |
57 | bool (BitOStream &outputStream, |
58 | const HeaderField &field); |
59 | |
60 | bool (BitOStream &outputStream, |
61 | const HttpHeader &); |
62 | |
63 | bool encodeIndexedField(BitOStream &outputStream, quint32 index) const; |
64 | |
65 | |
66 | bool encodeLiteralField(BitOStream &outputStream, |
67 | const struct BitPattern &fieldType, |
68 | quint32 nameIndex, |
69 | const QByteArray &value, |
70 | bool withCompression); |
71 | |
72 | bool encodeLiteralField(BitOStream &outputStream, |
73 | const BitPattern &fieldType, |
74 | const QByteArray &name, |
75 | const QByteArray &value, |
76 | bool withCompression); |
77 | |
78 | FieldLookupTable lookupTable; |
79 | bool compressStrings; |
80 | }; |
81 | |
82 | class Q_AUTOTEST_EXPORT Decoder |
83 | { |
84 | public: |
85 | Decoder(quint32 maxTableSize); |
86 | |
87 | bool (class BitIStream &inputStream); |
88 | |
89 | const HttpHeader &() const |
90 | { |
91 | return header; |
92 | } |
93 | |
94 | quint32 dynamicTableSize() const; |
95 | |
96 | void setMaxDynamicTableSize(quint32 size); |
97 | |
98 | private: |
99 | |
100 | bool decodeIndexedField(BitIStream &inputStream); |
101 | bool decodeSizeUpdate(BitIStream &inputStream); |
102 | bool decodeLiteralField(const BitPattern &fieldType, |
103 | BitIStream &inputStream); |
104 | |
105 | bool processDecodedField(const BitPattern &fieldType, |
106 | const QByteArray &name, |
107 | const QByteArray &value); |
108 | |
109 | void handleStreamError(BitIStream &inputStream); |
110 | |
111 | HttpHeader ; |
112 | FieldLookupTable lookupTable; |
113 | }; |
114 | |
115 | } |
116 | |
117 | QT_END_NAMESPACE |
118 | |
119 | #endif |
120 | |
121 | |