Skip to content

Commit 015716d

Browse files
authored
Merge pull request #71 from jayjamesjay/v0.14
V0.14
2 parents 8aae578 + acd45cd commit 015716d

File tree

15 files changed

+496
-306
lines changed

15 files changed

+496
-306
lines changed

.github/workflows/rust.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ on: [push]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98

109
steps:
11-
- uses: actions/checkout@v1
12-
- name: Build
13-
run: cargo build --verbose
14-
- name: Build with Rusttls
15-
run: cargo build --verbose --no-default-features --features rust-tls
16-
- name: Run tests
17-
run: cargo test --verbose
10+
- uses: actions/checkout@v1
11+
- name: Build
12+
run: cargo build --verbose
13+
- name: Build with Rusttls
14+
run: cargo build --verbose --no-default-features --features rust-tls
15+
- name: Run tests
16+
run: cargo test --verbose
17+
- name: Run tests with rust-tls
18+
run: cargo test --verbose --no-default-features --features rust-tls

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Contributing
2-
Code and documentation PRs are always welcome. Just remember to list out introduced changes.
2+
Code contributions and documentation improvements are always welcome! Please include a clear description of the changes introduced in your pull requests.
33

4-
If you want to suggest some improvements, report a bug, discuss a functionality, etc., feel free to open an issue.
4+
For suggestions, bug reports, or feature requests, please open an issue.

Cargo.lock

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "http_req"
3-
version = "0.13.3"
3+
version = "0.14.0"
44
license = "MIT"
55
description = "simple and lightweight HTTP client with built-in HTTPS support"
66
repository = "https://github.com/jayjamesjay/http_req"
@@ -12,8 +12,8 @@ edition = "2021"
1212

1313
[dependencies]
1414
unicase = "^2.8"
15-
base64 = "^0.22.1"
16-
zeroize = { version = "^1.8.1", features = ["zeroize_derive"] }
15+
base64 = { version = "^0.22.1", optional = true }
16+
zeroize = { version = "^1.8.1", features = ["zeroize_derive"], optional = true }
1717
native-tls = { version = "^0.2", optional = true }
1818
rustls = { version = "^0.23", optional = true }
1919
rustls-pemfile = { version = "^2.2", optional = true }
@@ -22,11 +22,13 @@ webpki = { version = "^0.22", optional = true }
2222
webpki-roots = { version = "^0.26", optional = true }
2323

