From 2ff0f8ae66623424dd64b865e7415dd007ade280 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 19 Feb 2009 14:40:37 -0800 Subject: http11: set SERVER_NAME env regardless of Host: header The Rack spec requires it. So we'll just set it to "localhost" if we're dealing with HTTP/1.0 clients that omit the "Host:" header. --- ext/http11/http11.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ext') diff --git a/ext/http11/http11.c b/ext/http11/http11.c index ee5704b..82982e7 100644 --- a/ext/http11/http11.c +++ b/ext/http11/http11.c @@ -42,6 +42,7 @@ static VALUE global_server_protocol; static VALUE global_server_protocol_value; static VALUE global_http_host; static VALUE global_port_80; +static VALUE global_localhost; #define TRIE_INCREASE 30 @@ -302,6 +303,9 @@ void header_done(void *data, const char *at, size_t length) rb_hash_aset(req, global_server_name, temp); rb_hash_aset(req, global_server_port, global_port_80); } + } else { + rb_hash_aset(req, global_server_name, global_localhost); + rb_hash_aset(req, global_server_port, global_port_80); } /* grab the initial body and stuff it into the hash */ @@ -507,6 +511,7 @@ void Init_http11() DEF_GLOBAL(server_protocol_value, "HTTP/1.1"); DEF_GLOBAL(http_host, "HTTP_HOST"); DEF_GLOBAL(port_80, "80"); + DEF_GLOBAL(localhost, "localhost"); eHttpParserError = rb_define_class_under(mUnicorn, "HttpParserError", rb_eIOError); -- cgit v1.2.3-24-ge0c7