maskit commented on code in PR #13554:
URL: https://github.com/apache/trafficserver/pull/13554#discussion_r3790384256
##########
src/proxy/http3/test/test_Http3Frame.cc:
##########
@@ -105,20 +105,28 @@ TEST_CASE("Store HEADERS Frame", "[http3]")
0x11, 0x22, 0x33, 0x44, // Payload
};
- uint8_t raw1[] = "\x11\x22\x33\x44";
- ats_unique_buf header_block = ats_unique_malloc(4);
- memcpy(header_block.get(), raw1, 4);
+ uint8_t raw1[] = "\x11\x22\x33\x44";
+ MIOBuffer *header_block = new_MIOBuffer(BUFFER_SIZE_INDEX_8K);
+ header_block->set(raw1, 4);
+ IOBufferReader *header_block_reader = header_block->alloc_reader();
- Http3HeadersFrame hdrs_frame(std::move(header_block), 4);
- CHECK(hdrs_frame.length() == 4);
+ Http3HeadersFrameUPtr frame =
Http3FrameFactory::create_headers_frame(header_block_reader, 4);
+ CHECK(frame->length() == 4);
+ // The factory must consume the caller's reader (needed so a header block
sent across
+ // multiple generate_frame() calls advances instead of re-reading the same
bytes).
+ CHECK(header_block_reader->read_avail() == 0);
- auto ibb = hdrs_frame.to_io_buffer_block();
+ // The frame must still serialize correctly even though the original
reader was already
+ // consumed above -- it holds its own independent clone of the reader.
+ auto ibb = frame->to_io_buffer_block();
IOBufferReader reader;
reader.block = ibb.get();
len = reader.read_avail();
reader.read(buf, sizeof(buf));
CHECK(len == 6);
CHECK(memcmp(buf, expected1, len) == 0);
+
+ free_MIOBuffer(header_block);
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]