Skip to content

HTTP server using Java, capable of handling various HTTP methods (GET, POST, PUT, DELETE) and serving static files.

Notifications You must be signed in to change notification settings

Thescattypotty/HttpServer-1.0

Repository files navigation

HttpServer/1.0

This repository contains a simple HTTP server implementation in Java.

Features

  • Supports HTTP methods: GET, POST, PUT, DELETE
  • Serves static files with correct MIME types
  • Handles various content types: HTML, text, images, PDF, etc.
  • Provides basic error handling and status code responses

Components

HTTPRequest

Represents an incoming HTTP request, parsing method, path, and HTTP version.

HTTPResponse

Constructs and sends HTTP responses with appropriate headers and content.

HTTPHandler Interface

Defines the contract for handling HTTP requests based on different methods.

FileServer

Serves static files from a specified directory, determining content types based on file extensions.

RequestHandler

Handles incoming client connections, delegates requests to appropriate handlers (HTTPHandler), and manages response generation.

Usage

To use the HTTP server:

  1. Clone the repository.
  2. Change The rootDirectory on HttpServer.java
  3. Compile the Java classes (javac *.java).
  4. Run the (java HTTPServer) .
  5. The server serve on port 1202 .

About

HTTP server using Java, capable of handling various HTTP methods (GET, POST, PUT, DELETE) and serving static files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages