idcurl

Crates.ioidcurl
lib.rsidcurl
version0.5.0
sourcesrc
created_at2019-06-17 05:24:24.892416
updated_at2024-05-10 17:41:24.769733
descriptionIdiomatic synchronous http client based on curl
homepage
repositoryhttps://github.com/njaard/idcurl
max_upload_size
id141675
size39,983
project-freta (github:microsoft:project-freta)

documentation

https://docs.rs/idcurl/

README

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");
Commit count: 41

cargo fmt