A simple HTTP server implementation in Go to understand HTTP protocol fundamentals.
This project is a basic HTTP server built from scratch in Go, designed to help understand how HTTP requests and responses work at a low level. It handles HTTP requests, parses headers, and demonstrates concurrent request processing.
.
├── go.mod # Go module file
├── go.sum # Go dependencies
├── trim_test.go # Test file for string parsing
├── note.md # Development notes
└── pkg/
├── main.go # Main server entry point
├── models.go # HTTP request/response models
└── server.go # Server implementation
- Basic HTTP request parsing
- Header extraction and processing
- User-Agent parsing
- Concurrent connection handling
- TCP server implementation
- Go 1.24.0 or later
- Clone the repository:
git clone https://github.com/alirezapourchali/go-http-server.git
cd go-http-server- Run the server:
go run pkg/*.goThe server will start listening on localhost:4221.
Run the test file to see string parsing functionality:
go run trim_test.goSend HTTP requests to the server:
curl http://localhost:4221/
curl -H "User-Agent: myapp/1.0" http://localhost:4221/user-agent- Understanding HTTP protocol structure
- Learning TCP server implementation in Go
- Practicing request/response parsing
- Exploring concurrent programming patterns
This project is for educational purposes. It's inspired by CodeCrafters