Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

410 Commits

Repository files navigation




✨ This library is no longer maintained, try simplehttpserver5. ✨





Logo

SimpleHttpServer

Java CICodeQLDeployMaven Centralversionlicense

A simplified implementation of the sun http server for JDK11.
This library simplifies complex operations for both the server, exchange, and handlers.
DocumentationIssues

Setup

Compiled binaries can be found on Maven Central. Maven Central

For projects built locally, compiled binaries can also be found in releases. releases

Features

📋 Complicated tasks made easy

Simplified exchange methods for:

  • Parsing HTTP GET/POST with multipart/form-data support.
  • Output stream writing with #send.
  • Sending gzip compressed responses.
  • Sending files
SimpleHttpHandlerhandler = newSimpleHttpHandler(){
@Overridepublicvoidhandle(SimpleHttpExchangeexchange){
MapPOST = exchange.getPostMap();
MultipartFormDataform = exchange.getMultipartFormData();
Recordrecord = form.getRecord("record");
FileRecordfile = (FileRecord) form.getRecord("file");
exchange.send(newFile("OK.png"), true);
}
};

⭐ Extended Features

Out of the box support for:

  • HTTP Cookies
  • HTTP Sessions
  • Multithreaded Servers
SimpleHttpServerserver = newSimpleHttpServer(8080);
server.setHttpSessionHandler(newHttpSessionHandler());
HttpHandlerhandler = newHttpHandler(){
@Overridepublicvoidhandle(HttpExchangeexchange){
HttpSessionsession = server.getHttpSession(exchange);
Stringsession_id = session.getSessionID();
Map<String,String> cookies = exchange.getCookies();
exchange.close();
}
};

💻 Simplified Handlers

Easy to use handlers:

  • Redirect Handler
  • Predicate Handler
  • File Handler
  • Server-Sent-Events Handler
  • Temporary Handler
  • Throttled Handler
RedirectHandlerredirect = newRedirectHandler("https://github.com/");
FileHandlerfileHandler = newFileHandler();
fileHandler.addFile(newFile("index.html"));
fileHandler.addDirectory(newFile("/site"))
SSEHandlerSSE = newSSEHandler();
SSE.push("Server sent events!");
ThrottledHandlerthrottled = newThrottledHandler(newHttpHandler(), newServerExchangeThrottler())

Contributing

About

SimpleHttpServer :: Simplified implementation of the sun http server :: Simplified handlers to execute complex operations

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages