GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - KatsuteDev/simplehttpserver: simplehttpserver5 - A simple and efficient HTTP server for Java

This repository was archived by the owner on May 10, 2024. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

114 Commits
114 Commits

Folders and files

NameName
Last commit message
Last commit date
.devcontainer
.devcontainer
 
 
.github
.github
 
 
assets
assets
 
 
src
src
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

icon

SimpleHttpServer

A simple and efficient HTTP server for Java
Documentation
Maven Central • GitHub Packages • Releases

⚠️ simplehttpserver5 is not compatible with any previous version of simplehttpserver.

Simplified httpserver experience for Java 8. Includes extensible servers and handlers for complex operations.

Installation

This library requires at least Java 8. No additional dependencies are required.

Compiled binaries can be installed from:

  • Maven Central
  • GitHub Packages
  • Releases

Refer to the documentation to learn how to use servers and handlers.

▲

Features

Complicated tasks made easy

Simplified exchange methods for:

  • Parsing GET/POST requests, including multipart/form-data support.
  • Accessing cookies.
  • Sending byte arrays, strings, and files to clients.
  • Sending gzip compressed responses.
SimpleHttpHandler handler = new SimpleHttpHandler(){
    @Override
    public void handle(SimpleHttpExchange exchange){
        Map POST = exchange.getPostMap();
        MultipartFormData form = exchange.getMultipartFormData();
        Record record = form.getRecord("record");
        FileRecord file = form.getRecord("file").asFile();
        exchange.send(new File("OK.png"), true);
    }
};

More Features

Features not included with a regular HTTP server:

  • Cookies
  • Sessions
  • Multithreaded Servers
SimpleHttpServer server = new SimpleHttpServer(8080);
server.setHttpSessionHandler(new HttpSessionHandler());
SimpleHttpHandler handler = new SimpleHttpHandler(){
    @Override
    public void handle(SimpleHttpExchange exchange){
        HttpSession session = server.getHttpSession(exchange);
        String session_id = session.getSessionID();
        Map<String,String> cookies = exchange.getCookies();
        exchange.close();
    }
};

Simplified Handlers

Simple and extensible request handlers:

  • Redirect Handler
  • Predicate Handler
  • Root / Handler
  • File Handler
  • Server-Sent-Events (SSE) Handler
  • Temporary Handler
  • Timeout Handler
  • Throttled Handler
RedirectHandler redirect = new RedirectHandler("https://github.com/");
FileHandler fileHandler = new FileHandler();
fileHandler.addFile(new File("index.html"));
fileHandler.addDirectory(new File("/site"));
SSEHandler SSE = new SSEHandler();
SSE.push("Server sent events!");
ThrottledHandler throttled = new ThrottledHandler(new ServerExchangeThrottler(), new HttpHandler());
▲

Contributing

Running Tests Locally

For local tests you can use Java 8+, however only methods in the Java 8 API may be used. The src/main/java9 folder should not be marked as a source root.

Running Tests using GitHub Actions

Each commit automatically triggers the Java CI workflow, make sure you have actions enabled on your forks.

▲

 

This library is released under the GNU General Public License (GPL) v2.0.

About

simplehttpserver5 - A simple and efficient HTTP server for Java

katsute.dev/product/simplehttpserver5

Topics

http-serverhttp-server-handlerhttp-server-libraryhttp-server-middlewarehttps-serverhttpserverjavaliblibrarysimplehttpserverwebserverwebsite

Resources

Readme
GPL-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

9 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.