alexcrichton / curl-rust

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

Added an example for the "multi" api #431

Closed reduf closed 2 years ago

reduf commented 2 years ago

Hey,

here is a simple example to demonstrate how can one execute multiple requests concurrently in a non-blocking way.

I wasn't sure whether I should include urls in the source to test, but I've tested with the following commang:

> cargo r --example multi -- https://api.github.com/repos/rust-lang/rust https://api.github.com/repos/rust-lang/dskuyhfkuhdsfds "<invalid URL>"

You should observe a success (Code 200) on the valid repo, an explicit error (Code 404) on a non existing repo and no status in the case of the invalid url.

Cheers,

sagebind commented 2 years ago

Is there perhaps a multi example from curl itself we could lift?

Curl has a few good C examples here: https://curl.se/libcurl/c/example.html. It would be nice to translate some of these into Rust and include them in our repo.

reduf commented 2 years ago

Curl has a few good C examples here: https://curl.se/libcurl/c/example.html. It would be nice to translate some of these into Rust and include them in our repo.

Indeed, I will adapt my example following one if theirs. This one seems to be in the same spirit.