smolhttp

Crates.iosmolhttp
lib.rssmolhttp
version1.1.0
sourcesrc
created_at2022-03-14 11:41:26.329773
updated_at2022-03-14 13:29:00.779223
descriptionsmolhttp is a fork of the original minihttp and aims to keep simple and lightweight
homepagehttps://github.com/FallAngel1337/smolhttp
repositoryhttps://github.com/FallAngel1337/smolhttp
max_upload_size
id549786
size17,523
FallAngel (FallAngel1337)

documentation

README

smolhttp

This project is a fork of the original minihttp that tries to improve the code and add more features, dont pushing aside the main purpose of the project thats is to be simple and lightweight.

Copyright

All the credits go to the original author p00s

Usage

Send a GET request

// Using the shortcut function
let content = smolhttp::get("https://www.rust-lang.org").unwrap().text();
println!("{content}");

// Using the Client
let content = smolhttp::Client::new("https://www.rust-lang.org").unwrap().get().send().unwrap().text();
println!("{content}");

Send a POST request

// Using the shortcut funtion
let content = smolhttp::post("https://www.rust-lang.org").unwrap().text();
println!("{content}");

// Using the Client
let content = smolhttp::Client::new("https://www.rust-lang.org")
  .unwrap()
  .post()
  .send()
  .unwrap()
  .text();
println!("{content}");

Custom headers

let content = smolhttp::Client::new("https://www.rust-lang.org")
  .unwrap()
  .post()
  .headers(vec![("User-Agent".to_owned(), "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36".to_owned())])
  .send()
  .unwrap()
  .text();
println!("{content}");

Support proxy

let content = smolhttp::Client::new("http://www.google.com")
  .unwrap()
  .proxy("http://127.0.0.1:1080")
  .unwrap()
  .get()
  .send()
  .unwrap()
  .text();
println!("{content}");

Adding it to your project

[dependencies]
smolhttp = "1.0"
Commit count: 44

cargo fmt