io.undertow.server.handlers

## Class RequestLimit

- java.lang.Object
- - io.undertow.server.handlers.RequestLimit

    public class RequestLimit
    extends Object

Represents a limit on a number of running requests.

This is basically a counter with a configured set of limits, that is used by `RequestLimitingHandler`.

When the number of active requests goes over the configured max requests then requests will be suspended and queued.

If the queue is full requests will be rejected with a 503 Service Unavailable according to RFC7231 Section 6.6.4.

The reason why this is abstracted out into a separate class is so that multiple handlers can share the same state. This allows for fine grained control of resources.

Author:
  Stuart Douglas
See Also:
  `RequestLimitingHandler`

### Constructor Summary

Constructors
Constructor and Description
`RequestLimit(int maximumConcurrentRequests)`
`RequestLimit(int maximumConcurrentRequests, int queueSize)` Construct a new instance.

### Method Summary

All Methods Instance Methods Concrete Methods
`HttpHandler` `getFailureHandler()`
`int` `getMaximumConcurrentRequests()` Get the maximum concurrent requests.
`void` `handleRequest(HttpServerExchange exchange, HttpHandler next)`
`void` `setFailureHandler(HttpHandler failureHandler)`
`int` `setMaximumConcurrentRequests(int newMax)` Set the maximum concurrent requests.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### RequestLimit

    public RequestLimit(int maximumConcurrentRequests)

#### RequestLimit

    public RequestLimit(int maximumConcurrentRequests,
                        int queueSize)

Construct a new instance. The maximum number of concurrent requests must be at least one.

Parameters:
  `maximumConcurrentRequests` - the maximum concurrent requests
  `queueSize` - The maximum number of requests to queue

### Method Detail

#### handleRequest

    public void handleRequest(HttpServerExchange exchange,
                              HttpHandler next)
                       throws Exception

Throws:
  `Exception`

#### getMaximumConcurrentRequests

    public int getMaximumConcurrentRequests()

Get the maximum concurrent requests.

Returns:
  the maximum concurrent requests

#### setMaximumConcurrentRequests

    public int setMaximumConcurrentRequests(int newMax)

Set the maximum concurrent requests. The value must be greater than or equal to one.

Parameters:
  `newMax` - the maximum concurrent requests

#### getFailureHandler

    public HttpHandler getFailureHandler()

#### setFailureHandler

    public void setFailureHandler(HttpHandler failureHandler)