about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-12-14 06:59:51 +0000
committerEric Wong <e@80x24.org>2016-12-14 08:02:52 +0000
commitd34fed5788c4ca8175ca4ef210041ae0348f56f4 (patch)
tree90149d22c0e302433c86ee8e6a800d130e7fe54c /lib
parent7fe9d585056ea5002cd789d70c3ea4bd5000759c (diff)
downloadyahns-d34fed5788c4ca8175ca4ef210041ae0348f56f4.tar.gz
Setting "Transfer-Encoding: chunked" on responses will confuse
clients which see a 204 response and do not expect a body.
This follows Rack::Chunked behavior, as yahns should function
without Rack::Chunked middleware.

This regression appeared in yahns v1.13.0 (2016-08-05)
Diffstat (limited to 'lib')
-rw-r--r--lib/yahns/http_response.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb
index a31ab70..bde4b3f 100644
--- a/lib/yahns/http_response.rb
+++ b/lib/yahns/http_response.rb
@@ -165,12 +165,12 @@ module Yahns::HttpResponse # :nodoc:
     end
     count ||= clen
 
-    if !term && chunk_ok
+    if !term && chunk_ok && !hdr_only
       term = true
       body = Yahns::ChunkBody.new(body, opt)
       buf << "Transfer-Encoding: chunked\r\n".freeze
     end
-    alive &&= term
+    alive &&= (term || hdr_only)
     buf << (alive ? "Connection: keep-alive\r\n\r\n".freeze
                   : "Connection: close\r\n\r\n".freeze)
     case rv = kgio_syssend(buf, flags)