JakeChampion / JakeChampion/trafficserver

[audit][quality] HTTPHdr-to-MIOBuffer serialization loop duplicated across HTTP/1, HTTP/2, and HTTP/3 stacks

Open
#52 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:quality audit severity:medium
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.