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.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb
index 1cdaa0f..873dd73 100644
--- a/lib/yahns/http_client.rb
+++ b/lib/yahns/http_client.rb
@@ -189,9 +189,11 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
       mkinput_preread # keep looping (@state == :body)
       true
     else # :lazy, false
-      status, headers, body = k.app.call(env = @hs.env)
+      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)
+      http_response_write(status, headers, body, hdr_only)
     end
   end
 
@@ -220,6 +222,7 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
       env['SERVER_PORT'] = '443'.freeze
     end
 
+    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)
@@ -229,7 +232,7 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
     end
 
     # this returns :wait_readable, :wait_writable, :ignore, or nil:
-    http_response_write(status, headers, body)
+    http_response_write(status, headers, body, hdr_only)
   end
 
   # called automatically by kgio_write