| Crates.io | avx-http |
| lib.rs | avx-http |
| version | 0.4.0 |
| created_at | 2025-11-22 21:08:20.853608+00 |
| updated_at | 2025-11-27 15:54:50.986709+00 |
| description | Pure Rust HTTP/1.1 + HTTP/2 implementation with ZERO dependencies - no tokio, no serde, no hyper, 100% proprietary |
| homepage | https://avila.inc |
| repository | https://github.com/avilaops/arxis |
| max_upload_size | |
| id | 1945738 |
| size | 464,687 |
100% proprietary HTTP implementation with ZERO external dependencies!
[dependencies]
avx-http = "0.4"
No other dependencies needed! Not even tokio.
use avx_http::async_net::AsyncTcpListener;
use avx_http::runtime;
async fn handle_client(mut stream: avx_http::async_net::AsyncTcpStream) {
let mut buf = vec![0u8; 1024];
let n = stream.read(&mut buf).await.unwrap();
let response = b"HTTP/1.1 200 OK\r\nContent-Length: 13\r\n\r\nHello, World!";
stream.write_all(response).await.unwrap();
}
#[avx_http::main]
async fn main() {
let listener = AsyncTcpListener::bind("127.0.0.1:8080").unwrap();
loop {
let (stream, _) = listener.accept().await.unwrap();
runtime::spawn(handle_client(stream));
}
}
use avx_http::{Request, Response, Method};
use avx_http::net::TcpStream;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create request
let mut req = Request::new(Method::Get, "/api/data");
req.headers.insert("Host", "api.avila.cloud");
req.headers.insert("User-Agent", "avx-http/0.4.0");
// Send over TCP
let mut stream = TcpStream::connect("api.avila.cloud:80")?;
stream.write_all(&req.to_bytes())?;
// Read response
let mut buffer = vec![0u8; 4096];
let n = stream.read(&mut buffer)?;
let response = Response::parse(&buffer[..n])?;
println!("Status: {}", response.status);
println!("Body: {}", response.body_str()?);
Ok(())
}
use avx_http::http2::Http2Connection;
use avx_http::net::TcpStream;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect
let stream = TcpStream::connect("api.avila.cloud:443")?;
let mut conn = Http2Connection::new_client(stream)?;
// Send request
let stream_id = conn.request(
"GET",
"/data",
"api.avila.cloud",
vec![
("user-agent".into(), "avx-http/0.4.0".into()),
("accept".into(), "application/json".into()),
],
None, // No body
)?;
println!("Request sent on stream {}", stream_id);
// Read response frames
while let Some((sid, frame)) = conn.read_frame()? {
if sid == stream_id {
// Process frame (HEADERS, DATA, etc.)
println!("Received frame for stream {}", sid);
}
}
Ok(())
}
use avx_http::json::JsonValue;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let json = r#"{"name": "Alice", "age": 30, "active": true}"#;
let value = JsonValue::parse(json)?;
if let Some(obj) = value.as_object() {
println!("Name: {}", obj.get("name").unwrap().as_str().unwrap());
println!("Age: {}", obj.get("age").unwrap().as_f64().unwrap());
}
// Serialize back
println!("JSON: {}", value.to_string());
Ok(())
}
Client Server
| |
|-- CONNECTION_PREFACE --------->|
|-- SETTINGS ------------------>|
|<-- SETTINGS -------------------|
|-- SETTINGS (ACK) ------------>|
| |
|-- HEADERS (stream 1) -------->|
|-- DATA (stream 1) ----------->|
|<-- HEADERS (stream 1) ---------|
|<-- DATA (stream 1) ------------|
| |
|-- HEADERS (stream 3) -------->| Multiplexing!
|<-- HEADERS (stream 3) ---------|
|<-- DATA (stream 3) ------------|
Before: "content-type: application/json" (32 bytes)
After: 0x82 (1 byte)
β index into static table
Compression ratio: 97%!
let original = Bytes::from(vec![1, 2, 3, 4, 5]);
let slice1 = original.slice(0..2); // [1, 2]
let slice2 = original.slice(2..5); // [3, 4, 5]
// All three share the same underlying Vec!
// No memcpy, just Arc::clone() and pointer arithmetic
# Run all tests
cargo test -p avx-http
# Run HTTP/2 specific tests
cargo test -p avx-http http2
# Run benchmarks
cargo bench -p avx-http
# Test JSON parser
cargo test -p avx-http json
We welcome contributions! See CONTRIBUTING.md for guidelines.
Licensed under either of:
at your option.
Built with β€οΈ for the AVL Platform and Brazilian research infrastructure π§π·