feat: re-export reqwest and add opt-in reqwest-gzip feature#79
Merged
Conversation
Re-export reqwest as oneio::reqwest (under the http feature) so downstream crates can name HTTP types exposed in oneio's public API (StatusCode, header, blocking::Response) without declaring their own reqwest dependency and risking version skew. Add opt-in reqwest-gzip feature that enables reqwest's gzip content-encoding: requests advertise Accept-Encoding: gzip and gzipped responses are transparently decoded. Off by default, so dependency trees are unchanged unless explicitly enabled. Distinct from the gz family, which is URL-suffix-based file decompression. Motivation: bgpkit-commons#33 (conditional RPKI loading) currently needs a direct reqwest dependency solely to name these types and enable gzip.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes reqwest (used by oneio’s HTTP implementation) directly nameable by downstream crates via oneio::reqwest and adds an opt-in feature to enable reqwest’s transparent gzip content-encoding support, improving ergonomics and reducing dependency/version-skew risk for consumers.
Changes:
- Re-export
reqwestasoneio::reqwestbehind thehttpfeature, with crate docs demonstrating conditional GET usage. - Add
reqwest-gzipfeature (["http", "reqwest/gzip"]) and document it across crate docs/README/CHANGELOG. - Add integration tests for the re-export usage and gzip transparent decoding; extend CI to build/test the new feature combo.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/http_advanced_tests.rs | Adds mock-server integration tests for oneio::reqwest usage and gzip transparent decoding under reqwest-gzip. |
| src/lib.rs | Documents reqwest-gzip and introduces #[cfg(feature = "http")] pub use reqwest; re-export with example. |
| specs/README.md | Adds spec index entry for the new feature/spec. |
| specs/03-reqwest-reexport-http-gzip/README.md | Adds the detailed design spec for reqwest re-export + opt-in gzip. |
| README.md | Documents reqwest-gzip and updates examples to use oneio::reqwest types. |
| CHANGELOG.md | Records the new public re-export and reqwest-gzip feature under Unreleased. |
| Cargo.toml | Introduces the reqwest-gzip feature forwarding to reqwest/gzip. |
| .github/workflows/rust.yml | Adds CI build and test legs for reqwest-gzip (and its integration tests). |
Comment on lines
+31
to
+35
| loop { | ||
| let bytes_read = stream.read(&mut buffer).unwrap(); | ||
| if bytes_read == 0 { | ||
| break; | ||
| } |
Comment on lines
+20
to
+28
| **Success criteria:** | ||
| - [ ] `oneio::reqwest` resolves when the `http` feature is enabled (e.g. | ||
| `oneio::reqwest::StatusCode::NOT_MODIFIED` compiles downstream) | ||
| - [ ] With `reqwest-gzip`, requests advertise `Accept-Encoding: gzip` and | ||
| `Content-Encoding: gzip` responses are transparently decoded | ||
| - [ ] Without `reqwest-gzip`, dependency tree is unchanged (no gzip decoder crates) | ||
| - [ ] Conditional-GET workflow (send `If-None-Match`, read `304` status and | ||
| `ETag`/`Last-Modified` response headers) is possible using only oneio's API | ||
| - [ ] All quality gates pass: fmt, build, test, clippy (`-D warnings`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-exports
reqwestasoneio::reqwest(under thehttpfeature) and adds an opt-inreqwest-gzipfeature enabling reqwest's transparent gzip content-encoding.Motivation: oneio's public API already exposes reqwest types (
OneIo::get_http_reader_raw()returnsreqwest::blocking::Response, the builder exposeshttp_client()), but downstream crates cannot name those types without declaring their own reqwest dependency — risking version skew. Separately, oneio's reqwest build does not enable gzip, so payload-gzipped endpoints (e.g.https://rpki.cloudflare.com/rpki.json: ~97 MB plain, ~4.6 MB gzipped) cannot benefit; oneio's own decompression is URL-suffix-based. Concrete downstream need: bgpkit/bgpkit-commons#33 (conditional RPKI loading, bgpkit/bgpkit-commons#34).Related Spec
specs/03-reqwest-reexport-http-gzip/README.mdChanges
pub use reqwest;(gated onhttp) with doc example showing a conditional-GET workflow (If-None-Match→304, readingETag/Last-Modified). Semver implication documented: reqwest becomes part of the public API contract, so a future reqwest major bump is a breaking oneio change — acceptable since the types already leak in public signatures.reqwest-gzip = ["http", "reqwest/gzip"]feature: pure passthrough, no cfg-gated code. AdvertisesAccept-Encoding: gzip, transparently decodes responses. Off by default — verifiedflate2absent fromcargo treewithout the feature, present with it. Named to disambiguate from thegzfamily (suffix-based file decompression); pattern extends toreqwest-brotli/reqwest-deflatelater.tests/http_advanced_tests.rs, in-process mock server, no external network):test_reqwest_reexport_conditional_get— 200 withETagcapture viaoneio::reqwest::header::ETAG, thenIf-None-Match→StatusCode::NOT_MODIFIEDtest_reqwest_gzip_transparent_decode— gzipped body +Content-Encoding: gzipdecodes transparently; asserts the request advertisedAccept-Encoding: gziponeio::reqwest::header, CHANGELOG entry.reqwest-gzip,rustlsand a test leg running the new integration tests.Testing
cargo test --features reqwest-gzip --test http_advanced_tests: 2 passedcargo test --all-features: all suites pass (43 + 24 + 10 + 9 + 2 passed, 0 failed)cargo test --doc --all-features: pass (includes the new re-export doc example)cargo fmt --check,cargo clippy --all-features -- -D warnings,cargo clippy --no-default-features -- -D warnings: cleancargo treecheck: no gzip decoder crates without the feature;flate2/async-compressionpresent with itChecklist
specs/03-reqwest-reexport-http-gzip/)