lazyhttp 1.2.0

A simple HTTP library to handle common stream objects (TcpStream, TlsStream, etc) sending HTTP data. This library is very simple and is intended to make reading raw HTTP less repetitive, and as such it does not handle responding or networking.
Documentation
  • Coverage
  • 11.11%
    1 out of 9 items documented0 out of 3 items with examples
  • Size
  • Source code size: 6.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 305.57 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • JohnSwiftC/lazyhttp
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JohnSwiftC

lazyhttp

An easy library to handle stream objects (TcpStream, TlsStream, etc) transferring HTTP data. Includes a function to parse and return an object representing the request.

This library does not handle networking or responding. This is really intended to remove a snippet of code that I find myself copying and pasting over and over again.

Important: This library does not handle content encodings. This library will also only accept bodies if they are sent with a Content-Length header.

Example

let listener = TcpListener::bind("addr");

for stream in listener.incoming() {
    let stream = stream.unwrap();

    if let Ok(req) = lazyhttp::handle_stream(&stream) {
        // Do something with req
    }
}

Note, this is not a good example for production code. Remember proper error handling and some form of async or multithreading for a server environment.