forthespada/MyPoorWebServer logo

forthespada/MyPoorWebServer

Free

一款可运行的基于C++ 实现的WebServer服务器,基于《TCPIP网络编程》和《Linux高性能服务器编程》实现的服务器项目。

FreeFree tier
Type
Open Source

About forthespada/MyPoorWebServer

MyPoorWebServer is an educational HTTP server project originally written in C++11 and later ported to C. It is designed for learning network programming based on the classic textbooks "TCP/IP Network Programming" and "Linux High-Performance Server Programming". The server supports static file serving, CGI scripts (via post.cgi), and listens on port 6379. It is built with Make and intended to run on Linux. The repository includes example HTML pages and is configured with appropriate file permissions. The project is maintained by forthespada and has gained 1.5k stars on GitHub, serving as a practical resource for students and developers looking to understand web server internals.

Key Features

HTTP/1.1 server implementation in C (originally C++11)
Supports GET requests for static files (HTML, images)
CGI support via post.cgi for dynamic content
Default port 6379
Built with Make for Linux
References classic network programming textbooks
Includes test HTML pages (test.html, post.html)
Educational project suitable for resume building

Pros & Cons

Pros
  • Educational and well-documented for beginners
  • Based on authoritative textbooks
  • Lightweight and easy to compile with Make
  • Active GitHub community with stars and forks
  • Free and open-source with permissive license (MIT implied)
  • Includes a functional CGI example
Cons
  • Primarily written in C (C++ version removed); may not suit C++ learners
  • Limited to basic HTTP/1.1 features; no HTTPS, chunked encoding, or persistent connections
  • Not production-ready; intended for learning only
  • Documentation is mostly in Chinese, limiting accessibility
  • Only tested on Linux; no Windows/macOS support

Best For

Learning HTTP protocol and web server internalsPracticing Linux socket programming and epollUnderstanding CGI and static file servingDemonstrating C/C++ network programming skills in job applicationsBuilding a lightweight personal web server for experimentation

FAQ

What language is MyPoorWebServer written in?
The current version is written in C (85.8% of the codebase). The project originally used C++11 but that version has been removed. The README references both C++ and C versions.
What port does the server use?
The default port is 6379, as shown in the README and compilation instructions.
Does the server support dynamic content?
Yes, it includes a CGI script (post.cgi) that handles POST requests. The server also serves static HTML files.
What are the prerequisites to run this project?
Familiarity with TCP/IP network programming and Linux high-performance server programming is recommended. The project references the books 'TCP/IP Network Programming' and 'Linux High-Performance Server Programming'.
How do I compile and run the server?
Clone the repository, set file permissions with chmod (sudo chmod 600 test.html post.html and sudo chmod +x post.cgi), then run 'make' and './myhttp' in the project root.