// Minimal HTTP server benchmark - Rust version (single-threaded)
// Compile: rustc -C opt-level=3 -o http_rust http_server.rs
// Test: wrk -t2 -c50 -d5s http://localhost:8081/

use std::io::{Read, Write};
use std::net::TcpListener;

const RESPONSE: &[u8] = b"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: 15\r\n\r\n{\"status\":\"ok\"}";

fn main() {
    let listener = TcpListener::bind("0.0.0.0:8081").unwrap();
    println!("Rust HTTP server listening on port 8081");

    for stream in listener.incoming() {
        if let Ok(mut stream) = stream {
            let mut buffer = [0u8; 1024];
            let _ = stream.read(&mut buffer);
            let _ = stream.write_all(RESPONSE);
        }
    }
}
