From b1adc4738b5fd9a42a5d686d67efae300d1c55ea Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 10 Aug 2009 23:55:21 -0700 Subject: http: add "HttpParser#keepalive?" method This should be used to detect if a request can really handle keepalives and pipelining. Currently, the rules are: 1. MUST be a GET or HEAD request 2. MUST be HTTP/1.1 3. MUST NOT have "Connection: close" set This also reduces the amount of garbage we create by globalizing constants and using them whenever possible. --- ext/unicorn_http/global_variables.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ext/unicorn_http/global_variables.h') diff --git a/ext/unicorn_http/global_variables.h b/ext/unicorn_http/global_variables.h index 1383ed4..b8b6221 100644 --- a/ext/unicorn_http/global_variables.h +++ b/ext/unicorn_http/global_variables.h @@ -15,16 +15,19 @@ static VALUE g_path_info; static VALUE g_server_name; static VALUE g_server_port; static VALUE g_server_protocol; -static VALUE g_server_protocol_value; static VALUE g_http_host; static VALUE g_http_x_forwarded_proto; static VALUE g_http_transfer_encoding; static VALUE g_content_length; static VALUE g_http_trailer; +static VALUE g_http_connection; static VALUE g_port_80; static VALUE g_port_443; static VALUE g_localhost; static VALUE g_http; +static VALUE g_http_11; +static VALUE g_GET; +static VALUE g_HEAD; /** Defines common length and error messages for input length validation. */ #define DEF_MAX_LENGTH(N, length) \ @@ -71,12 +74,14 @@ void init_globals(void) DEF_GLOBAL(server_name, "SERVER_NAME"); DEF_GLOBAL(server_port, "SERVER_PORT"); DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL"); - DEF_GLOBAL(server_protocol_value, "HTTP/1.1"); DEF_GLOBAL(http_x_forwarded_proto, "HTTP_X_FORWARDED_PROTO"); DEF_GLOBAL(port_80, "80"); DEF_GLOBAL(port_443, "443"); DEF_GLOBAL(localhost, "localhost"); DEF_GLOBAL(http, "http"); + DEF_GLOBAL(http_11, "HTTP/1.1"); + DEF_GLOBAL(GET, "GET"); + DEF_GLOBAL(HEAD, "HEAD"); eHttpParserError = rb_define_class_under(mUnicorn, "HttpParserError", rb_eIOError); -- cgit v1.2.3-24-ge0c7