Skip to content

justjavac/rust_tinyget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinyget

ci Crate Documentation License

A tiny fork of minreq.

A simple, minimal-dependency HTTP client for Rust. It provides a clean and intuitive API for making HTTP requests with minimal overhead.

Features

  • Simple and intuitive API
  • Minimal dependencies
  • Optional HTTPS support via native-tls
  • Optional timeout support
  • Small binary size

Quick Start

Add this to your Cargo.toml:

[dependencies]
tinyget = "1.1"

Basic usage:

use tinyget;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Simple GET request
    let response = tinyget::get("https://httpbin.org/anything").send()?;
    println!("Response: {}", response.as_str()?);

    // With timeout
    let response = tinyget::get("https://httpbin.org/anything")
        .with_timeout(5)
        .send()?;
    println!("Response: {}", response.as_str()?);

    Ok(())
}

Advanced Usage

HTTPS Support

To enable HTTPS support, add the https feature:

[dependencies]
tinyget = { version = "1.1", features = ["https"] }

Timeout Support

To enable timeout support, add the timeout feature:

[dependencies]
tinyget = { version = "1.1", features = ["timeout"] }

You can set timeout in two ways:

  1. Per-request timeout:
let response = tinyget::get("https://httpbin.org/anything")
    .with_timeout(5)
    .send()?;
  1. Global timeout via environment variable:
TINYGET_TIMEOUT=5 cargo run

Custom Headers

let response = tinyget::get("https://httpbin.org/anything")
    .with_header("User-Agent", "tinyget/1.1")
    .send()?;

Binary Size

rustc 1.76.0 (07dca489a 2024-02-04)

debug release
hello 424,896 266,547
http 772,416(+348k) 319,856(+53k)
https 1,101,512(+677k) 344,432(+78k)

Size Comparison

http https
tinyget 283,920 319,632
minreq 300,328 959,744
ureq 695,632 1,371,368
reqwest 1,639,496 1,675,032

Examples

Check out the examples directory for more usage examples:

License

This crate is distributed under the terms of the MIT license.

About

Tiny HTTP client for GET

Topics

Resources

License

MIT, ISC licenses found

Licenses found

MIT
LICENSE
ISC
COPYING-minreq

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages