Skip to content

OmarDawoud4/http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java HTTP Server

A simple, multi-threaded HTTP server implementation in Java that demonstrates basic web server concepts including request handling, routing, and concurrent client connections.

Features

  • Multi-threaded: Uses a thread pool with 8 threads to handle concurrent client connections
  • Basic Routing: Supports multiple endpoints with different content
  • HTTP/1.1 Compatible: Implements basic HTTP protocol standards
  • Lightweight: No external dependencies, uses only Java standard library

Architecture

graph TD
    Clients[Client Requests] --> ServerSocket[Server Socket]
    
    ServerSocket --> ThreadPool[Thread Pool]
    
    ThreadPool --> Thread1[Thread 1]
    ThreadPool --> Thread2[Thread 2]
    ThreadPool --> Thread3[...]
    ThreadPool --> Thread8[Thread 8]
    
    Thread1 --> Handler1[RequestHandler]
    Thread2 --> Handler2[RequestHandler]
    Thread8 --> Handler8[RequestHandler]
    
    Handler1 --> Response1[ResponseGenerator]
    Handler2 --> Response2[ResponseGenerator]
    Handler8 --> Response8[ResponseGenerator]
    
    Response1 --> ClientResponse1[Response]
    Response2 --> ClientResponse2[Response]
    Response8 --> ClientResponse8[Response]
Loading

Available Routes

  • / : Home page with navigation links
  • /about : Information about the server
  • /random : Generates a random number (1-100)
  • /stats : Displays server statistics
  • Other routes :Returns 404 Not Found

How to Run

  • Compile the Java files:
javac HttpServer.java RequestHandler.java ResponseGenerator.java
  • Run the server:
java HttpServer

About

PoC multithreaded HTTP server in Java using ExecutorService.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages