- Notifications
You must be signed in to change notification settings - Fork0
SimpleHttpServer :: Simplified implementation of the sun http server :: Simplified handlers to execute complex operations
License
Ktt-Development/simplehttpserver
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation

A simplified implementation of thesun http server for JDK11.
This library simplifies complex operations for both the server, exchange, and handlers.
Documentation •Issues
Compiled binaries can be found on Maven Central.
For projects built locally, compiled binaries can also be found in releases.
Simplified exchange methods for:
- Parsing HTTP
GET
/POST
withmultipart/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); }};
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(); }};
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())
- Found a bug? Open a newissue.
- Want to contribute? Create afork and open apull request.
About
SimpleHttpServer :: Simplified implementation of the sun http server :: Simplified handlers to execute complex operations
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.