Skip to content

Add direct unit tests for HTTPChunkedTransferDecoder#211

Merged
swhitty merged 1 commit into
swhitty:mainfrom
ianegordon:ian/chunked-decoder-tests
Apr 28, 2026
Merged

Add direct unit tests for HTTPChunkedTransferDecoder#211
swhitty merged 1 commit into
swhitty:mainfrom
ianegordon:ian/chunked-decoder-tests

Conversation

@ianegordon

@ianegordon ianegordon commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Existing chunked-body coverage runs through HTTPDecoder integration tests. This adds four tests that exercise HTTPChunkedTransferDecoder directly, pinning behavior the integration path doesn't cover:

  • No over-consumption past the terminator — bytes after the chunked stream remain readable on the underlying source (the keep-alive / pipelining correctness property).
  • nextBuffer(suggested:) honors the suggested cap — a 100-byte chunk requested with suggested: 16 yields only buffers ≤ 16 bytes.
  • Uppercase HEXDIG acceptedFF\r\n… decodes 255 bytes (per RFC 5234 §2.3, ABNF literal strings are case-insensitive).
  • Chunk-size exceeding Int.max rejected — a 20-hex-char value throws HTTPDecoder.Error rather than truncating or trapping. Distinct error path from non-hex input (already covered by invalidChunkSize_ThrowsError).

No public-API changes.

Test plan

  • swift test --filter HTTPChunkedDecodedSequenceTests passes locally (4/4)
  • CI green

@codecov

codecov Bot commented Apr 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.75%. Comparing base (5295843) to head (1d1f0a9).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #211   +/-   ##
=======================================
  Coverage   92.75%   92.75%           
=======================================
  Files          70       70           
  Lines        3645     3645           
=======================================
  Hits         3381     3381           
  Misses        264      264           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Existing chunked-body coverage runs through HTTPDecoder. These tests
exercise the decoder directly to pin behavior that integration tests
don't cover: that consumption stops at the trailer terminator (so
keep-alive pipelining is safe), that nextBuffer(suggested:) honors
the suggested cap, that uppercase HEXDIG is accepted per RFC 5234
§2.3, and that chunk-sizes exceeding Int.max are rejected as a
framing error.
@ianegordon ianegordon force-pushed the ian/chunked-decoder-tests branch from 5ca2c29 to 1d1f0a9 Compare April 28, 2026 01:41
@swhitty swhitty merged commit e2f31ad into swhitty:main Apr 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants