Skip to content

A lightweight HTTP server written from scratch in C, handling GET requests with multi-threading support. It serves static files with proper MIME types and efficient response handling.

Notifications You must be signed in to change notification settings

puang59/http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTP Server from scratch

Read the blog where I break down the code step by step!

Overview

The server listens for incoming connections on port 8080 and processes client requests in separate threads, allowing it to handle multiple concurrent connections efficiently.

When a client request is received, the server:

  • Checks if it is a valid GET request.
  • Extracts and decodes the URL-encoded file name.
  • Determines the file's extension to identify the appropriate MIME type for the response.

If the requested file exists, the server reads its contents and sends it back with the correct HTTP headers. Otherwise, it responds with a 404 Not Found message.


gcc main.c request.c http.c utils.c -o server -pthread

or

make
./server

Credits

Resource Used: https://github.com/JeffreytheCoder/Simple-HTTP-Server

Shoutout to Jeffrey Yu

About

A lightweight HTTP server written from scratch in C, handling GET requests with multi-threading support. It serves static files with proper MIME types and efficient response handling.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published