Class TemporaryHandler

java.lang.Object
dev.katsute.simplehttpserver.handler.TemporaryHandler
All Implemented Interfaces:
com.sun.net.httpserver.HttpHandler

public class TemporaryHandler extends Object implements com.sun.net.httpserver.HttpHandler
Handler that removes itself after a single request, or after a set time, whichever comes first. This can be used for single use downloads or disposable links. A random unused context can be created by using HttpServerExtensions.getRandomContext() or HttpServerExtensions.getRandomContext(String).
Since:
5.0.0
Version:
5.0.0
Author:
Katsute
See Also:
  • HttpServerExtensions.getRandomContext()
  • HttpServerExtensions.getRandomContext(String)
  • Constructor Summary

    Constructors
    Constructor
    Description
    TemporaryHandler(com.sun.net.httpserver.HttpHandler handler)
    Creates a temporary handler that removes itself after the first request.
    TemporaryHandler(com.sun.net.httpserver.HttpHandler handler, long maxTime)
    Creates a temporary handler that removes itself after the first request, or after a set time.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    handle(com.sun.net.httpserver.HttpExchange exchange)
     
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TemporaryHandler

      public TemporaryHandler(com.sun.net.httpserver.HttpHandler handler)
      Creates a temporary handler that removes itself after the first request.
      Parameters:
      handler - handler
      Since:
      5.0.0
    • TemporaryHandler

      public TemporaryHandler(com.sun.net.httpserver.HttpHandler handler, long maxTime)
      Creates a temporary handler that removes itself after the first request, or after a set time.
      Parameters:
      handler - handler
      maxTime - how long the handler should exists for in milliseconds
      Since:
      5.0.0
  • Method Details

    • handle

      public final void handle(com.sun.net.httpserver.HttpExchange exchange) throws IOException
      Specified by:
      handle in interface com.sun.net.httpserver.HttpHandler
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object