Expand description
Product OS : Request
Product OS : Request provides a fully featured HTTP request library combining elements of reqwest and hyper for async requests with a series of helper methods to allow for easier usage depending upon your needs for one-time or repeat usage.
§Features
- Default support for HTTPS / TLS using Rustls
- A requester concept for managing multiple requests
- One-time request support
- Async requests
- Custom Request and Response structs
- Helpers for managing conditions such as managing specific trusted certificates
- Helpers for defining redirect policies
- Requester build flows to ensure specific settings are defined
- Support no_std with alloc only environments
- Choice of HTTP backends: reqwest (
std_reqwest) or hyper (std_hyper)
§Usage
Use ProductOSRequestClient for portable code that works with either backend:
use product_os_request::{Method, ProductOSRequestClient, ProductOSRequester, ProductOSClient};
// Create a client (works with either reqwest or hyper backend)
let mut requester = ProductOSRequester::new();
requester.set_timeout(5000);
let mut client = ProductOSRequestClient::new();
requester.build(&mut client);
// Make a request
let mut request = client.new_request(Method::GET, "https://api.example.com/data");
request.add_header("User-Agent", "ProductOS-Request/0.0.51", false);For explicit backend selection, use ProductOSReqwestClient or ProductOSHyperClient directly:
use product_os_request::{Method, ProductOSHyperClient, ProductOSRequester, ProductOSClient};
let mut requester = ProductOSRequester::new();
let mut client = ProductOSHyperClient::new();
requester.build(&mut client);