alexcrichton / curl-rust

Rust bindings to libcurl
MIT License
1k stars 234 forks source link

curl with brotli compression #458

Open pchpub opened 1 year ago

pchpub commented 1 year ago

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

sagebind commented 1 year ago

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.