[SOLVED] Reqwest crate response is invalid

I've been trying to download a simple zip file from a website using the reqwest crate.

(Playground)

But whenever I try to read the payload, I get an extra 32957 bytes in the binary, and thus a checksum error

Error { kind: Io(Custom { kind: InvalidData, error: StringError("CRC32 mismatched: value=3696103308, expected=3723158783") }), url: None }'

As a guide, I'm trying to replicate this piece of python code: fx

I suspect I'm using the reqwuest api incorrectly, but can't see an obvious incantation mistake

Fixed. Reqwest doesn't automatically understand Deflate compression. Setting this using

    headers.set(AcceptEncoding(vec![qitem(Encoding::Deflate)]));

Just in case others have the same issue

2 Likes