From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.4 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, LOCALPART_IN_SUBJECT shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A0BFC2021F; Tue, 2 Aug 2016 20:54:42 +0000 (UTC) Date: Tue, 2 Aug 2016 20:54:42 +0000 From: Eric Wong To: spew@80x24.org Subject: spew Message-ID: <20160802205442.GA6313@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index 88ff9f9..f2d9c62 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -126,6 +126,7 @@ def http_response_write(status, headers, body, hdr_only) k = self.class alive = @hs.next? && k.persistent_connections flags = MSG_DONTWAIT + term = false if @hs.headers? code = status.to_i @@ -147,14 +148,19 @@ def http_response_write(status, headers, body, hdr_only) # allow Rack apps to tell us they want to drop the client alive = false if value =~ /\bclose\b/i when %r{\AContent-Length\z}i + term = true flags |= MSG_MORE if value.to_i > 0 && !hdr_only kv_str(buf, key, value) + when %r{\ATransfer-Encoding\z}i + term = true if value =~ /\bchunked\b/i + kv_str(buf, key, value) when "rack.hijack" hijack = value else kv_str(buf, key, value) end end + alive &&= term buf << (alive ? "Connection: keep-alive\r\n\r\n".freeze : "Connection: close\r\n\r\n".freeze) case rv = kgio_syssend(buf, flags)