From a4400935d2db7028420a216f735d4d4029f985d4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 12 Feb 2016 04:00:38 +0000 Subject: set HTTPS and rack.url_scheme in Rack env as appropriate env['HTTPS'] is not documented in rack SPEC, but appears to be used by Rack::Request since 2010[*]. Also, set rack.url_scheme as documented by rack SPEC. [*] - commit 4defbe5d7c07b3ba721ff34a8ff59fde480a4a9f ("Improves performance by lazy loading the session.") --- lib/yahns/http_context.rb | 2 +- lib/yahns/server.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/yahns/http_context.rb b/lib/yahns/http_context.rb index 10be062..c02eefd 100644 --- a/lib/yahns/http_context.rb +++ b/lib/yahns/http_context.rb @@ -17,7 +17,7 @@ module Yahns::HttpContext # :nodoc: attr_accessor :qegg attr_accessor :queue # set right before spawning acceptors attr_reader :app - attr_reader :app_defaults + attr_accessor :app_defaults attr_writer :input_buffer_tmpdir attr_accessor :output_buffer_tmpdir diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb index 09ddbef..d6a03f3 100644 --- a/lib/yahns/server.rb +++ b/lib/yahns/server.rb @@ -382,6 +382,9 @@ class Yahns::Server # :nodoc: ctx.__send__(:include, l.expire_mod) if ssl_ctx = opts[:ssl_ctx] ctx.__send__(:include, Yahns::OpenSSLClient) + env = ctx.app_defaults = ctx.app_defaults.dup + env['HTTPS'] = 'on' # undocumented, but Rack::Request uses this + env['rack.url_scheme'] = 'https' # call OpenSSL::SSL::SSLContext#setup explicitly here to detect # errors and avoid race conditions. We avoid calling this in the -- cgit v1.2.3-24-ge0c7