Skip to content

Very simple library for personal use. Provides reusable methods and structs to read HTTP requests from a stream object (like TlsStream or TcpStream), does not handle responding or the process of obtaining a stream.

Notifications You must be signed in to change notification settings

JohnSwiftC/lazyhttp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lazyhttp

An easy library to handle stream objects (TcpStream, TlsStream, etc) transferring HTTP data, providing functions which return a Request from the http crate.

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 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.

About

Very simple library for personal use. Provides reusable methods and structs to read HTTP requests from a stream object (like TlsStream or TcpStream), does not handle responding or the process of obtaining a stream.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages