Module SimpleHttpServer
Class ThrottledHandler
java.lang.Object
dev.katsute.simplehttpserver.handler.throttler.ThrottledHandler
- All Implemented Interfaces:
HttpHandler,SimpleHttpHandler
The throttled handler limits how many simultaneous connections are allowed at any given time. Throttlers are used to determine how inbound connections are handled.
- Since:
- 5.0.0
- Version:
- 5.0.0
- Author:
- Katsute
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionThrottledHandler(dev.katsute.simplehttpserver.handler.throttler.ConnectionThrottler throttler, HttpHandler handler) Creates a throttled handler. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidhandle(HttpExchange exchange) Do not override this method, it will causeSimpleHttpHandler.handle(SimpleHttpExchange)to not work.final voidhandle(SimpleHttpExchange exchange) Handles an exchange.toString()
-
Constructor Details
-
ThrottledHandler
public ThrottledHandler(dev.katsute.simplehttpserver.handler.throttler.ConnectionThrottler throttler, HttpHandler handler) Creates a throttled handler.- Parameters:
throttler- connection throttlerhandler- handler- Since:
- 5.0.0
- See Also:
-
-
Method Details
-
handle
Description copied from interface:SimpleHttpHandlerDo not override this method, it will causeSimpleHttpHandler.handle(SimpleHttpExchange)to not work. UseSimpleHttpHandler.handle(SimpleHttpExchange)instead.- Specified by:
handlein interfaceHttpHandler- Specified by:
handlein 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:SimpleHttpHandlerHandles 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:
handlein interfaceSimpleHttpHandler- Parameters:
exchange- http exchange- Throws:
IOException- IO exception- See Also:
-
toString
-