Konloch Software

HTTPdLib

Published 03/22/2023

Build your own HTTP server using HTTPdLib - An easy-to-use zero dependency non-blocking HTTP web server for Java.

What Does It Do?

  • Small Java Library that provides an API for maintaining a persistent high performance HTTP web-server into your Java application.
    • Dynamic Pages, GET & POST
    • Cookies / Headers
    • File Uploading

Links

Requirements

  • Java 8 or greater

How To Integrate as a Dependency

Add the following to your pom.xml as a maven dependency, or just download the latest release and import it with your IDE.

<dependency>
  <groupId>com.konloch</groupId>
  <artifactId>HTTPdLib</artifactId>
  <version>0.1.0</version>
</dependency>

How To Use

Click here to view an example of how to implement the HTTP server.

import com.konloch.disklib.DiskReader;
import com.konloch.http.HTTPdLib;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author Konloch
 * @since 2/28/2023
 */
public class TestHTTPServer
{
	public static void main(String[] args) throws IOException
	{
		HTTPdLib webserver = new HTTPdLib(80, request ->
		{
			switch(request.getPath())
			{
				case "/":
					return ("Hello World: " + request.getRemoteIP()).getBytes(StandardCharsets.UTF_8);
			}
		});
		webserver.start();
		
		System.out.println("Running on http://localhost:" + webserver.getServer().getPort() + "/");
	}
}

Latest Updates

HTTPdLib v0.1.0

This is the first public release of the library, it has been heavily tested but please feel free to report any issues found.

To add it as a…

Read More