about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-21 11:14:42 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-21 11:16:25 -0700
commit78c076ebb118a8312a2912dddb8a93d3ea80fa99 (patch)
tree708cd4175f92b26e636490d0474abaf088a02ff9
parentaca95eb1157eff8351320c4b2f5daa904330e904 (diff)
downloadunicorn-78c076ebb118a8312a2912dddb8a93d3ea80fa99.tar.gz
-rw-r--r--ext/unicorn/http11/http11.c4
-rw-r--r--lib/unicorn/http_request.rb1
-rw-r--r--test/unit/test_http_parser.rb6
3 files changed, 7 insertions, 4 deletions
diff --git a/ext/unicorn/http11/http11.c b/ext/unicorn/http11/http11.c
index 42dcf99..fbe2432 100644
--- a/ext/unicorn/http11/http11.c
+++ b/ext/unicorn/http11/http11.c
@@ -262,6 +262,10 @@ static void header_done(void *data, const char *at, size_t length)
   VALUE server_port = global_port_80;
   VALUE temp;
 
+  /* rack requires QUERY_STRING */
+  if (rb_hash_aref(req, global_query_string) == Qnil)
+    rb_hash_aset(req, global_query_string, rb_str_new(NULL, 0));
+
   /* set rack.url_scheme to "https" or "http", no others are allowed by Rack */
   if ((temp = rb_hash_aref(req, global_http_x_forwarded_proto)) != Qnil &&
       RSTRING_LEN(temp) == 5 &&
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index 7233008..d170505 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -128,7 +128,6 @@ module Unicorn
       #  that client may be a proxy, gateway, or other intermediary
       #  acting on behalf of the actual source client."
       @params[Const::REMOTE_ADDR] = socket.unicorn_peeraddr
-      @params[Const::QUERY_STRING] ||= ''
       @params[Const::RACK_INPUT] = @body
       @params.update(DEF_PARAMS)
     end
diff --git a/test/unit/test_http_parser.rb b/test/unit/test_http_parser.rb
index 37a539d..1f3c9d2 100644
--- a/test/unit/test_http_parser.rb
+++ b/test/unit/test_http_parser.rb
@@ -22,7 +22,7 @@ class HttpParserTest < Test::Unit::TestCase
     assert_equal '/', req['REQUEST_URI']
     assert_equal 'GET', req['REQUEST_METHOD']
     assert_nil req['FRAGMENT']
-    assert_nil req['QUERY_STRING']
+    assert_equal '', req['QUERY_STRING']
 
     parser.reset
     req.clear
@@ -40,7 +40,7 @@ class HttpParserTest < Test::Unit::TestCase
     assert_equal '/hello-world', req['REQUEST_URI']
     assert_equal 'GET', req['REQUEST_METHOD']
     assert_nil req['FRAGMENT']
-    assert_nil req['QUERY_STRING']
+    assert_equal '', req['QUERY_STRING']
   end
 
   def test_parse_strange_headers
@@ -100,7 +100,7 @@ class HttpParserTest < Test::Unit::TestCase
     assert parser.execute(req, http << "\n")
     assert_equal 'HTTP/1.1', req['SERVER_PROTOCOL']
     assert_nil req['FRAGMENT']
-    assert_nil req['QUERY_STRING']
+    assert_equal '', req['QUERY_STRING']
   end
 
   def test_absolute_uri