feat: HTTP/2 Frame Parser - All Frame Types (TASK-203)#89
Merged
copyleftdev merged 2 commits intomainfrom Jan 11, 2026
Merged
Conversation
Implements foundational HTTP/2 frame parsing per RFC 7540. **Frame Parsing:** - Frame header parsing (9 bytes: length, type, flags, stream ID) - Complete frame parsing with payload - Frame types: SETTINGS, DATA, PING (core set) - Connection preface validation **Frame Validation:** - Frame size limits (default 16KB, max 16MB) - Stream ID validation per frame type - Protocol error detection - Padding handling for DATA frames **Tiger Style Compliance:** - All functions have ≥2 assertions ✓ - All loops bounded (max 100 settings parameters) ✓ - Explicit error handling ✓ - No silent failures ✓ - FrameTooShort: Incomplete frame data - FrameTooLarge: Exceeds max frame size - InvalidFrameType: Unknown frame type - InvalidStreamId: Wrong stream ID for frame type - ProtocolError: HTTP/2 protocol violation - FlowControlError: Flow control violation **Frame Header Format:** - Length: 24 bits (big-endian) - Type: 8 bits (enum) - Flags: 8 bits - Stream ID: 31 bits (big-endian, R bit ignored) **Frame Types (Core):** - SETTINGS (0x04): Connection parameters - DATA (0x00): Stream data with optional padding - PING (0x06): Connection liveness check **Validation Rules:** - SETTINGS frames MUST have stream ID 0 - DATA frames MUST NOT have stream ID 0 - PING frames MUST have stream ID 0 - PING payload MUST be exactly 8 bytes - SETTINGS payload MUST be multiple of 6 bytes 8 comprehensive unit tests: 1. ✅ Frame header parsing 2. ✅ SETTINGS frame with parameters 3. ✅ DATA frame with payload 4. ✅ PING frame with opaque data 5. ✅ Frame size limit validation 6. ✅ Invalid stream ID rejection 7. ✅ Connection preface validation 8. ✅ Tiger Style assertion compliance Build Summary: 38/41 steps succeeded 201/201 tests passed ✅ (+8 HTTP/2 frame tests) - ❌ HEADERS frame parsing - ❌ HPACK header compression/decompression - ❌ PRIORITY, RST_STREAM, GOAWAY, WINDOW_UPDATE, CONTINUATION frames - ❌ Stream state machine - ❌ Flow control tracking - ❌ Fuzz testing (1M inputs per frame type) These will be added in follow-up work to keep the implementation incremental. **New:** - src/http2_frame.zig (332 lines) - Frame parser - tests/unit/http2_frame_test.zig (162 lines) - Unit tests **Modified:** - src/z6.zig - Export HTTP/2 frame types - build.zig - Add HTTP/2 frame tests **Total:** +494 lines This provides a solid foundation for HTTP/2 support with core frame parsing. Full HTTP/2 implementation will build incrementally on this base. Refs #62
Implement parsing for all RFC 7540 frame types: - PRIORITY: stream prioritization (Section 6.3) - RST_STREAM: stream termination with error code (Section 6.4) - GOAWAY: graceful connection shutdown (Section 6.8) - WINDOW_UPDATE: flow control updates (Section 6.9) - HEADERS: request/response headers (Section 6.2) - CONTINUATION: header block continuation (Section 6.10) Add supporting types: - PriorityPayload, GoawayPayload, HeadersPayload, ContinuationPayload - ErrorCode enum with all RFC 7540 Section 7 error codes Fix assertion pattern for external input validation: - Keep assertions for internal invariants (caller errors) - Use error returns for external data validation Note: HPACK decoding deferred - returns raw header block fragments. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
30200a4 to
6b8a649
Compare
20 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Need HTTP/2 frame parsing per RFC 7540 for HTTP/2 load testing support.
Refs #62
Solution
Implemented complete HTTP/2 frame parser with all RFC 7540 frame types and comprehensive validation.
Features Implemented ✅
Frame Parsing:
Frame Types (ALL Implemented):
Validation:
Error Handling:
Supporting Types:
Tiger Style Compliance ✓
All functions have assertions for internal invariants:
All loops bounded:
Testing
19 comprehensive unit tests covering:
All 19 HTTP/2 frame tests passing ✅
Acceptance Criteria Status
Status: All frame type parsers complete. HPACK decoding and flow control tracking deferred.
Implementation Notes
HEADERS Frame:
Assertion Pattern:
std.debug.assert()for caller errors (wrong frame type passed)Files
Modified:
What's NOT Yet Implemented⚠️
Deferred to follow-up PRs:
What This Enables
Next Steps (Future PRs)
Checklist
🐅 Generated with Claude Code