about summary refs log tree commit homepage
path: root/lib/yahns/http_client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/yahns/http_client.rb')
-rw-r--r--lib/yahns/http_client.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb
index 873dd73..7a1bac1 100644
--- a/lib/yahns/http_client.rb
+++ b/lib/yahns/http_client.rb
@@ -191,9 +191,9 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
     else # :lazy, false
       env = @hs.env
       hdr_only = env['REQUEST_METHOD'] == 'HEAD'.freeze
-      status, headers, body = k.app.call(env)
-      return :ignore if app_hijacked?(env, body)
-      http_response_write(status, headers, body, hdr_only)
+      res = k.app.call(env)
+      return :ignore if app_hijacked?(env, res)
+      http_response_write(res, hdr_only)
     end
   end
 
@@ -224,15 +224,15 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
 
     hdr_only = env['REQUEST_METHOD'] == 'HEAD'.freeze
     # run the rack app
-    status, headers, body = k.app.call(env)
-    return :ignore if app_hijacked?(env, body)
-    if status.to_i == 100
+    res = k.app.call(env)
+    return :ignore if app_hijacked?(env, res)
+    if res[0].to_i == 100
       rv = http_100_response(env) and return rv
-      status, headers, body = k.app.call(env)
+      res = k.app.call(env)
     end
 
     # this returns :wait_readable, :wait_writable, :ignore, or nil:
-    http_response_write(status, headers, body, hdr_only)
+    http_response_write(res, hdr_only)
   end
 
   # called automatically by kgio_write
@@ -308,9 +308,9 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
     return # always drop the connection on uncaught errors
   end
 
-  def app_hijacked?(env, body)
+  def app_hijacked?(env, res)
     return false unless env.include?('rack.hijack_io'.freeze)
-    body.close if body.respond_to?(:close)
+    res[2].close if res && res[2].respond_to?(:close)
     true
   end