OxHTTP is a very simple synchronous implementation of an HTTP 1.1 client and server in Rust.
OxHTTP provides a very simple client. It aims at following the basic concepts of the Web Fetch standard without the bits specific to web browsers (context, CORS...).
HTTPS is supported behind the disabled by default native-tls
feature.
Example:
rust
let client = Client::new();
let response = client.request(Request::new(Method::GET, "http://example.com".parse()?))?;
OxHTTP provides a very simple threaded HTTP server. It is still a work in progress. Use at your own risks!
Example:
rust
// Builds a new server that returns a 404 everywhere except for "/" where it returns the body 'home' "/
let mut server = Server::new(|request| {
if request.url().path() == "/" {
Response::new(Status::OK).with_body("home")
} else {
Response::new(Status::NOT_FOUND)
}
});
// Raise a timeout error if the client does not respond after 10s.
server.set_global_timeout(Some(Duration::from_secs(10)));
// Listen to localhost:8080
server.listen(("localhost", 8080))?;
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Futures by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.