http-rs

Crates.iohttp-rs
lib.rshttp-rs
version0.1.3
sourcesrc
created_at2020-06-17 02:04:21.035715
updated_at2020-06-17 21:58:08.999598
descriptionDesigned for https://github.com/euvoor/hawk
homepagehttps://github.com/euvoor/hawk
repositoryhttps://github.com/euvoor/hawk/tree/master/daemon/http
max_upload_size
id254801
size12,158
Oussama Elgoumri (euvoor)

documentation

https://docs.rs/http-rs

README

Designed for HAWK

Example

use tokio::net::TcpListener;

use http_rs::Http;
use websocket_rs::{ Websocket, Opcode };

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut listener = TcpListener::bind("127.0.0.1:8080").await?;

    println!("Listening for websocket connections on 127.0.0.1:8080");

    while let Ok((stream, addr)) = listener.accept().await {
        tokio::spawn(async move {
            println!("New connection from {:?}", addr);

            let mut http = Http::new(stream);

            if let Some(req) = http.next().await {
                println!("{:?}", req);
            }
        });
    }

    Ok(())
}

TODO

  • [*] Handle errors properly
  • Support GET/POST request
  • Parse Request-Line & headers
  • Read POST body
  • Generate a suitable response
  • Handles Compression
  • Serve static files from disk
Commit count: 0

cargo fmt