async-chunked-transfer

Note: The only difference between this and chunked_transfer is that you MUST call Encoder::finish before dropping the encoder.

Documentation

Encoder and decoder for HTTP chunked transfer coding. For more information about chunked transfer encoding:

Example

Decoding

```rust use asyncchunkedtransfer::Decoder; use tokio::io::AsyncReadExt;

let encoded = b"3\r\nhel\r\nb\r\nlo world!!!\r\n0\r\n\r\n"; let mut decoded = String::new();

let mut decoder = Decoder::new(encoded as &[u8]); decoder.readtostring(&mut decoded).await;

assert_eq!(decoded, "hello world!!!"); ```

Encoding

```rust use chunked_transfer::Encoder; use tokio::io::AsyncWriteExt;

let mut decoded = "hello world"; let mut encoded: Vec = vec![];

{ let mut encoder = Encoder::withchunkssize(&mut encoded, 5); encoder.writeall(decoded.asbytes()).await; encoder.finish().await; }

assert_eq!(encoded, b"5\r\nhello\r\n5\r\n worl\r\n1\r\nd\r\n0\r\n\r\n"); ```

Authors