dev.katsute.simplehttpserver 5.0.0-RC-1
Install 1/2: Add this to pom.xml:
Learn more about Maven or Gradle
<dependency>
<groupId>dev.katsute</groupId>
<artifactId>simplehttpserver</artifactId>
<version>5.0.0-RC-1</version>
</dependency>
Install 2/2: Run via command line
$ mvn install
About this package
You do not have to authenticate with GitHub to use this package, binaries are available on Maven Central https://mvnrepository.com/artifact/dev.katsute/simplehttpserver |
---|
⚠️ simplehttpserver5 is not compatible with any previous version of simplehttpserver.
Simplified httpserver experience for Java 8. Includes extensible servers and handlers for complex operations.
simplehttpserver5 requires at least Java 8. No additional dependencies/libraries are required.
Compiled binaries can be installed from:
Refer to the documentation to learn how to use servers and handlers.
Simplified exchange methods for:
- Parsing
GET
/POST
requests, includingmultipart/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);
}
};
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();
}
};
Simple and extensible request handlers:
- Redirect Handler
- Predicate Handler
- Root
/
Handler - File Handler
- Server-Sent-Events (SSE) Handler
- Temporary 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());
GitHub Copilot is strictly prohibited on this repository.
Pulls using this will be rejected.
- Found a bug? Post it in issues.
- Want to further expand our project? Fork this repository and submit a pull request.
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.
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.
Details
- KatsuteDev
- July 31, 2022
- 06397e4
- 5.0.0-RC-1
- 2 dependencies
- GNU GPLv2
Assets
- simplehttpserver-5.0.0-RC-1-javadoc.jar.md5
- simplehttpserver-5.0.0-RC-1-javadoc.jar.sha1
- simplehttpserver-5.0.0-RC-1-javadoc.jar
- simplehttpserver-5.0.0-RC-1-sources.jar.sha1
- simplehttpserver-5.0.0-RC-1-sources.jar.md5
- simplehttpserver-5.0.0-RC-1-sources.jar
- simplehttpserver-5.0.0-RC-1.pom.md5
- simplehttpserver-5.0.0-RC-1.pom.sha1
- simplehttpserver-5.0.0-RC-1.pom
- simplehttpserver-5.0.0-RC-1.jar.md5
- simplehttpserver-5.0.0-RC-1.jar.sha1
- simplehttpserver-5.0.0-RC-1.jar
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0
Recent versions
View all-
5.0.2
Nov 20, 2023 -
5.0.1
Mar 14, 2023 -
5.0.0
Nov 29, 2022 -
5.0.0-RC-2
Oct 21, 2022 -
5.0.0-RC-1
Jul 31, 2022