Skip to content

Commit 91de857

Browse files
authored
v0.3.0 - full http/1.1 GET and HEAD (#6)
* v0.3.0 - full http/1.1 GET and HEAD
1 parent a03b13e commit 91de857

File tree

38 files changed

+12149
-832
lines changed

38 files changed

+12149
-832
lines changed

.github/workflows/checker.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Checker
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- opened
9+
- reopened
10+
- synchronize
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
compliance-docs:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v6
22+
23+
- name: Validate compliance matrix/index drift
24+
run: python3 tools/check_compliance_docs.py
25+
26+
fmt:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v6
31+
32+
- name: Install stable
33+
run: rustup toolchain install stable --profile minimal --component rustfmt
34+
35+
- name: Check formatting
36+
run: cargo +stable fmt --all -- --check
37+
38+
clippy-http:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v6
43+
44+
- name: Install stable
45+
run: rustup toolchain install stable --profile minimal --component clippy
46+
47+
- name: Lint HTTP-only build
48+
run: cargo +stable clippy --workspace --all-targets --no-default-features --features http -- -D warnings
49+
50+
clippy-all-features:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v6
55+
56+
- name: Install OpenSSL headers
57+
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
58+
59+
- name: Install stable
60+
run: rustup toolchain install stable --profile minimal --component clippy
61+
62+
- name: Lint all features
63+
run: cargo +stable clippy --workspace --all-targets --all-features -- -D warnings
64+
65+
test-http:
66+
runs-on: ubuntu-latest
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
toolchain:
71+
- "1.71.0"
72+
- stable
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v6
76+
77+
- name: Install Rust
78+
run: rustup toolchain install ${{ matrix.toolchain }} --profile minimal
79+
80+
- name: Resolve HTTP-only dependency graph
81+
run: |
82+
rm -f Cargo.lock
83+
cargo +${{ matrix.toolchain }} test --workspace --no-default-features --features http --no-run
84+
85+
- name: Test HTTP-only build with locked dependencies
86+
run: cargo +${{ matrix.toolchain }} test --workspace --no-default-features --features http --locked
87+
88+
test-all-features:
89+
runs-on: ubuntu-latest
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
toolchain:
94+
- "1.71.0"
95+
- stable
96+
steps:
97+
- name: Checkout
98+
uses: actions/checkout@v6
99+
100+
- name: Install OpenSSL headers
101+
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
102+
103+
- name: Install Rust
104+
run: rustup toolchain install ${{ matrix.toolchain }} --profile minimal
105+
106+
- name: Resolve all-features dependency graph
107+
run: |
108+
rm -f Cargo.lock
109+
cargo +${{ matrix.toolchain }} test --workspace --all-features --no-run
110+
111+
- name: Test all features with locked dependencies
112+
run: cargo +${{ matrix.toolchain }} test --workspace --all-features --locked
113+
114+
coverage-http:
115+
runs-on: ubuntu-latest
116+
steps:
117+
- name: Checkout
118+
uses: actions/checkout@v6
119+
120+
- name: Install stable
121+
run: rustup toolchain install stable --profile minimal
122+
123+
- name: Install cargo-llvm-cov
124+
uses: taiki-e/install-action@cargo-llvm-cov
125+
126+
- name: Enforce HTTP-only 100% line coverage
127+
run: |
128+
cargo llvm-cov clean --workspace
129+
cargo llvm-cov --workspace --no-default-features --features http \
130+
--lcov \
131+
--output-path /tmp/http_cov.info
132+
python3 tools/check_line_coverage.py --lcov /tmp/http_cov.info --root . --require 95
133+
134+
coverage-all-features:
135+
runs-on: ubuntu-latest
136+
steps:
137+
- name: Checkout
138+
uses: actions/checkout@v6
139+
140+
- name: Install OpenSSL headers
141+
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
142+
143+
- name: Install stable
144+
run: rustup toolchain install stable --profile minimal
145+
146+
- name: Install cargo-llvm-cov
147+
uses: taiki-e/install-action@cargo-llvm-cov
148+
149+
- name: Enforce all-features 100% line coverage
150+
run: |
151+
cargo llvm-cov clean --workspace
152+
cargo llvm-cov --workspace --all-features \
153+
--lcov \
154+
--output-path /tmp/all_cov.info
155+
python3 tools/check_line_coverage.py --lcov /tmp/all_cov.info --root . --require 95

.github/workflows/publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
publish:
13+
if: github.event.release.target_commitish == 'main'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v6
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Fetch main
22+
run: git fetch origin main
23+
24+
- name: Verify release commit is on main
25+
run: git merge-base --is-ancestor "$GITHUB_SHA" origin/main
26+
27+
- name: Verify release tag matches Cargo version
28+
env:
29+
RELEASE_TAG: ${{ github.event.release.tag_name }}
30+
run: |
31+
python3 - <<'PY'
32+
import os
33+
import tomllib
34+
from pathlib import Path
35+
36+
cargo = tomllib.loads(Path("Cargo.toml").read_text())
37+
expected = f"v{cargo['package']['version']}"
38+
actual = os.environ["RELEASE_TAG"]
39+
if actual != expected:
40+
raise SystemExit(f"release tag {actual!r} does not match Cargo.toml version {expected!r}")
41+
PY
42+
43+
- name: Install OpenSSL headers
44+
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
45+
46+
- name: Install stable
47+
run: rustup toolchain install stable --profile minimal
48+
49+
- name: Resolve publish dependency graph
50+
run: |
51+
rm -f Cargo.lock
52+
cargo +stable test --workspace --all-features --no-run
53+
54+
- name: Verify tests
55+
run: cargo +stable test --workspace --all-features --locked
56+
57+
- name: Publish to crates.io
58+
env:
59+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
60+
run: cargo +stable publish --locked --token "$CARGO_REGISTRY_TOKEN"

.github/workflows/rust.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

Cargo.toml

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[package]
22
name = "nano-get"
33
description = """
4-
A very tiny implementation of HTTP(s) GET, using minimal dependencies.
4+
A tiny HTTP/1.1 GET and HEAD client with zero dependencies by default.
55
"""
6-
version = "0.2.4"
6+
version = "0.3.0"
77
authors = ["Rahul Thomas <rapidclock@users.noreply.github.com>"]
8-
edition = "2018"
8+
edition = "2021"
9+
rust-version = "1.71"
910
license = "MIT"
1011
repository = "https://github.com/rapidclock/nano-get"
1112
documentation = "https://docs.rs/nano-get"
@@ -23,9 +24,55 @@ readme = "README.md"
2324
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2425

2526
[dependencies]
26-
openssl = { version = "0.10.29", optional = true }
27+
openssl = { version = "0.10.75", optional = true }
2728

2829
[features]
2930
http = []
3031
https = ["openssl"]
31-
default = ["http"]
32+
default = ["http"]
33+
34+
[[example]]
35+
name = "simple-get"
36+
path = "examples/simple-get/main.rs"
37+
38+
[[example]]
39+
name = "get-bytes"
40+
path = "examples/get-bytes/main.rs"
41+
42+
[[example]]
43+
name = "head-request"
44+
path = "examples/head-request/main.rs"
45+
46+
[[example]]
47+
name = "request-builder"
48+
path = "examples/request-builder/main.rs"
49+
50+
[[example]]
51+
name = "protocol-specific-helpers"
52+
path = "examples/protocol-specific-helpers/main.rs"
53+
required-features = ["https"]
54+
55+
[[example]]
56+
name = "session-reuse-and-pipelining"
57+
path = "examples/session-reuse-and-pipelining/main.rs"
58+
59+
[[example]]
60+
name = "memory-cache"
61+
path = "examples/memory-cache/main.rs"
62+
63+
[[example]]
64+
name = "basic-auth"
65+
path = "examples/basic-auth/main.rs"
66+
67+
[[example]]
68+
name = "custom-auth-handler"
69+
path = "examples/custom-auth-handler/main.rs"
70+
71+
[[example]]
72+
name = "proxy-and-proxy-auth"
73+
path = "examples/proxy-and-proxy-auth/main.rs"
74+
75+
[[example]]
76+
name = "advanced-client"
77+
path = "examples/advanced-client/main.rs"
78+
required-features = ["https"]

0 commit comments

Comments
 (0)