#http #curl #http-request #client #sync

idcurl

Idiomatic synchronous http client based on curl

16 releases

0.5.2 Aug 2, 2024
0.5.0 May 10, 2024
0.4.3 Jul 12, 2022
0.4.2 Dec 21, 2020
0.2.3 Jun 20, 2019

#101 in HTTP client

Download history 213/week @ 2024-07-29 12/week @ 2024-08-05 14/week @ 2024-09-16 40/week @ 2024-09-23 2/week @ 2024-09-30

830 downloads per month

BSD-2-Clause

30KB
763 lines

GitHub license Crates.io

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) 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");

Dependencies

~8–15MB
~228K SLoC