From 0d89349e78092ad65dfca5b9131218cef0476a37 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 2 Aug 2009 15:25:42 -0700 Subject: http: move global initialization code Just extra noise we don't care about. This also allows us to undef the DEF_GLOBAL macro to avoid polluting the main namespace. --- ext/unicorn_http/global_variables.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (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 1091909..7feef93 100644 --- a/ext/unicorn_http/global_variables.h +++ b/ext/unicorn_http/global_variables.h @@ -54,4 +54,34 @@ DEF_MAX_LENGTH(REQUEST_PATH, 1024); DEF_MAX_LENGTH(QUERY_STRING, (1024 * 10)); DEF_MAX_LENGTH(HEADER, (1024 * (80 + 32))); +void init_globals(void) +{ + mUnicorn = rb_define_module("Unicorn"); + + DEF_GLOBAL(rack_url_scheme, "rack.url_scheme"); + DEF_GLOBAL(request_method, "REQUEST_METHOD"); + DEF_GLOBAL(request_uri, "REQUEST_URI"); + DEF_GLOBAL(fragment, "FRAGMENT"); + DEF_GLOBAL(query_string, "QUERY_STRING"); + DEF_GLOBAL(http_version, "HTTP_VERSION"); + DEF_GLOBAL(request_path, "REQUEST_PATH"); + DEF_GLOBAL(path_info, "PATH_INFO"); + 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"); + + eHttpParserError = + rb_define_class_under(mUnicorn, "HttpParserError", rb_eIOError); + cHttpParser = rb_define_class_under(mUnicorn, "HttpParser", rb_cObject); + sym_http_body = ID2SYM(rb_intern("http_body")); +} + +#undef DEF_GLOBAL + #endif /* global_variables_h */ -- cgit v1.2.3-24-ge0c7