#http #client #curl #sync

idcurl

Idiomatic synchronous http client based on curl

9 releases

✓ Uses Rust 2018 edition

0.3.2 Sep 20, 2019
0.3.1 Sep 9, 2019
0.3.0 Aug 13, 2019
0.2.3 Jun 20, 2019
0.1.1 Jun 17, 2019

#5 in #curl

Download history 27/week @ 2019-08-08 8/week @ 2019-08-15 96/week @ 2019-08-22 31/week @ 2019-08-29 41/week @ 2019-09-05 25/week @ 2019-09-12 113/week @ 2019-09-19 14/week @ 2019-09-26 19/week @ 2019-10-03 36/week @ 2019-10-17 87/week @ 2019-10-24 20/week @ 2019-10-31 4/week @ 2019-11-07 10/week @ 2019-11-14

142 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
~221K SLoC