https://github.com/justjavac/rust_tinyget
Tiny HTTP client for GET
https://github.com/justjavac/rust_tinyget
http http-client https rust rust-crate rust-lang rust-library tiny
Last synced: 10 months ago
JSON representation
Tiny HTTP client for GET
- Host: GitHub
- URL: https://github.com/justjavac/rust_tinyget
- Owner: justjavac
- License: mit
- Created: 2021-01-28T05:22:14.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-08T02:11:21.000Z (over 1 year ago)
- Last Synced: 2025-03-10T11:42:44.869Z (11 months ago)
- Topics: http, http-client, https, rust, rust-crate, rust-lang, rust-library, tiny
- Language: Rust
- Homepage: https://crates.io/crates/tinyget
- Size: 53.7 KB
- Stars: 19
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING-minreq
Awesome Lists containing this project
README
# tinyget
[](https://github.com/justjavac/rust_tinyget/actions/workflows/ci.yml)
[](https://crates.io/crates/tinyget)
[](https://docs.rs/tinyget)

> A tiny fork of [minreq](https://crates.io/crates/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`:
```toml
[dependencies]
tinyget = "1.1"
```
Basic usage:
```rust
use tinyget;
fn main() -> Result<(), Box> {
// 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:
```toml
[dependencies]
tinyget = { version = "1.1", features = ["https"] }
```
### Timeout Support
To enable timeout support, add the `timeout` feature:
```toml
[dependencies]
tinyget = { version = "1.1", features = ["timeout"] }
```
You can set timeout in two ways:
1. Per-request timeout:
```rust
let response = tinyget::get("https://httpbin.org/anything")
.with_timeout(5)
.send()?;
```
2. Global timeout via environment variable:
```bash
TINYGET_TIMEOUT=5 cargo run
```
### Custom Headers
```rust
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**][1] | 424,896 | 266,547 |
| [**http**][2] | 772,416(+348k) | 319,856(+53k) |
| [**https**][3] | 1,101,512(+677k) | 344,432(+78k) |
[1]: ./examples/hello.rs
[2]: ./examples/http.rs
[3]: ./examples/https.rs
## 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](./examples) directory for more usage examples:
- [Basic HTTP request](./examples/http.rs)
- [HTTP request with timeout](./examples/http_timeout.rs)
- [HTTPS request](./examples/https.rs)
- [HTTPS request with timeout](./examples/https_timeout.rs)
- [Iterator example](./examples/iterator.rs)
## License
This crate is distributed under the terms of the [MIT license](./LICENSE).