JakeChampion / JakeChampion/trafficserver
[audit][quality] HTTPHdr-to-MIOBuffer serialization loop duplicated across HTTP/1, HTTP/2, and HTTP/3 stacks
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 0
- Forks
- 0
- Avg merge
- 8h 2m
- Merged PRs (30d)
- 21
Description
Severity: medium · Category: quality
Location: src/proxy/http3/Http3HeaderVIOAdaptor.cc:135
What's wrong
The dumpoffset/bufindex/block do-while loop that serializes an HTTPHdr into an MIOBuffer exists three times: HttpSM::write_header_into_buffer (src/proxy/http/HttpSM.cc:6910), Http2Stream.cc:331 ('Borrowing logic from HttpSM::write_header_into_buffer'), and Http3HeaderVIOAdaptor::_on_qpack_decode_complete. The H3 copy carries a TODO enumerating three ways to deduplicate it, so the debt is self-acknowledged. Any fix to the loop (e.g. block-allocation edge cases) must now be applied in three protocol stacks or they silently diverge.
Evidence
// TODO: Http2Stream::send_request has same logic. It originally comes from HttpSM::write_header_into_buffer.
// a). Make HttpSM::write_header_into_buffer static
// or
// b). Add interface to HTTPHdr to dump data
...
do {
bufindex = 0;
tmp = dumpoffset;
block = writer->get_current_block();
Suggested fix
Implement option (b) from the TODO: add HTTPHdr::write_into(MIOBuffer &) (or a free function in proxy/hdrs) and delete the three hand-rolled loops.
Filed from an automated multi-lens codebase audit. Full report: CODEBASE_AUDIT.md / audit-report.html on branch claude/codebase-audit-review-9nw7vz.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the duplicated loops in src/proxy/http/HttpSM.cc:6910, Http2Stream.cc:331, and src/proxy/http3/Http3HeaderVIOAdaptor.cc:135, including the existing TODO. Read the HTTPHdr and MIOBuffer interfaces before choosing the shared write_into location. Done means the three protocol stacks use one shared serialization path and the hand-rolled loops are removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design, networking
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100