pub struct AwsChunkedDecoder { /* private fields */ }Expand description
Incremental decoder for the aws-chunked content-encoding that modern AWS
S3 clients (aws-cli, boto3 >= 1.36, aws-crt) apply by default to PutObject /
UploadPart bodies when they send x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD (or STREAMING-UNSIGNED-PAYLOAD-TRAILER).
The wire format wraps the real payload in application-layer frames:
<hex-size>[;chunk-signature=<hex>]\r\n<data>\r\n repeated, terminated by a
0-size chunk, then optional x-amz-trailer lines, then a final \r\n.
hyper only strips HTTP Transfer-Encoding: chunked, NOT this
Content-Encoding: aws-chunked framing — so without decoding, the size /
signature lines and trailers get stored as the object’s bytes (silent
corruption + a wrong ETag). This is fed incrementally because network frames
do not align to chunk boundaries. Trailer lines (x-amz-checksum-<algo>:<v>)
are collected so the service can verify the trailing checksum against the
decoded bytes; see AwsChunkedDecoder::trailers.
Implementations§
Source§impl AwsChunkedDecoder
impl AwsChunkedDecoder
Sourcepub fn feed(&mut self, input: &[u8]) -> Result<Vec<u8>, MalformedChunk>
pub fn feed(&mut self, input: &[u8]) -> Result<Vec<u8>, MalformedChunk>
Feed a network frame; returns the decoded payload bytes it yielded. Errors only on a malformed chunk-size line.
Sourcepub fn trailers(&self) -> &[(String, String)]
pub fn trailers(&self) -> &[(String, String)]
The trailer headers read after the terminating zero-size chunk.
Sourcepub fn into_trailers(self) -> Vec<(String, String)>
pub fn into_trailers(self) -> Vec<(String, String)>
Consume the decoder, returning its trailer headers.