#http #client #curl #sync

idcurl

Idiomatic synchronous http client based on curl

12 releases

0.4.2 Dec 21, 2020
0.4.1 Dec 10, 2020
0.4.0 Feb 15, 2020
0.3.2 Sep 20, 2019
0.1.1 Jun 17, 2019

#143 in Asynchronous

Download history 6/week @ 2021-06-24 12/week @ 2021-07-15 24/week @ 2021-07-29 14/week @ 2021-08-05 14/week @ 2021-08-12 1/week @ 2021-08-19 2/week @ 2021-08-26 2/week @ 2021-09-09 1/week @ 2021-09-23 13/week @ 2021-09-30 12/week @ 2021-10-07

71 downloads per month

BSD-2-Clause

27KB
723 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.

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

lib.rs:

An idiomatic synchronous Rust library for making HTTP requests.

It's implemented in terms of curl.

Example

let mut output = vec!();
idcurl::get("http://example.com")
    .expect("error making request")
    .copy_to(&mut output)
    .unwrap();
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

~11MB
~231K SLoC