http_req
Simple and lightweight HTTP client with built-in HTTPS support.
- HTTP and HTTPS via rust-native-tls (or optionally rustls)
- Small binary size (0.7 MB for a basic GET request in the default configuratio)
- Minimal number of dependencies
Requirements
http_req by default uses rust-native-tls, which relies on TLS framework provided by OS on Windows and macOS, and OpenSSL on all other platforms. But it also supports rustls.
All functionalities
- Support for both HTTP and HTTPS protocols via rust-native-tls (or optionally rustls)
- Creating and sending HTTP requests using the
Requesttype (with extended capabilities provided viaRequestMessageandStream) - Representing HTTP responses with the
Responsetype, allowing easy access to details like the status code and headers - Handling redirects using the
RedirectPolicy - Support for Basic and Bearer authentication
- Processing responses with
Transfer-Encoding: chunked - Managing absolute
Uris and partial support for relativeUris - Enforcing timeouts on requests
- Downloading data in a streaming fashion, allowing direct saving to disk (minimizing RAM usage)
Errorhandling system allowing for better debugging- Utility functions for easily sending common request types:
get,head,post
Usage
Default configuration
In order to use http_req with default configuration, add the following lines to Cargo.toml:
[]
= "^0.14"
Rustls
In order to use http_req with rustls in your project, add the following lines to Cargo.toml:
[]
= { ="^0.14", = false, = ["rust-tls"] }
HTTP only
In order to use http_req without any additional features in your project (no HTTPS, no Authentication), add the following lines to Cargo.toml:
[]
= { ="^0.14", = false }
Example
Basic HTTP GET request
use request;
Take a look at more examples
License
Licensed under MIT.