To make a http request with a custom body as binary in Rust, you can use the reqwest crate. Here's an example code:
main.rs326 chars12 linesIn this code, reqwest::Client is used to create a http client. body variable holds the binary data that you want to send in the request body. Then, body is passed to the .body() method of the reqwest::RequestBuilder, which returns a new builder with the binary body added. Finally, the .send() method is called to execute the request.
Note that reqwest's Body type automatically sets the Content-Length header, so you don't need to set it manually.
Also, note that reqwest's Client internally uses a connection pool, so it's recommended to create one instance and reuse it across your application.
gistlibby LogSnag