Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 06397e4

Browse files
committed
ready for prerelease
1 parent cd7e2c9 commit 06397e4

File tree

13 files changed

+25
-33
lines changed

13 files changed

+25
-33
lines changed

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ body:
99
Before opening a bug report please check that your issue was not already discussed in the following:
1010
1111
* [Issues](https://github.com/KatsuteDev/simplehttpserver/issues?q=is%3Aissue+is%3Aopen+label%3Abug%2C%22critical+bug%22)
12-
* [Documentation](https://docs.katsute.dev/simplehttpserver)
12+
* [Documentation](https://docs.katsute.dev/simplehttpserver5)
1313
1414
Please also check that:
1515

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
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
@@ -19,7 +17,7 @@
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
2422
Simplified 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

4545
Simplified 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
5353
SimpleHttpHandler 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
7474
SimpleHttpServer server = new SimpleHttpServer(8080);
7575
server.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
99100
RedirectHandler redirect = new RedirectHandler("https://github.com/");
100101
FileHandler fileHandler = new FileHandler();
101102
fileHandler.addFile(new File("index.html"));
102-
fileHandler.addDirectory(new File("/site"))
103+
fileHandler.addDirectory(new File("/site"));
103104
SSEHandler SSE = new SSEHandler();
104105
SSE.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

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>dev.katsute</groupId>
88
<artifactId>simplehttpserver</artifactId>
9-
<version>5.0.0-SNAPSHOT</version>
9+
<version>5.0.0-RC-1</version>
1010

1111
<profiles>
1212
<profile>

src/main/java/dev/katsute/simplehttpserver/SimpleHttpExchangeImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ public synchronized final void close(){
425425

426426
//
427427

428-
429428
@Override
430429
public String toString(){
431430
return "SimpleHttpExchange{" +

src/main/java/dev/katsute/simplehttpserver/SimpleHttpsServerImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public synchronized final void setExecutor(final Executor executor){
113113
server.setExecutor(executor);
114114
}
115115

116-
117116
//
118117

119118
@Override
@@ -146,7 +145,6 @@ public synchronized final HttpContext createContext(final String context, final
146145
if(!ct.equals("/") && Objects.requireNonNull(handler) instanceof RootHandler)
147146
throw new IllegalArgumentException("RootHandler can only be used at the root '/' context");
148147

149-
150148
final HttpContext hc = server.createContext(ct);
151149

152150
if(sessionHandler != null){
@@ -247,7 +245,6 @@ public synchronized final void stop(final int delay){
247245

248246
// endregion
249247

250-
251248
@Override
252249
public String toString(){
253250
return "SimpleHttpsServer{" +

src/main/java/dev/katsute/simplehttpserver/handler/SSEHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1717
*/
1818

19-
2019
package dev.katsute.simplehttpserver.handler;
2120

2221
import com.sun.net.httpserver.Headers;

src/main/java/dev/katsute/simplehttpserver/handler/file/DirectoryEntry.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ final byte[] getBytes(final String path){
149149

150150
//
151151

152-
153152
@Override
154153
public String toString(){
155154
return "DirectoryEntry{" +

src/main/java/dev/katsute/simplehttpserver/handler/file/FileEntry.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ final boolean isExpired(){
125125

126126
//
127127

128-
129128
@Override
130129
public String toString(){
131130
return "FileEntry{" +

src/main/java/dev/katsute/simplehttpserver/handler/throttler/ThrottledHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public final void handle(final SimpleHttpExchange exchange) throws IOException {
7474

7575
//
7676

77-
7877
@Override
7978
public String toString(){
8079
return "ThrottledHandler{" +

src/test/java/dev/katsute/simplehttpserver/exchange/ExchangeSendTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ final class ExchangeSendTests {
1313

1414
private static SimpleHttpServer server;
1515

16-
private static int testCode = HttpURLConnection.HTTP_ACCEPTED;
17-
private static String testContent = String.valueOf(System.currentTimeMillis());
16+
private static final int testCode = HttpURLConnection.HTTP_ACCEPTED;
17+
private static final String testContent = String.valueOf(System.currentTimeMillis());
1818

1919
@TempDir
2020
private static File dir = new File(testContent);

0 commit comments

Comments
 (0)