public LimitHandler() { this.requestLimit = new RequestLimit(config.concurrentRequest, config.queueSize); }
public void handleRequest(final HttpServerExchange exchange) throws Exception { requestLimit.handleRequest(exchange, nextHandler); }
/** * Construct a new instance. The maximum number of concurrent requests must be at least one. The next handler * must not be {@code null}. * * @param maximumConcurrentRequests the maximum concurrent requests * @param queueSize the maximum number of requests to queue * @param nextHandler the next handler */ public RequestLimitingHandler(int maximumConcurrentRequests, int queueSize, HttpHandler nextHandler) { if (nextHandler == null) { throw new IllegalArgumentException("nextHandler is null"); } if (maximumConcurrentRequests < 1) { throw new IllegalArgumentException("Maximum concurrent requests must be at least 1"); } this.requestLimit = new RequestLimit(maximumConcurrentRequests, queueSize); this.nextHandler = nextHandler; }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { requestLimit.handleRequest(exchange, Handler.getNext(exchange, next)); }
private StreamReadLimitHandler(HttpHandler next) { this.requestLimit = new RequestLimit(MAX_STREAM_SENDERS, MAX_STREAM_RESPONSES); this.next = next; }
public void handleRequest(final HttpServerExchange exchange) throws Exception { requestLimit.handleRequest(exchange, nextHandler); }
/** * Construct a new instance. The maximum number of concurrent requests must be at least one. The next handler * must not be {@code null}. * * @param maximumConcurrentRequests the maximum concurrent requests * @param queueSize the maximum number of requests to queue * @param nextHandler the next handler */ public RequestLimitingHandler(int maximumConcurrentRequests, int queueSize, HttpHandler nextHandler) { if (nextHandler == null) { throw new IllegalArgumentException("nextHandler is null"); } if (maximumConcurrentRequests < 1) { throw new IllegalArgumentException("Maximum concurrent requests must be at least 1"); } this.requestLimit = new RequestLimit(maximumConcurrentRequests, queueSize); this.nextHandler = nextHandler; }
public void handleRequest(final HttpServerExchange exchange) throws Exception { requestLimit.handleRequest(exchange, nextHandler); }
/** * Construct a new instance. The maximum number of concurrent requests must be at least one. The next handler * must not be {@code null}. * * @param maximumConcurrentRequests the maximum concurrent requests * @param queueSize the maximum number of requests to queue * @param nextHandler the next handler */ public RequestLimitingHandler(int maximumConcurrentRequests, int queueSize, HttpHandler nextHandler) { if (nextHandler == null) { throw new IllegalArgumentException("nextHandler is null"); } if (maximumConcurrentRequests < 1) { throw new IllegalArgumentException("Maximum concurrent requests must be at least 1"); } this.requestLimit = new RequestLimit(maximumConcurrentRequests, queueSize); this.nextHandler = nextHandler; }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (isStreamRead(exchange)) { requestLimit.handleRequest(exchange, next); } else { next.handleRequest(exchange); } }
/** * buildGracefulShutdownHandler * * @param paths * @return */ private static GracefulShutdownHandler buildGracefulShutdownHandler(PathHandler paths) { return new GracefulShutdownHandler( new RequestLimitingHandler(new RequestLimit(configuration.getRequestLimit()), new AllowedMethodsHandler( new BlockingHandler( new GzipEncodingHandler( new ErrorHandler( new HttpContinueAcceptingHandler(paths) ), configuration.isForceGzipEncoding() ) ), // allowed methods HttpString.tryFromString(RequestContext.METHOD.GET.name()), HttpString.tryFromString(RequestContext.METHOD.POST.name()), HttpString.tryFromString(RequestContext.METHOD.PUT.name()), HttpString.tryFromString(RequestContext.METHOD.DELETE.name()), HttpString.tryFromString(RequestContext.METHOD.PATCH.name()), HttpString.tryFromString(RequestContext.METHOD.OPTIONS.name()) ) ) ); }