Git Product home page Git Product logo

leafhttp's Introduction

LeafHttp Web Server

LeafHttp is a simple configurable web server.

⚠️ This project is for demo/educational purposes! It is *NOT* designed for production use.

Features

  • Configurable IP/Port binding
  • Configurable WWW directory
  • Optional path traversal protection
  • Connection limiter
  • Can serve simple HTML/JS/CSS/etc. files
  • ⚠️ PHP is not supported (will be served as plain text)!
  • POST handling 🛠

Compatibility

  • ✅ Linux
  • ✅ macOS
  • ❌ Windows
    • Not supported due to home_dir using POSIX APIs.
    • This may be fixed in the future.

Limitations/Notes

  • The server strictly expects that requests are separated by \r\n. Using two newlines will cause parse errors (and thus 501s).
  • Clients are handled on separate threads, so don't make max-connections too high (unless you have a ton of CPU cores).
  • Only GET requests are supported.
  • max-request-size counts the entire request, not just the body.
  • The request body must contain valid UTF-8 characters. The server will respond with a 501 if you send a body with non-UTF-8 characters.

Client handling

Every client is handled in a separate thread. When the connection limit is reached, the socket is immediately closed.

Configuration

See default_config.yml.

Cross-compiling

Since home_dir depends on nix, you may get some linker errors.

If you get an error like ld: unknown option: --as-needed (especially on macOS), you can fix it by changing the linker. This can be done by creating a .cargo/config.toml config file, and specifying the following overrides:

[target.x86_64-unknown-linux-gnu] # macOS -> x86 Linux
linker = "x86_64-unknown-linux-gnu-gcc"

You'll need to adjust this to your needs.

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.