Skip to content

nithikapidikiti-collab/http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-server

A concurrent HTTP/1.1 server written in C from scratch — no libraries, just POSIX sockets.

Features

  • Parses raw HTTP/1.1 GET requests
  • Serves static files with correct Content-Type headers (HTML, CSS, JS, PNG, JPEG)
  • Fork-based concurrency — each client handled in a separate process
  • SIGCHLD handler to reap zombie processes
  • Apache-style request logging with timestamps

Build

make

Run

./server

Serves files from ./www on port 8080 by default. Open http://localhost:8080 in your browser.

You can also pass a custom port:

./server 9090

Project Structure

http-server/
├── src/
│   ├── main.c        # Entry point, port handling
│   ├── server.c      # Socket setup, accept loop, fork concurrency
│   ├── request.c     # HTTP request parser
│   └── response.c    # HTTP response builder, file serving
├── include/
│   └── server.h      # Shared types and function declarations
├── www/
│   └── index.html    # Static files served by the server
└── Makefile

Example Output

[*] HTTP server listening on port 8080
[*] Serving files from ./www
[2026-06-08 22:05:14] 127.0.0.1 "GET /" 200
[2026-06-08 22:05:14] 127.0.0.1 "GET /favicon.ico" 200

About

Concurrent HTTP/1.1 server built from scratch in C using POSIX sockets and fork-based concurrency.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors