10 releases (stable)

1.5.0 Nov 23, 2023
1.4.1 Dec 27, 2022
1.4.0 Jan 30, 2021
1.3.0 Oct 6, 2020
0.3.1 May 5, 2015

#13 in HTTP client

Download history 175091/week @ 2024-06-30 189836/week @ 2024-07-07 178545/week @ 2024-07-14 188232/week @ 2024-07-21 179397/week @ 2024-07-28 173776/week @ 2024-08-04 200032/week @ 2024-08-11 207474/week @ 2024-08-18 203783/week @ 2024-08-25 185655/week @ 2024-09-01 221274/week @ 2024-09-08 190705/week @ 2024-09-15 220098/week @ 2024-09-22 229225/week @ 2024-09-29 245366/week @ 2024-10-06 241919/week @ 2024-10-13

942,955 downloads per month
Used in 493 crates (11 directly)

MIT/Apache

18KB
357 lines

rust-chunked-transfer

Documentation

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

Example

Decoding

use chunked_transfer::Decoder;
use std::io::Read;

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.read_to_string(&mut decoded);

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

Encoding

use chunked_transfer::Encoder;
use std::io::Write;

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

{
    let mut encoder = Encoder::with_chunks_size(&mut encoded, 5);
    encoder.write_all(decoded.as_bytes());
}

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

Authors

License

Licensed under either of:

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps