FastCppNetworkLibrary is a high-performance web server based on C++ that supports the HTTP protocol. It implements basic HTTP request handling, file upload and download, logging, and other functions. The project structure includes modules such as an HTTP server, TCP server, event loop, logging system, and timer.
- Handle HTTP GET and POST requests
- Support file upload and download
- Log information
- Support multithreading, handle concurrent requests through a thread pool
- Timer function for handling timed tasks
-
Clone the project to your local machine:
git clone https://github.com/5yh/FastCppNetworkLibrary.git cd FastCppNetworkLibrary
-
Build the project:
mkdir build cd build cmake .. make
-
Copy the
LogFiles
folder,files
folder, andstatic
folder from the parent directory to the currentbuild
directory:cp -r LogFiles build/ cp -r files build/ cp -r static build/
-
Run the HTTP server:
./bin/http_server
-
After the server starts, you can send HTTP requests for testing through a browser or tools like curl:
curl http://localhost:1234
http/
: HTTP server related codeHttpServer.h
: HTTP server header fileHttpServer.cpp
: HTTP server implementation fileHttpRequest.h
: HTTP request header fileHttpRequest.cpp
: HTTP request implementation fileHttpResponse.h
: HTTP response header fileHttpResponse.cpp
: HTTP response implementation fileHttpContext.h
: HTTP context header fileHttpContext.cpp
: HTTP context implementation file
tcp/
: TCP server related codeTcpServer.h
: TCP server header fileTcpServer.cpp
: TCP server implementation fileTcpConnection.h
: TCP connection header fileTcpConnection.cpp
: TCP connection implementation fileAcceptor.h
: Acceptor header fileAcceptor.cpp
: Acceptor implementation fileEventLoop.h
: Event loop header fileEventLoop.cpp
: Event loop implementation fileEventLoopThread.h
: Event loop thread header fileEventLoopThread.cpp
: Event loop thread implementation fileEventLoopThreadPool.h
: Event loop thread pool header fileEventLoopThreadPool.cpp
: Event loop thread pool implementation fileChannel.h
: Channel header fileChannel.cpp
: Channel implementation fileEpoller.h
: Epoll wrapper header fileEpoller.cpp
: Epoll wrapper implementation fileBuffer.h
: Buffer header fileBuffer.cpp
: Buffer implementation file
log/
: Logging system related codeLogging.h
: Logging system header fileLogging.cpp
: Logging system implementation fileLogStream.h
: Log stream header fileLogStream.cpp
: Log stream implementation fileAsyncLogging.h
: Asynchronous logging header fileAsyncLogging.cpp
: Asynchronous logging implementation fileLogFile.h
: Log file header fileLogFile.cpp
: Log file implementation file
timer/
: Timer related codeTimer.h
: Timer header fileTimer.cpp
: Timer implementation fileTimerQueue.h
: Timer queue header fileTimerQueue.cpp
: Timer queue implementation fileTimeStamp.h
: Timestamp header fileTimeStamp.cpp
: Timestamp implementation file
base/
: Infrastructure codecommon.h
: Common macro definitionsCurrentThread.h
: Current thread utility header fileCurrentThread.cpp
: Current thread utility implementation fileLatch.h
: Synchronization utility header file
static/
: Static files directoryindex.html
: Homepage HTML filefileserver.html
: File server HTML file
test/
: Test code directoryhttp_server.cpp
: HTTP server test fileecho_server.cpp
: Echo server test filetest_logstream.cpp
: Log stream test filetest_httpcontext.cpp
: HTTP context test file
files/
: File upload directorya.txt
: Example fileb.txt
: Example filec.txt
: Example file
CMakeLists.txt
: CMake build scriptREADME.md
: Project description file