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:
server
package - for server creationrequest
package - for reading incoming requestsheaders
package - handles request header parsing logic (used by both request and response packages)response
package - 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.git
Access the project folder
cd http1-server
Start the server
go run ./cmd/httpserver
This 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.