about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--ext/unicorn_http/unicorn_http.rl8
-rw-r--r--test/unit/test_http_parser.rb2
2 files changed, 7 insertions, 3 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index 220069b..88fb163 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -100,8 +100,12 @@ static void write_value(VALUE req, struct http_parser *hp,
     VALIDATE_MAX_LENGTH(hp->s.field_len, FIELD_NAME);
     f = uncommon_field(PTR_TO(start.field), hp->s.field_len);
   } else if (f == g_http_connection) {
-    if (STR_CSTR_CASE_EQ(v, "close"))
-      hp->flags &= ~UH_FL_KEEPALIVE;
+    if (hp->flags & UH_FL_KAMETHOD) {
+      if (STR_CSTR_CASE_EQ(v, "keep-alive"))
+        hp->flags |= UH_FL_KAVERSION;
+      else if (STR_CSTR_CASE_EQ(v, "close"))
+        hp->flags &= ~UH_FL_KEEPALIVE;
+    }
   } else if (f == g_content_length) {
     hp->len.content = parse_length(RSTRING_PTR(v), RSTRING_LEN(v));
     if (hp->len.content < 0)
diff --git a/test/unit/test_http_parser.rb b/test/unit/test_http_parser.rb
index 6cef678..42aa1a3 100644
--- a/test/unit/test_http_parser.rb
+++ b/test/unit/test_http_parser.rb
@@ -79,7 +79,7 @@ class HttpParserTest < Test::Unit::TestCase
     req = {}
     tmp = "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n"
     assert_equal req.object_id, parser.headers(req, tmp).object_id
-    assert ! parser.keepalive?
+    assert parser.keepalive?
   end
 
   def test_parse_server_host_default_port