From 6dfc7482e4414a7b2d18af127065c15aede39b62 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 2 Aug 2009 15:30:55 -0700 Subject: http: cleanup setting for common values => globals We'll need to be defining g_http_transfer_encoding and g_content_length in the near future. --- ext/unicorn_http/unicorn_http.rl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index 299d2d9..6ce6be4 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -310,6 +310,11 @@ static VALUE HttpParser_execute(VALUE self, VALUE req, VALUE data) rb_raise(eHttpParserError, "Requested start is after data buffer end."); } +#define SET_GLOBAL(var,str) do { \ + var = find_common_field(str, sizeof(str) - 1); \ + assert(var != Qnil); \ +} while (0) + void Init_unicorn_http(void) { init_globals(); @@ -318,6 +323,6 @@ void Init_unicorn_http(void) rb_define_method(cHttpParser, "reset", HttpParser_reset,0); rb_define_method(cHttpParser, "execute", HttpParser_execute,2); init_common_fields(); - g_http_host = find_common_field("HOST", 4); - assert(g_http_host != Qnil); + SET_GLOBAL(g_http_host, "HOST"); } +#undef SET_GLOBAL -- cgit v1.2.3-24-ge0c7