This crate provides a zero-allocation, iterator/slice-based parser for extracting
transfer encoding types as they
appear in the Transfer-Encoding
request header. Standard
encodings
are extracted as enum values, and unknown encodings are extracted as slices for
further processing.
use uhttp_transfer_encoding::{transfer_encodings, TransferEncoding, StdTransferEncoding};
let mut encs = transfer_encodings(" gzip, custom-enc, chunked");
assert_eq!(encs.next(), Some(TransferEncoding::Std(StdTransferEncoding::Chunked)));
assert_eq!(encs.next(), Some(TransferEncoding::Other("custom-enc")));
assert_eq!(encs.next(), Some(TransferEncoding::Std(StdTransferEncoding::Gzip)));
assert_eq!(encs.next(), None);
This crate can be used through cargo by
adding it as a dependency in Cargo.toml
:
[dependencies]
uhttp_transfer_encoding = "0.5.0"
and importing it in the crate root:
extern crate uhttp_transfer_encoding;