diff --git a/docs/compile_options.md b/docs/compile_options.md index 178f05a3..4b4f9f9e 100644 --- a/docs/compile_options.md +++ b/docs/compile_options.md @@ -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'" +``` diff --git a/ext/puma_http11/puma_http11.c b/ext/puma_http11/puma_http11.c index 35c70812..367137c8 100644 --- a/ext/puma_http11/puma_http11.c +++ b/ext/puma_http11/puma_http11.c @@ -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)));