java.lang.Object
dev.katsute.simplehttpserver.handler.TimeoutHandler
- All Implemented Interfaces:
HttpHandler
,SimpleHttpHandler
The timeout handler runs a handler and times out after a set time.
- Since:
- 5.0.0
- Version:
- 5.0.0
- Author:
- Katsute
-
Constructor Summary
ConstructorDescriptionTimeoutHandler
(HttpHandler handler, double timeout) Creates a timeout handler.TimeoutHandler
(HttpHandler handler, double timeout, TimeUnit unit) Creates a timeout handler. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
handle
(HttpExchange exchange) Do not override this method, it will causeSimpleHttpHandler.handle(SimpleHttpExchange)
to not work.final void
handle
(SimpleHttpExchange exchange) Handles an exchange.toString()
-
Constructor Details
-
TimeoutHandler
Creates a timeout handler.- Parameters:
handler
- handlertimeout
- how long until timeout in seconds- Since:
- 5.0.0
-
TimeoutHandler
Creates a timeout handler.- Parameters:
handler
- handlertimeout
- how long until timeoutunit
- timeout units- Since:
- 5.0.0
- See Also:
-
-
Method Details
-
handle
Description copied from interface:SimpleHttpHandler
Do not override this method, it will causeSimpleHttpHandler.handle(SimpleHttpExchange)
to not work. UseSimpleHttpHandler.handle(SimpleHttpExchange)
instead.- Specified by:
handle
in interfaceHttpHandler
- Specified by:
handle
in interfaceSimpleHttpHandler
- Parameters:
exchange
- the exchange containing the request from the client and used to send the response- Throws:
IOException
- IO exception- See Also:
-
handle
Description copied from interface:SimpleHttpHandler
Handles an exchange.
Http handlers will not throw an exception in the main thread, you must use a try-catch to expose them. All requests must be closed withHttpExchange.close()
, otherwise the handler will rerun the request multiple times.- Specified by:
handle
in interfaceSimpleHttpHandler
- Parameters:
exchange
- http exchange- Throws:
IOException
- IO exception- See Also:
-
toString
-