Giter VIP home page Giter VIP logo

mini_http's Introduction

mini_http

Build Status

Note: This project is a work in progress and shouldn't be used in any critical production environment.

A basic asynchronous* http server using mio

*While network IO is performed asynchronously, handler functions are executed synchronously in a thread pool.

Usage

See examples

extern crate mini_http;

fn run() -> Result<(), Box<std::error::Error>> {
    mini_http::Server::new("127.0.0.1:3000")?
        .start(|request| {
            println!("{:?}", std::str::from_utf8(request.body()));
            let resp = if request.body().len() > 0 {
                request.body().to_vec()
            } else {
                b"hello!".to_vec()
            };
            mini_http::Response::builder()
                .status(200)
                .header("X-What-Up", "Nothin")
                .body(resp)
                .unwrap()
        })?;
    Ok(())
}

mini_http's People

Contributors

jaemk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sdeleuze heyline

mini_http's Issues

Improve end of headers detection

End of header detection could be improved avoid scanning through the entire buffer each try_build_request and to put off header counting until all of them are received. This probably overlaps with #2 since it'll require tracking the current number of bytes

Use several mio event loops

Try using more than one event loop. The main loop can handle all listener events and all stream events can be pawned off to additional event loops.

Add keep-alive connection timeout

Right now connections live until the client disconnects. Add a max timeout between completion of sending a response and the receipt of a new request.

Properly handle `Connection` header

Right now all connection are closed after transfer and Connection: Close isn't even being set. Streams should be held onto and reused for Connection: keep-alive

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.