Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 1.93 KB

README.md

File metadata and controls

39 lines (32 loc) · 1.93 KB

Slow-Server

This is a http server program which can be used with another program that requires a (simple) server implementation.

Feel free to give any feedback.

Project License javadoc POM Artifact JAR

How to use:-

  1. To start the server, create an instance of the HttpServer or HttpsServer class and assign it to Server class.
  2. To set the logics for any of the http request methods, call the setRequestProcessor() method and pass an instance of the RequestProcessor class.
  3. Call the start() function.
  4. To set the request timeout, call the setTimeout() method and pass an instance of Duration class.
  5. For HttpsServer only, the setKeyStore() method needs to be called with keyStoreFileName and password.

Note:-

  1. If no RequestProcessor is set, the server returns the default http response.
  2. If setKeyStore() method is not called then connection to HttpsServer cannot be established.

Example:-

Extending the RequestPreprocessor class

class TestRequestProcessor extends RequestProcessor
{
    // override the required methods
}

Starting the server

TestRequestProcessor testRequestProcessor = new TestRequestProcessor();
Server server = new HttpServer(); // Starts an HTTP Server
Server server = new HttpsServer(); // Starts an HTTPS Server
server.setRequestProcessor(testRequestProcessor);
server.start();