https://github.com/njaard/idcurl
idiomatic synchronous Rust HTTP client library
https://github.com/njaard/idcurl
Last synced: 5 months ago
JSON representation
idiomatic synchronous Rust HTTP client library
- Host: GitHub
- URL: https://github.com/njaard/idcurl
- Owner: njaard
- License: bsd-2-clause
- Created: 2019-06-17T05:22:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-02T17:29:44.000Z (about 1 year ago)
- Last Synced: 2025-04-17T14:42:32.475Z (6 months ago)
- Language: Rust
- Size: 39.1 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://raw.githubusercontent.com/njaard/idcurl/master/LICENSE)
[](https://crates.io/crates/idcurl)# Introduction
idcurl is a synchronous HTTP client using curl (and inheriting all of
its protocol support).It's useful if you absolutely don't want to use futures.
One of two crates (along with [isahc](https://crates.io/crates/isahc))
to support Unix domain sockets!# Examples
The most basic request:
let mut output = vec!();
idcurl::get("http://example.com")
.expect("error making request")
.copy_to(&mut output)
.unwrap();You can also configure your request:
let body = r#"{ "hello": "world" }"#;
let mut response = idcurl::Request::post(
"http://example.com".to_string()
)
.header("Content-Type", "application/json")
.body(std::io::Cursor::new(body))
.send()
.expect("http request");
assert!(response.status().is_success());
std::io::copy(&mut response, &mut std::io::stdout())
.expect("reading response");