curl-rust icon indicating copy to clipboard operation
curl-rust copied to clipboard

curl with brotli compression

Open pchpub opened this issue 1 year ago • 1 comments

How can I use curl to fetch pages using brotli compression? when i use handle.accept_encoding("gzip,deflate,br").unwrap(); and then use perform(), it panic :

Error { description: "Unrecognized or bad HTTP Content or Transfer-Encoding", code: 61, extra: Some("Unrecognized content encoding type. libcurl understands deflate, gzip content encodings.") }

it seems that curl did not support brotli compression

pchpub avatar Sep 03 '22 12:09 pchpub

The bundled version of libcurl included in the crate is not compiled with brotli support by default. We would accept a PR to add brotli support behind an optional crate feature though!

It might be possible to use the brotli crate written in Rust here, as it supposedly is ABI-compatible with libbrotli that curl normally uses. Otherwise we could use brotlic-sys to pull in libbrotli and statically link to it.

sagebind avatar Sep 04 '22 23:09 sagebind