MCPcopy Create free account
hub / github.com/apache/trafficserver / test_decoding

Function test_decoding

src/proxy/http2/test_HPACK.cc:162–213  ·  view source on GitHub ↗

Returns -1 if test passes, or returns the failed sequence number

Source from the content-addressed store, hash-verified

160
161// Returns -1 if test passes, or returns the failed sequence number
162int
163test_decoding(const string &filename)
164{
165 HpackIndexingTable indexing_table(INITIAL_TABLE_SIZE);
166 string line, name, value;
167 uint8_t unpacked[8192];
168 size_t unpacked_len;
169 int result = -1;
170 HTTPHdr original, decoded;
171 MIMEField *field;
172
173 decoded.create(HTTP_TYPE_REQUEST);
174 original.create(HTTP_TYPE_REQUEST);
175
176 int seqnum = -1;
177 ifstream ifs(filename);
178 while (ifs && getline(ifs, line) && result == -1) {
179 switch (line.find_first_of('"')) {
180 case 6:
181 switch (line[6 + 1]) {
182 case 's':
183 // This line should be the start of new case
184 // Check the last case
185 if (compare_header_fields(&decoded, &original) != 0) {
186 result = seqnum;
187 break;
188 }
189 // Prepare for next sequence
190 ++seqnum;
191 decoded.fields_clear();
192 original.fields_clear();
193 break;
194 case 'w':
195 parse_line(line, 6, name, value);
196 unpacked_len = unpack(value, unpacked);
197 hpack_decode_header_block(indexing_table, &decoded, unpacked, unpacked_len, MAX_REQUEST_HEADER_SIZE, MAX_TABLE_SIZE);
198 break;
199 }
200 break;
201 case 10:
202 // This line should be a header field
203 parse_line(line, 10, name, value);
204 field = original.field_create(name.c_str(), name.length());
205 field->value_set(original.m_heap, original.m_mime, value.c_str(), value.length());
206 original.field_attach(field);
207 break;
208 }
209 }
210 decoded.destroy();
211 original.destroy();
212 return result;
213}
214
215int
216test_encoding(const string &filename_in, const string &filename_out)

Callers 1

Calls 12

compare_header_fieldsFunction · 0.85
parse_lineFunction · 0.85
unpackFunction · 0.85
fields_clearMethod · 0.80
field_attachMethod · 0.80
createMethod · 0.45
field_createMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
value_setMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected