diff options
Diffstat (limited to 'ext/unicorn_http/global_variables.h')
-rw-r--r-- | ext/unicorn_http/global_variables.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/unicorn_http/global_variables.h b/ext/unicorn_http/global_variables.h index cdbc42d..cda7f24 100644 --- a/ext/unicorn_http/global_variables.h +++ b/ext/unicorn_http/global_variables.h @@ -1,6 +1,7 @@ #ifndef global_variables_h #define global_variables_h static VALUE eHttpParserError; +static VALUE eRequestURITooLongError; static VALUE g_rack_url_scheme; static VALUE g_request_method; @@ -36,6 +37,7 @@ static VALUE g_http_11; "HTTP element " # N " is longer than the " # length " allowed length." NORETURN(static void parser_error(const char *)); +NORETURN(static void raise_414(const char *)); /** * Validates the max length of given input and throws an HttpParserError @@ -46,6 +48,11 @@ NORETURN(static void parser_error(const char *)); parser_error(MAX_##N##_LENGTH_ERR); \ } while (0) +#define VALIDATE_MAX_URI_LENGTH(len, N) do { \ + if (len > MAX_##N##_LENGTH) \ + raise_414(MAX_##N##_LENGTH_ERR); \ +} while (0) + /** Defines global strings in the init method. */ #define DEF_GLOBAL(N, val) do { \ g_##N = rb_obj_freeze(rb_str_new(val, sizeof(val) - 1)); \ |