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.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb
index c300742..272db85 100644
--- a/lib/yahns/http_client.rb
+++ b/lib/yahns/http_client.rb
@@ -206,8 +206,17 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
       end
     end
 
+    env.merge!(k.app_defaults)
+
+    # workaround stupid unicorn_http parser behavior when it parses HTTP_HOST
+    if env['HTTPS'] == 'on'.freeze &&
+        env['HTTP_HOST'] &&
+        env['SERVER_PORT'] == '80'.freeze
+      env['SERVER_PORT'] = '443'.freeze
+    end
+
     # run the rack app
-    status, headers, body = k.app.call(env.merge!(k.app_defaults))
+    status, headers, body = k.app.call(env)
     return :ignore if app_hijacked?(env, body)
     if status.to_i == 100
       rv = http_100_response(env) and return rv