Skip to content

About

A lightweight, synchronous, curl-based HTTP client in Rust

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

58 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lean http client based on curl

small blocking http client on top of libcurl. Built for exchanging parameters/files with services (multipart, form-urlencoded, raw bodies) without dealing with curl directly.

usage

use http_helper::{Client, Method, Parameter, ParameterType};

let mut client = Client::new("http://localhost:5678?debug=1", Method::POST)?;
client.add_parameter(Parameter::SimpleParameter {
    name: "key".to_owned(),
    value: "value".to_owned(),
    param_type: ParameterType::Body,
});
let response = client.execute()?;
println!("{}", response.status_code);

files go in as complex parameters:

client.add_complex_parameter("report", mime::APPLICATION_PDF, &data)?;

one body parameter -> sent raw, multiple simple ones -> form urlencoded, anything with a file in it -> multipart. Query params in the url are parsed and re-encoded, so pass them unencoded.

responses are parsed back into the same Parameter enum (multipart gets split into parts), or use execute_raw() if you just want status + headers + bytes.

features

  • static-curl / static-ssl: passthrough of the curl crate's static linking flags, default is dynamic

About

A lightweight, synchronous, curl-based HTTP client in Rust

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages