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

Function test_encoding

src/proxy/http2/test_HPACK.cc:215–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215int
216test_encoding(const string &filename_in, const string &filename_out)
217{
218 HpackIndexingTable indexing_table_for_encoding(INITIAL_TABLE_SIZE), indexing_table_for_decoding(INITIAL_TABLE_SIZE);
219 string line, name, value;
220 uint8_t encoded[8192];
221 const uint64_t encoded_len = sizeof(encoded);
222 string packed;
223 int64_t written;
224 int result = -1;
225 HTTPHdr original, decoded;
226 MIMEField *field;
227
228 decoded.create(HTTP_TYPE_REQUEST);
229 original.create(HTTP_TYPE_REQUEST);
230
231 ofstream ofs(filename_out);
232 ofs << "{" << endl;
233 ofs << " \"cases\": [" << endl;
234
235 int seqnum = -1;
236 ifstream ifs(filename_in);
237 while (ifs && getline(ifs, line) && result == -1) {
238 switch (line.find_first_of('"')) {
239 case 6:
240 switch (line[6 + 1]) {
241 case 's':
242 // This line should be the start of new case
243 // Check the last sequence
244 if (seqnum != -1) {
245 ofs << " }" << endl; // end of last header
246 ofs << " ]," << endl; // end of headers
247 written = hpack_encode_header_block(indexing_table_for_encoding, encoded, encoded_len, &original);
248 if (written == -1) {
249 result = seqnum;
250 break;
251 }
252 hpack_decode_header_block(indexing_table_for_decoding, &decoded, encoded, written, MAX_REQUEST_HEADER_SIZE,
253 MAX_TABLE_SIZE);
254 if (compare_header_fields(&decoded, &original) != 0) {
255 result = seqnum;
256 break;
257 }
258 pack(encoded, written, packed);
259 ofs << R"( "wire": ")" << packed << "\"" << endl;
260 ofs << " }," << endl;
261 }
262 // Prepare for next sequence
263 ++seqnum;
264 decoded.fields_clear();
265 original.fields_clear();
266 name = "";
267 value = "";
268 ofs << " {" << endl;
269 ofs << " \"seqnum\": " << seqnum << "," << endl;
270 ofs << " \"headers\": [" << endl;
271 break;
272 case 'w':

Callers 1

Calls 14

compare_header_fieldsFunction · 0.85
packFunction · 0.85
parse_lineFunction · 0.85
fields_clearMethod · 0.80
field_attachMethod · 0.80
escapeFunction · 0.70
createMethod · 0.45
field_createMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected