From 8c2e83f98ec8ba9dd2e02f9579b6b2cdefc1b8af Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 14 Aug 2009 22:39:11 -0700 Subject: http: support for "Connection: keep-alive" ab still sends this with HTTP/1.0 requests, which is unfortunate, but synthetic benchmarks are good for marketing purposes! --- ext/unicorn_http/unicorn_http.rl | 8 ++++++-- test/unit/test_http_parser.rb | 2 +- 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 -- cgit v1.2.3-24-ge0c7