dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: spew
Date: Tue, 2 Aug 2016 20:54:42 +0000	[thread overview]
Message-ID: <20160802205442.GA6313@dcvr> (raw)

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)

             reply	other threads:[~2016-08-02 20:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 20:54 Eric Wong [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-08-23 19:32 spew Eric Wong
2015-06-29 17:45 spew Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160802205442.GA6313@dcvr \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).