Debian Codegraph @

/

debian rust-oxhttp 0.3.3+ds-1debian librust-oxhttp-dev debian librust-oxhttp-0.3+client-dev debian librust-oxhttp-0.3+default-dev debian librust-oxhttp-0.3+flate2-dev debian librust-oxhttp-0.3+native-tls-dev debian librust-oxhttp-0.3+rustls-ring-native-dev debian librust-oxhttp-0.3+server-dev debian librust-oxhttp-0.3-dev debian librust-oxhttp-0.3.3-dev debianinimakefilemarkdownrustshelltoml 31 files · 118 symbols
View dependency graph

Depends on

  • debhelper (dh-sequence-single-binary)
  • dh-rust (dh-sequence-rust)
  • rust-flate2 (librust-flate2-dev)
  • rust-http (librust-http-dev)
  • rust-httparse (librust-httparse-dev)
  • rust-lazy-static (librust-lazy-static-dev)
  • debhelper-compat, librust-native-tls-dev, librust-rustls-dev, librust-rustls-pki-types-dev, librust-rustls-platform-verifier-dev, librust-url-dev
README (full)

OxHTTP

actions status Latest Version Released API docs

OxHTTP is a simple and naive synchronous implementation of HTTP 1.1 in Rust. It provides both a client and a server. It does not aim to be a fully-working-in-all-cases HTTP implementation but to be only a simple one to be use in simple usecases.

Client

OxHTTP provides a 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 features. To enable it, you need to enable one of the following features:

Example:

use oxhttp::Client;
use oxhttp::model::{Body, Request, Method, StatusCode, HeaderName};
use oxhttp::model::header::CONTENT_TYPE;
use std::io::Read;

let client = Client::new();
let response = client.request(Request::builder().uri("http://example.com").body(Body::empty()).unwrap()).unwrap();
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(response.headers().get(CONTENT_TYPE).unwrap(), "text/html");

let body = response.into_body().to_string().unwrap();

Server

OxHTTP provides a threaded HTTP server. It is still a work in progress. Use at your own risks behind a reverse proxy!

Example:

use std::net::{Ipv4Addr, Ipv6Addr};
use oxhttp::Server;
use oxhttp::model::{Body, Response, StatusCode};
use std::time::Duration;

// 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.uri().path() == "/" {
Response::builder().body(Body::from("home")).unwrap()
} else {
Response::builder().status(StatusCode::NOT_FOUND).body(Body::empty()).unwrap()
}
});
// We bind the server to localhost on both IPv4 and v6
server = server.bind((Ipv4Addr::LOCALHOST, 8080)).bind((Ipv6Addr::LOCALHOST, 8080));
// Raise a timeout error if the client does not respond after 10s.
server = server.with_global_timeout(Duration::from_secs(10));
// Limits the max number of concurrent connections to 128.
server = server.with_max_concurrent_connections(128);
// We spawn the server and block on it
server.spawn().unwrap().join().unwrap();

License

This project is licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or <http://www.apache.org/licenses/LICENSE-2.0>)
  • MIT license (LICENSE-MIT or <http://opensource.org/licenses/MIT>)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in OxHTTP by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

dir benches/
dir debian/
dir src/
file AGENTS.md
file CHANGELOG.md
file Cargo.toml
file LICENSE-APACHE
file LICENSE-MIT
file README.md
file deny.toml
file typos.toml