Product OS : Request
Product OS : Request provides a fully featured HTTP request library with multiple implementation choices, allowing you to select between reqwest (high-level) or hyper (low-level) backends while maintaining a consistent API.
Features
- Multiple Implementations - Choose between reqwest or hyper backends
- Async HTTP Requests - Built on tokio for high-performance async I/O
- Default HTTPS/TLS - Secure by default using Rustls
- Requester Pattern - Reusable configuration for multiple requests
- Custom Request/Response Types - Type-safe request building and response handling
- Proxy Support - HTTP, HTTPS, and SOCKS5 proxy configuration
- Redirect Policies - Configurable redirect handling
- Certificate Management - Custom trusted certificates support
- Streaming Responses - Optional streaming support for large responses
- no_std Support - Works in no_std environments with alloc
- Comprehensive Documentation - Well-documented with examples
Installation
Using Reqwest (High-Level, More Features)
[]
= { = "0.0.48", = false, = ["std_reqwest"] }
= { = "1", = ["full"] }
Using Hyper (Low-Level, More Control)
[]
= { = "0.0.48", = false, = ["std_hyper"] }
= { = "1", = ["full"] }
Backward Compatible (defaults to reqwest)
[]
= "0.0.48"
= { = "1", = ["full"] }
Quick Start
Simple GET Request (Reqwest)
use ;
async
Simple GET Request (Hyper)
use ;
async
POST with JSON
use ;
use json;
async
Features
Product OS Request supports optional features that can be enabled as needed:
[]
= { = "0.0.48", = ["json", "form", "stream"] }
Available features:
std(default) - Full standard library support with reqwest integrationjson- JSON serialization/deserialization supportform- Form-encoded body supportstream- Streaming response supportmethod- Method enum only (no_std compatible)request- Request building (no_std compatible)response- Response handling (no_std compatible)
no_std Support
To use in a no_std environment:
[]
= { = "0.0.48", = false, = ["method", "request"] }
Examples
The library includes comprehensive examples in this README demonstrating common use cases.
Simple GET Request Example
Configuration Options
Requester Configuration
let mut requester = new;
// Timeouts
requester.set_timeout; // Request timeout in ms
requester.set_connect_timeout; // Connection timeout in ms
// Security
requester.force_secure; // HTTPS only
requester.trust_all_certificates; // Certificate validation
// Redirects
use RedirectPolicy;
requester.set_redirect_policy;
// Proxy
use Protocol;
requester.set_proxy;
// Custom certificates
let cert_der = include_bytes!;
requester.add_trusted_certificate_pem;
// Default headers
requester.add_header;
Request Building
let mut request = client.new_request;
// Headers
request.add_header;
request.add_header; // marked as sensitive
// Authentication
request.bearer_auth;
// Query parameters
request.add_param;
request.add_param;
// Body
use Bytes;
use BodyBytes;
let body = new;
request.set_body;
Response Handling
let response = client.request.await?;
// Status
let status = response.status_code;
println!;
// Headers
let headers = response.get_headers;
for in headers
// URL (after redirects)
let url = response.response_url;
// Body as text
let text = client.text.await?;
// Body as JSON
let json = client.json.await?;
// Body as bytes
let bytes = client.bytes.await?;
API Documentation
For detailed API documentation, visit docs.rs/product-os-request.
What is Product OS?
Product OS is a collection of packages that provide different tools and features that can work together to build products more easily for the Rust ecosystem.
Contributing
Contributions are not currently available but will be available on a public repository soon.
License
Changelog
See CHANGELOG.md for version history and changes.
Testing
Run the test suite:
# Test reqwest implementation
# Test hyper implementation
# Test both implementations
&& \
# Specific feature combination
# With output
Implementation Comparison
Product OS Request offers two HTTP client implementations:
Reqwest Implementation (std_reqwest)
Pros:
- Battle-tested, mature library
- More convenience features out of the box
- Simpler internal architecture
- Well-documented ecosystem
Cons:
- Larger dependency tree
- Less control over low-level details
- Updates depend on upstream reqwest releases
Hyper Implementation (std_hyper)
Pros:
- Lower-level control over HTTP behavior
- Smaller dependency tree
- Direct access to hyper's connection management
- More customization options
- Potentially better performance
Cons:
- More complex internal implementation
- Some features require manual implementation
- Less mature than reqwest integration
Feature Parity Matrix
| Feature | reqwest_impl | hyper_impl | Status |
|---|---|---|---|
| GET/POST/etc | ✅ | ✅ | Full parity |
| Headers | ✅ | ✅ | Full parity |
| Query params | ✅ | ✅ | Full parity |
| Request body | ✅ | ✅ | Full parity |
| JSON body | ✅ | ✅ | Full parity |
| Form body | ✅ | ✅ | Full parity |
| Timeouts | ✅ | ⚠️ | Partial (configured, not enforced yet) |
| Redirects | ✅ | ✅ | Full parity |
| Proxies (HTTP/HTTPS) | ✅ | ⚠️ | Planned |
| Proxies (SOCKS5) | ✅ | ⚠️ | Planned |
| TLS/HTTPS | ✅ | ✅ | Full parity |
| Custom certs | ✅ | ✅ | Full parity |
| Trust all certs | ✅ | ✅ | Full parity |
| Compression | ✅ | ⚠️ | Dependencies added, not integrated |
| Cookies | ✅ | ⚠️ | Dependencies added, not integrated |
| Streaming | ✅ | ✅ | Full parity |
| Connection pooling | ✅ | ✅ | Full parity |
Status Legend:
- ✅ Fully implemented and tested
- ⚠️ Partial implementation or dependencies added
- ❌ Not implemented
Performance
Product OS Request supports multiple backends:
Reqwest-based:
- Async/await support for efficient concurrency
- Connection pooling and reuse
- HTTP/2 support
- Compression support (gzip, brotli)
- Streaming for large responses
Hyper-based:
- Direct hyper integration for lower overhead
- Fine-tuned connection pool settings
- HTTP/1 and HTTP/2 support
- Streaming with native hyper Body traits
- Reduced abstraction layers
Safety
This library:
- Uses
#![warn(clippy::unwrap_used)]to avoid panics - Provides proper error handling throughout
- Supports no_std for embedded environments
- Has comprehensive test coverage (112+ tests)
Comparison with Other Libraries
| Feature | product-os-request | reqwest | hyper | ureq |
|---|---|---|---|---|
| Async | ✅ | ✅ | ✅ | ❌ |
| Sync | ❌ | ✅ (blocking) | ❌ | ✅ |
| no_std | ✅ | ❌ | ❌ | ❌ |
| Builder Pattern | ✅ | ✅ | ⚠️ | ✅ |
| Streaming | ✅ | ✅ | ✅ | ❌ |
| Type-safe | ✅ | ✅ | ✅ | ✅ |
| Multiple Backends | ✅ | ❌ | N/A | ❌ |
| Requester Pattern | ✅ | ❌ | ❌ | ❌ |
Product OS Request provides a unique combination of features:
- Abstraction Layer: Unified API across multiple HTTP client implementations
- Requester Pattern: Reusable configuration for managing multiple requests
- Implementation Choice: Select between high-level (reqwest) or low-level (hyper) backends
- no_std Support: Core types work in constrained environments
- Consistent API: Same code works with different backends