Skip to content

javieracevedo/turbolover

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turbo Lover (HTTP Server)

Basic HTTP 1/1 Server that accepts TCP connections and serves HTTP Responses.

Motivation

I'm building this for educational purposes only. Nothing is meant to be optimized or fully complete.

Scope

  • Listen on a TCP port and accept incoming connections.
  • Read and parse the HTTP request line into method, path, and version.
  • Parse request headers into a key/value map.
  • Accept Accept-Encoding header and respond with Content-Enconding header (Only accepts gzip as valid encoding)
  • Only accepts Content-Type header as text/plain, application/json, and application/octet-stream (only in response)
  • Send well-formed HTTP responses, including status line, headers, and body.
  • Expose a simple callback/handler interface such that the server calls something like: onRequest({ method, path, headers, rawBody }, respond).
  • Graceful error handling for malformed requests.
    • 400 Bad Request (Parsing Errors: request line, headers, body | Content-Length header is invalid)
    • 505 Unsupported Version (HTTP Version Not Supported)
  • Read the raw request body (as bytes / Buffer / string) according to headers like Content-Length and Transfer-Encoding: chunked.
  • Improve the logger module and use it in place of regular puts calls.
  • Test suite for all the cases above.
  • Package the server so it can be used as a library.

About

I'm your turbo loverrrrrrrrrr!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published