The body decoder handles framing only.
Included:
- fixed-length byte accounting
- chunked decode
- trailer consumption control
Excluded:
- transport reads
- hidden buffering
- content-coding decode
- application payload interpretation
| API | Purpose |
|---|---|
ihtp_fixed_decoder_init() |
initialize fixed-length accounting |
ihtp_decode_fixed() |
advance fixed-length decode state |
ihtp_chunked_decoder_t |
chunked decode state |
ihtp_decode_chunked() |
decode chunked body bytes in place |
- Reuse one
ihtp_chunked_decoder_tacross calls. - The decoder rewrites the caller buffer in place.
*bufszbecomes the retained payload size in the current slice.total_decodedcounts payload bytes only.- A non-negative return value means completion and equals the number of trailing bytes after the terminal chunk processing path.
consume_trailer |
Effect |
|---|---|
true |
decoder consumes trailer fields through the terminating empty line |
false |
decoder leaves trailer bytes for the consumer |
Trailing bytes remain in the caller buffer immediately after the decoded payload prefix.
ihtp_fixed_decoder_init()sets the expected payload length.ihtp_decode_fixed()is accounting only.remainingdecreases monotonically.total_decodedincreases monotonically.- Passing more bytes than
remainingis an error.
- Input bytes are caller-owned.
- Decoded payload bytes remain in caller-owned memory.
- Decoder state stores counters and phase only.
sequenceDiagram
participant C as Caller
participant S as Semantics
participant D as Decoder
C->>S: parsed headers
S-->>C: body mode
C->>D: body bytes
D-->>C: payload bytes
D-->>C: trailing bytes