Skip to main content

Crate product_os_request

Crate product_os_request 

Source
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)

§Cargo Features

No features are enabled by default. Choose an implementation explicitly.

Core (no_std): uri, method, response, request

Std: method_std, response_std, request_std, std_base

Backends: std_reqwest, std_hyper, std (deprecated alias for std_reqwest)

Hyper add-ons: hyper_timeout, hyper_compression, hyper_cookies, hyper_proxy, std_hyper_full

Content: json, form

Streaming: stream, stream_reqwest, stream_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.55", 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);