Class TemporaryHandler
- java.lang.Object
-
- com.kttdevelopment.simplehttpserver.handler.TemporaryHandler
-
- All Implemented Interfaces:
HttpHandler
public class TemporaryHandler extends Object implements HttpHandler
A temporary handler handles a single request and then removes itself from the server. This can be used for single use downloads, or media file hosting. For time based expiry the handler will only remove itself if a user connects to the handler after the time expires.- Since:
- 03.03.00
- Version:
- 03.05.02
- Author:
- Ktt Development
- See Also:
HttpHandler,SimpleHttpServer.getRandomContext(),SimpleHttpServer.getRandomContext(String)
-
-
Constructor Summary
Constructors Constructor Description TemporaryHandler(SimpleHttpServer server, HttpHandler handler)Creates a temporary handler that removes itself after the first connection.TemporaryHandler(SimpleHttpServer server, HttpHandler handler, long maxTime)Creates a temporary handler that removes itself after the first connection, or after the time expires.TemporaryHandler(HttpHandler handler)Creates a temporary handler that removes itself after the first connection.TemporaryHandler(HttpHandler handler, long maxTime)Creates a temporary handler that removes itself after the first connection, or after the time expires.
-
-
-
Constructor Detail
-
TemporaryHandler
public TemporaryHandler(HttpHandler handler)
Creates a temporary handler that removes itself after the first connection.- Parameters:
handler- handler to use- Since:
- 03.03.00
- See Also:
HttpHandler
-
TemporaryHandler
public TemporaryHandler(SimpleHttpServer server, HttpHandler handler)
Creates a temporary handler that removes itself after the first connection.- Parameters:
server- simple http server; required if you wantSimpleHttpServer.getContexts()to work properlyhandler- handler to use- Since:
- 03.05.02
- See Also:
SimpleHttpServer,HttpHandler
-
TemporaryHandler
public TemporaryHandler(HttpHandler handler, long maxTime)
Creates a temporary handler that removes itself after the first connection, or after the time expires.- Parameters:
handler- handler to usemaxTime- how long the handler may exists for in milliseconds- Since:
- 03.03.00
- See Also:
HttpHandler
-
TemporaryHandler
public TemporaryHandler(SimpleHttpServer server, HttpHandler handler, long maxTime)
Creates a temporary handler that removes itself after the first connection, or after the time expires.- Parameters:
server- simple http server; required if you wantSimpleHttpServer.getContexts()to work properlyhandler- handler to usemaxTime- how long the handler may exists for in milliseconds- Since:
- 03.05.02
- See Also:
SimpleHttpServer,HttpHandler
-
-
Method Detail
-
handle
public final void handle(HttpExchange exchange) throws IOException
- Specified by:
handlein interfaceHttpHandler- Throws:
IOException
-
-