The practical HTTP client that is fun to use.
cHTTP provides a clean and easy-to-use interface around the venerable [libcurl]. Here are some of the features that are currently available:
Not everything needs to be re-invented! For typical use cases, [libcurl] is a fantastic choice for making web requests. It's fast, reliable, well supported, and isn't going away any time soon.
It has a reputation for having an unusual API that is sometimes tricky to use, but hey, that's why this library exists.
Really simple example that spits out the response body from https://example.org:
rust
let mut response = chttp::get("https://example.org").unwrap();
let body = response.body_mut().text().unwrap();
println!("{}", body);
Configuring a custom client:
```rust use chttp::{http, Client, RedirectPolicy}; use std::time::Duration;
let client = Client::builder() .maxconnections(Some(4)) .timeout(Some(Duration::fromsecs(60))) .redirects(RedirectPolicy::Limit(10)) .preferredhttpversion(http::Version::HTTP_2) .build();
let mut response = client.get("https://example.org").unwrap(); let body = response.body_mut().text().unwrap(); println!("{}", body); ```
On Linux:
On Windows and macOS:
Add this to your Cargo.toml file:
[dependencies] chttp = "0.1"
This library is licensed under the MIT license. See the LICENSE file for details.