diff options
author | Eric Wong <e@80x24.org> | 2015-06-09 22:15:25 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-06-10 09:20:31 +0000 |
commit | 91e4f202d4db4ebcb9a4eb863d4598f3c0f73858 (patch) | |
tree | 1090daac95fc83d76afbc1c5aedc26d2a3b41b59 /lib/yahns/http_response.rb | |
parent | 8e5d64502e478c7e93d7168628d97f66417fcabe (diff) | |
download | yahns-91e4f202d4db4ebcb9a4eb863d4598f3c0f73858.tar.gz |
Middlewares such as Rack::Lock (used by Rails) break badly unless the response body is closed on hijack, so we will close it to follow the lead of other popular Rack servers. While it's unclear if there's anybody using rack.hijack besides yahns/proxy_pass we'll try to emulate the behavior of other servers as much as possible. ref: https://github.com/ngauthier/tubesock/issues/10 While we're at it, use DieIfUsed correctly in test_ssl.rb :x
Diffstat (limited to 'lib/yahns/http_response.rb')
-rw-r--r-- | lib/yahns/http_response.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index 1be28bc..fabd4b7 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -69,7 +69,9 @@ module Yahns::HttpResponse # :nodoc: end wbuf = Yahns::Wbuf.new(body, alive, self.class.output_buffer_tmpdir, ret) rv = wbuf.wbuf_write(self, header) - body.each { |chunk| rv = wbuf.wbuf_write(self, chunk) } if body + if body && ! alive.respond_to?(:call) # skip body.each if hijacked + body.each { |chunk| rv = wbuf.wbuf_write(self, chunk) } + end wbuf_maybe(wbuf, rv) end @@ -155,7 +157,6 @@ module Yahns::HttpResponse # :nodoc: buf << kv_str(key, value) when "rack.hijack" hijack = value - body = nil # ensure we do not close body else buf << kv_str(key, value) end |