This repository provides a simple implementation of an HTTP/1.1 server using TCP connections.
The core implementation is located in the internal folder, while the cmd/httpserver directory contains a basic usage example.
The main TCP connection data reading implementation resides in the internal folder, which includes:
serverpackage - for server creationrequestpackage - for reading incoming requestsheaderspackage - handles request header parsing logic (used by both request and response packages)responsepackage - manages server response logic
The response writer package also includes support for:
- A simplified version of chunked encoding
- HTTP trailers
Clone the repo
git clone https://github.com/lealre/http1-server.gitAccess the project folder
cd http1-serverStart the server
go run ./cmd/httpserverThis will start the server at localhost:42069.
You can access the following endpoints in your browser:
/bad- Simple HTML example/error- Simple HTML example/httpbin/- A proxy to httpbin endpoints for testing chunked encoding/video- A simple example of responding with binary data instead of text
This project is an extension of this repository, created to better understand how HTTP works.