Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mini HTTP Server (Java)

A minimal web server built from scratch using pure Java sockets.
No frameworks. No Spring. Just HTTP.

The purpose of this project is to understand what actually happens behind modern backend frameworks by implementing the core mechanics manually.


✨ Features

  • Accepts real browser connections
  • Parses HTTP requests (method, path, headers)
  • Routes requests based on URL
  • Generates valid HTTP responses
  • Automatic 404 Not Found
  • Clear separation between networking and application logic

You can open it in Chrome and it behaves like a real backend server.


πŸ— Architecture

Browser ↓ TCP Connection ↓ SocketServer ↓ HttpParser ↓ Router ↓ HttpResponse ↓ Browser

Responsibility per component

Component Responsibility
SocketServer Handles TCP connections
HttpParser Converts raw request text β†’ HttpRequest object
Router Chooses which handler should run
HttpResponse Builds valid HTTP response text

🌐 Example Routes

Route Result
/ Welcome message
/health OK
unknown path 404 Not Found

πŸš€ Run the server

1. Clone

git clone https://github.com/lindaeskilsson/mini-server.git
cd mini-server
2. Start
Run via IDE or terminal:

mvn compile
mvn exec:java -Dexec.mainClass="org.example.index.http.MyServer"
Server starts on:

http://localhost:4000
πŸ§ͺ Test
Browser:

http://localhost:4000/
http://localhost:4000/health
http://localhost:4000/anything
Terminal:

curl -v http://localhost:4000/health
πŸ“š Implemented HTTP Concepts
Request line parsing

Header parsing

Status codes

Content-Length handling

Routing

Layered architecture

This mirrors the core of real backend frameworks β€” without abstraction.


🎯 Learning Goal
The project demonstrates that a web server is fundamentally:
- A TCP loop + a text protocol + a function map
- Frameworks simply automate this.

πŸ‘€ Author
Linda Eskilsson
Java Developer Student

About

Creating a mini server in java

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages