Allow configuring request uri max length & request path max length (#2840)

This commit is contained in:
Łukasz Maślej 2022-04-14 01:55:45 +02:00 committed by GitHub
parent a7f48495e8
commit 34c3c59809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 2 deletions

View File

@ -19,3 +19,37 @@ For Bundler, use its configuration system:
```
bundle config build.puma "--with-cflags='-D PUMA_QUERY_STRING_MAX_LENGTH=64000'"
```
## Request Path, `PUMA_REQUEST_PATH_MAX_LENGTH`
By default, the max length of `REQUEST_PATH` is `8192`. But you may want to
adjust it to accept longer paths in requests.
For manual install, pass the `PUMA_REQUEST_PATH_MAX_LENGTH` option like this:
```
gem install puma -- --with-cflags="-D PUMA_REQUEST_PATH_MAX_LENGTH=64000"
```
For Bundler, use its configuration system:
```
bundle config build.puma "--with-cflags='-D PUMA_REQUEST_PATH_MAX_LENGTH=64000'"
```
## Request URI, `PUMA_REQUEST_URI_MAX_LENGTH`
By default, the max length of `REQUEST_URI` is `1024 * 12`. But you may want to
adjust it to accept longer URIs in requests.
For manual install, pass the `PUMA_REQUEST_URI_MAX_LENGTH` option like this:
```
gem install puma -- --with-cflags="-D PUMA_REQUEST_URI_MAX_LENGTH=64000"
```
For Bundler, use its configuration system:
```
bundle config build.puma "--with-cflags='-D PUMA_REQUEST_URI_MAX_LENGTH=64000'"
```

View File

@ -52,15 +52,23 @@ static VALUE global_request_path;
/* Defines the maximum allowed lengths for various input elements.*/
#ifndef PUMA_REQUEST_URI_MAX_LENGTH
#define PUMA_REQUEST_URI_MAX_LENGTH (1024 * 12)
#endif
#ifndef PUMA_REQUEST_PATH_MAX_LENGTH
#define PUMA_REQUEST_PATH_MAX_LENGTH (8192)
#endif
#ifndef PUMA_QUERY_STRING_MAX_LENGTH
#define PUMA_QUERY_STRING_MAX_LENGTH (1024 * 10)
#endif
DEF_MAX_LENGTH(FIELD_NAME, 256);
DEF_MAX_LENGTH(FIELD_VALUE, 80 * 1024);
DEF_MAX_LENGTH(REQUEST_URI, 1024 * 12);
DEF_MAX_LENGTH(REQUEST_URI, PUMA_REQUEST_URI_MAX_LENGTH);
DEF_MAX_LENGTH(FRAGMENT, 1024); /* Don't know if this length is specified somewhere or not */
DEF_MAX_LENGTH(REQUEST_PATH, 8192);
DEF_MAX_LENGTH(REQUEST_PATH, PUMA_REQUEST_PATH_MAX_LENGTH);
DEF_MAX_LENGTH(QUERY_STRING, PUMA_QUERY_STRING_MAX_LENGTH);
DEF_MAX_LENGTH(HEADER, (1024 * (80 + 32)));