2424
[features]
25-
default = ["native-tls"]
25+
default = ["native-tls", "auth"]
2626
rust-tls = [
2727
"rustls",
2828
"rustls-pki-types",
2929
"webpki",
3030
"webpki-roots",
3131
"rustls-pemfile",
32+
"auth",
3233
]
34+
auth = ["base64", "zeroize"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018-2024 jayjamesjay
3+
Copyright (c) 2018-2025 jayjamesjay
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
# http_req
22

33
[![Rust](https://github.com/jayjamesjay/http_req/actions/workflows/rust.yml/badge.svg)](https://github.com/jayjamesjay/http_req/actions/workflows/rust.yml)
4-
[![Crates.io](https://img.shields.io/badge/crates.io-v0.13.3-orange.svg?longCache=true)](https://crates.io/crates/http_req)
5-
[![Docs.rs](https://docs.rs/http_req/badge.svg)](https://docs.rs/http_req/0.13.3/http_req/)
4+
[![Crates.io](https://img.shields.io/badge/crates.io-v0.14.0-orange.svg?longCache=true)](https://crates.io/crates/http_req)
5+
[![Docs.rs](https://docs.rs/http_req/badge.svg)](https://docs.rs/http_req/0.14.0/http_req/)
66

77
Simple and lightweight HTTP client with built-in HTTPS support.
88

9-
- HTTP and HTTPS via [rust-native-tls](https://github.com/sfackler/rust-native-tls) (or optionally [rus-tls](https://crates.io/crates/rustls))
9+
- HTTP and HTTPS via [rust-native-tls](https://crates.io/crates/native-tls) (or optionally [rustls](https://crates.io/crates/rustls))
1010
- Small binary size (0.7 MB for a basic GET request in the default configuratio)
1111
- Minimal number of dependencies
1212

1313
## Requirements
1414

15-
http_req by default uses [rust-native-tls](https://github.com/sfackler/rust-native-tls),
15+
http_req by default uses [rust-native-tls](https://crates.io/crates/native-tls),
1616
which relies on TLS framework provided by OS on Windows and macOS, and OpenSSL
17-
on all other platforms. But it also supports [rus-tls](https://crates.io/crates/rustls).
18-
19-
## Example
20-
21-
Basic HTTP GET request
22-
23-
```rust
24-
use http_req::request;
25-
26-
fn main() {
27-
let mut body = Vec::new(); //Container for body of a response.
28-
let res = request::get("https://doc.rust-lang.org/", &mut body).unwrap();
29-
30-
println!("Status: {} {}", res.status_code(), res.reason());
31-
}
32-
```
33-
34-
Take a look at [more examples](https://github.com/jayjamesjay/http_req/tree/master/examples)
17+
on all other platforms. But it also supports [rustls](https://crates.io/crates/rustls).
18+
19+
## All functionalities
20+
21+
- Support for both HTTP and HTTPS protocols via [rust-native-tls](https://crates.io/crates/native-tls) (or optionally [rustls](https://crates.io/crates/rustls))
22+
- Creating and sending HTTP requests using the `Request` type (with extended capabilities provided via `RequestMessage` and `Stream`)
23+
- Representing HTTP responses with the `Response` type, allowing easy access to details like the status code and headers
24+
- Handling redirects using the `RedirectPolicy`
25+
- Support for Basic and Bearer authentication
26+
- Processing responses with `Transfer-Encoding: chunked`
27+
- Managing absolute `Uri`s and partial support for relative `Uri`s
28+
- Enforcing timeouts on requests
29+
- Downloading data in a streaming fashion, allowing direct saving to disk (minimizing RAM usage)
30+
- `Error` handling system allowing for better debugging
31+
- Utility functions for easily sending common request types: `get`, `head`, `post`
3532

3633
## Usage
3734

@@ -41,7 +38,7 @@ In order to use `http_req` with default configuration, add the following lines t
4138

4239
```toml
4340
[dependencies]
44-
http_req = "^0.13"
41+
http_req = "^0.14"
4542
```
4643

4744
### Rustls
@@ -50,9 +47,35 @@ In order to use `http_req` with `rustls` in your project, add the following line
5047

5148
```toml
5249
[dependencies]
53-
http_req = { version="^0.13", default-features = false, features = ["rust-tls"] }
50+
http_req = { version="^0.14", default-features = false, features = ["rust-tls"] }
51+
```
52+
53+
### HTTP only
54+
55+
In order to use `http_req` without any additional features in your project (no HTTPS, no Authentication), add the following lines to `Cargo.toml`:
56+
57+
```toml
58+
[dependencies]
59+
http_req = { version="^0.14", default-features = false }
60+
```
61+
62+
## Example
63+
64+
Basic HTTP GET request
65+
66+
```rust
67+
use http_req::request;
68+
69+
fn main() {
70+
let mut body = Vec::new(); //Container for body of a response.
71+
let res = request::get("https://doc.rust-lang.org/", &mut body).unwrap();
72+
73+
println!("Status: {} {}", res.status_code(), res.reason());
74+
}
5475
```
5576

77+
Take a look at [more examples](https://github.com/jayjamesjay/http_req/tree/master/examples)
78+
5679
## License
5780

5881
Licensed under [MIT](https://github.com/jayjamesjay/http_req/blob/master/LICENSE).

examples/authentication.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77
// Container for body of a response.
88
let mut body = Vec::new();
99
// URL of the website.
10-
let uri = Uri::try_from("http://httpbin.org/basic-auth/foo/bar").unwrap();
10+
let uri = Uri::try_from("https://httpbin.org/basic-auth/foo/bar").unwrap();
1111
// Authentication details: username and password.
1212
let auth = Authentication::basic("foo", "bar");
1313

0 commit comments

Comments
 (0)