55 <h3>SimpleHttpServer</h3>
66 <h5>A simple and efficient HTTP server for Java</h5>
77 <div>
8- <a href="https://docs.katsute.dev/simplehttpserver">Documentation</a>
9- •
10- <a href="https://github.com/KatsuteDev/simplehttpserver/blob/main/setup.md#readme">Setup</a>
8+ <a href="https://docs.katsute.dev/simplehttpserver5">Documentation</a>
119 <br>
1210 <a href="https://mvnrepository.com/artifact/dev.katsute/simplehttpserver">Maven Central</a>
1311 •
1917
2018<br >
2119
22- > ⚠️ simplehttpserver5 is not compatible with any previous version of [ simplehttpserver] ( https://github.com/Ktt-Development/simplehttpserver )
20+ > ⚠️ simplehttpserver5 is not compatible with any previous version of [ simplehttpserver] ( https://github.com/Ktt-Development/simplehttpserver ) .
2321
2422Simplified httpserver experience for Java 8. Includes extensible servers and handlers for complex operations.
2523
@@ -38,16 +36,18 @@ Compiled binaries can be installed from:
3836 - GitHub Packages
3937 - [ Releases] ( https://github.com/KatsuteDev/simplehttpserver/releases )
4038
39+ Refer to the [ documentation] ( https://docs.katsute.dev/simplehttpserver5 ) to learn how to use servers and handlers.
40+
4141## ✨ Features
4242
4343### ✔️ Complicated tasks made easy
4444
4545Simplified exchange methods for:
4646
47- - Parsing HTTP ` GET ` /` POST ` with ` multipart/form-data ` support.
48- - Output stream writing with ` #send ` .
47+ - Parsing ` GET ` /` POST ` requests, including ` multipart/form-data ` support.
48+ - Accessing cookies.
49+ - Sending byte arrays, strings, and files to clients.
4950 - Sending gzip compressed responses.
50- - Sending files
5151
5252``` java
5353SimpleHttpHandler handler = new SimpleHttpHandler (){
@@ -56,26 +56,26 @@ SimpleHttpHandler handler = new SimpleHttpHandler(){
5656 Map POST = exchange. getPostMap();
5757 MultipartFormData form = exchange. getMultipartFormData();
5858 Record record = form. getRecord(" record" );
59- FileRecord file = ( FileRecord ) form. getRecord(" file" );
59+ FileRecord file = form. getRecord(" file" ) . asFile( );
6060 exchange. send(new File (" OK.png" ), true );
6161 }
6262};
6363```
6464
65- ### ⭐ Extended Features
65+ ### ⭐ More Features
6666
67- Support for :
67+ Features not included with a regular HTTP server :
6868
69- - HTTP Cookies
70- - HTTP Sessions
69+ - Cookies
70+ - Sessions
7171 - Multithreaded Servers
7272
7373``` java
7474SimpleHttpServer server = new SimpleHttpServer (8080 );
7575server. setHttpSessionHandler(new HttpSessionHandler ());
76- HttpHandler handler = new HttpHandler (){
76+ SimpleHttpHandler handler = new SimpleHttpHandler (){
7777 @Override
78- public void handle (HttpExchange exchange ){
78+ public void handle (SimpleHttpExchange exchange ){
7979 HttpSession session = server. getHttpSession(exchange);
8080 String session_id = session. getSessionID();
8181 Map<String ,String > cookies = exchange. getCookies();
@@ -86,23 +86,24 @@ HttpHandler handler = new HttpHandler(){
8686
8787### 🌐 Simplified Handlers
8888
89- Easy to use handlers:
89+ Simple and extensible request handlers:
9090
9191 - Redirect Handler
9292 - Predicate Handler
93+ - Root ` / ` Handler
9394 - File Handler
94- - Server-Sent-Events Handler
95+ - Server-Sent-Events (SSE) Handler
9596 - Temporary Handler
9697 - Throttled Handler
9798
9899``` java
99100RedirectHandler redirect = new RedirectHandler (" https://github.com/" );
100101FileHandler fileHandler = new FileHandler ();
101102fileHandler. addFile(new File (" index.html" ));
102- fileHandler. addDirectory(new File (" /site" ))
103+ fileHandler. addDirectory(new File (" /site" ));
103104SSEHandler SSE = new SSEHandler ();
104105SSE . push(" Server sent events!" );
105- ThrottledHandler throttled = new ThrottledHandler (new HttpHandler (), new ServerExchangeThrottler ())
106+ ThrottledHandler throttled = new ThrottledHandler (new ServerExchangeThrottler (), new HttpHandler ());
106107```
107108
108109## 👨💻 Contributing
0 commit comments