description |
---|
This page provides the technical details of the Request Content Limit policy |
You can use the request-content-limit
policy to specify a maximum request content length allowed. This limit is compared to the content length header of the request.
Functional and implementation information for the request-content-limit
policy is organized into the following sections:
{% hint style="warning" %} This policy can be applied to v2 APIs and v4 HTTP proxy APIs. It cannot be applied to v4 message APIs or v4 TCP proxy APIs. {% endhint %}
{% tabs %} {% tab title="HTTP proxy API example" %}
"request-content-limit": {
"limit": 1000
}
{% endtab %} {% endtabs %}
The phases checked below are supported by the request-content-limit
policy:
v2 Phases | Compatible? | v4 Phases | Compatible? |
---|---|---|---|
onRequest | true | onRequest | true |
onResponse | false | onResponse | false |
onRequestContent | false | onMessageRequest | false |
onResponseContent | false | onMessageResponse | false |
The request-content-limit
policy can be configured with the following options:
Property | Required | Description | Type |
---|---|---|---|
limit | true | Maximum length of request content allowed | int |
The following is the compatibility matrix for APIM and the request-content-limit
policy:
Plugin Version | Supported APIM versions |
---|---|
1.x | All |
HTTP status code | Message |
---|---|
400 | The limit from the configuration is not correct. |
413 | Incoming HTTP request payload exceed the size limit. |
411 | The HTTP request is not chunked and does not specify the Content-Length header. |
You can use the response template feature to override the default responses provided by the policy. These templates must be defined at the API level (see the API Console Response Templates option in the API Proxy menu).
Some possible responses are:
Error | description |
---|---|
400 | Content-length is not a valid integer. |
411 | The request did not specify the length of its content, which is required by the requested resource. |
413 | The request is larger than the server is willing or able to process. |
The error keys sent by this policy are as follows:
Key | Parameters |
---|---|
REQUEST_CONTENT_LIMIT_TOO_LARGE | length - limit |
REQUEST_CONTENT_LIMIT_LENGTH_REQUIRED | limit |
{% @github-files/github-code-block url="https://github.com/gravitee-io/gravitee-policy-request-content-limit/blob/master/CHANGELOG.md" %}