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

Function test_encode

src/proxy/http3/test/test_QPACK.cc:278–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278static int
279test_encode(const char *qif_file, const char *out_file, int dts, int mbs, int am)
280{
281 int ret = 0;
282
283 FILE *fd = fopen(out_file, "w");
284 if (!fd) {
285 std::cerr << "couldn't open file: " << out_file << std::endl;
286 REQUIRE(false);
287 return -1;
288 }
289
290 HTTPHdr *requests[MAX_SEQUENCE] = {nullptr};
291 int n_requests = load_qif_file(qif_file, requests);
292
293 QUICApplicationDriver driver;
294 QPACK *qpack = new QPACK(driver.get_connection(), UINT32_MAX, dts, mbs);
295 TestQUICStream *encoder_stream = new TestQUICStream(0);
296 TestQUICStream *decoder_stream = new TestQUICStream(10);
297 qpack->on_stream_open(*encoder_stream);
298 qpack->on_stream_open(*decoder_stream);
299 qpack->set_encoder_stream(encoder_stream->id());
300 qpack->set_decoder_stream(decoder_stream->id());
301
302 uint64_t stream_id = 1;
303 MIOBuffer *header_block = new_MIOBuffer(BUFFER_SIZE_INDEX_32K);
304 uint64_t header_block_len = 0;
305 IOBufferReader *header_block_reader = header_block->alloc_reader();
306 for (int i = 0; i < n_requests; ++i) {
307 HTTPHdr *hdr = requests[i];
308 ret = qpack->encode(stream_id, *hdr, header_block, header_block_len);
309 if (ret < 0) {
310 break;
311 }
312
313 output_encoder_stream_data(fd, encoder_stream);
314 output_encoded_data(fd, stream_id, header_block_reader);
315
316 if (am == ACK_MODE_IMMEDIATE) {
317 acknowledge_header_block(decoder_stream, stream_id);
318 }
319
320 ++stream_id;
321 }
322
323 fflush(fd);
324 fclose(fd);
325
326 return ret;
327}
328
329static int
330test_decode(const char *enc_file, const char *out_file, int dts, int mbs)

Callers 1

SECTIONFunction · 0.85

Calls 11

load_qif_fileFunction · 0.85
output_encoded_dataFunction · 0.85
acknowledge_header_blockFunction · 0.85
get_connectionMethod · 0.80
set_encoder_streamMethod · 0.80
set_decoder_streamMethod · 0.80
alloc_readerMethod · 0.80
on_stream_openMethod · 0.45
idMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected