24 days of Rust - reqwest

In the first volume of 24 Days of Rust, I've written about hyper as the Rust HTTP toolkit. A lot of things have changed in the last two years, but hyper is still the best solution for HTTP in Rust. However, hyper is undergoing some major changes to use tokio for async I/O. While this will be fantastic for use cases where performance is top priority, it will also make hyper APIs a bit more complex. It's good to know about event loops, futures and services, but sometimes we just want to send a GET request and call it a day.

Sean McArthur created Reqwest specifically for such scenarios. It is a high level HTTP client built on top of hyper. The situation here is somewhat similar to Python, where requests provides a simple API on top of heavy urllib3 machinery. Reqwest is relatively new compared to requests, but it has the same goal - to make simple HTTP requests easy and delegate complex tasks to hyper.

Reqwest also uses OS-provided TLS support if possible. This avoids a lot of pain setting up OpenSSL on Windows.

Czytaj dalej »
Napisane 20 grudnia 2016

24 days of Rust - hyper

Important note: this article is outdated! Go to http://zsiciarz.github.io/24daysofrust/ for a recent version of all of 24 days of Rust articles. The blogpost here is kept as it is for historical reasons.

The state of HTTP libraries in Rust is a constant flux. See Are we web yet? for an overview of the current affairs. There's rust-http which although usable (for example Nickel builds on top of that) is not developed anymore. Teepee, it's conceptual successor, is in the words of it's author not even vaguely usable. Meanwhile a new library emerged during the last few months: hyper, which will be the subject of this blogpost.

Czytaj dalej »
Napisane 5 grudnia 2014