diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-05-04 16:41:36 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-05-04 16:41:36 -0700 |
commit | f81aa02448b615c4d5fc4f6544c53289dae9d2ec (patch) | |
tree | ca8b4d49e5baaedb7106932c3fc73d0078e5a0d1 /ext/unicorn_http/global_variables.h | |
parent | 3a76dc40dda91a3804276fcc73260bb2a529c034 (diff) | |
download | unicorn-f81aa02448b615c4d5fc4f6544c53289dae9d2ec.tar.gz |
There's an HTTP status code allocated for it in <http://www.iana.org/assignments/http-status-codes>, so return that instead of 400.
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)); \ |