1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#![deny(missing_docs)]
//! Simple, virtually-zero-dependencies HTTP client wrapping a system client.
//!
//! "Virtually-zero" means no unnecessary runtime dependencies. The only runtime dependency, other than `std`, is URL validation, which is required for security reasons.
//!
//! ## Supported Backends
//!
//! * wget
//! * cURL
//! * PowerShell (`Invoke-WebRequest`)
//! # Usage
//!
//! In your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! sysreq = "0.1"
//! ```
//!
//! In your code:
//!
//! ```rust
//! let html = sysreq::get("https://www.rust-lang.org/").unwrap();
//! println!("{}", String::from_utf8_lossy(&html));
//! ```
#[cfg(test)]
mod tests;
mod error;
pub use error::Error;
mod clients;
use clients::{resolve::resolve, SystemHttpClientInterface};
pub use clients::{
resolve::{http_client, installed},
supported_http_clients, SystemHttpClient,
};
mod url;
use self::url::ValidUrl;
mod request;
pub use request::RequestBuilder;
/// Perform a GET request to the given URL
pub fn get(url: impl ValidUrl) -> Result<Vec<u8>, Error> {
Ok(resolve()?.get(url.validate()?, None)?.body)
}