diff options
Diffstat (limited to 'lib/yahns/http_client.rb')
-rw-r--r-- | lib/yahns/http_client.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index 7351171..0c656e8 100644 --- a/lib/yahns/http_client.rb +++ b/lib/yahns/http_client.rb @@ -193,9 +193,9 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: mkinput_preread # keep looping (@state == :body) true else # :lazy, false - r = k.app.call(env = @hs.env) - return :ignore if env.include?(RACK_HIJACK_IO) - http_response_write(*r) + status, headers, body = k.app.call(env = @hs.env) + return :ignore if app_hijacked?(env, body) + http_response_write(status, headers, body) end end @@ -217,7 +217,7 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: # run the rack app status, headers, body = k.app.call(env.merge!(k.app_defaults)) - return :ignore if env.include?(RACK_HIJACK_IO) + return :ignore if app_hijacked?(env, body) if status.to_i == 100 rv = http_100_response(env) and return rv status, headers, body = k.app.call(env) @@ -298,4 +298,10 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: shutdown rescue nil return # always drop the connection on uncaught errors end + + def app_hijacked?(env, body) + return false unless env.include?(RACK_HIJACK_IO) + body.close if body.respond_to?(:close) + true + end end |