class ASF::HTTPS_workarounds

Apache httpd on the original whimsy-vm was behind a proxy that converts https requests into http requests. Update the environment variables to match. This middleware is likely now obsolte.

Public Class Methods

new(app) click to toggle source

capture the app

# File lib/whimsy/asf/rack.rb, line 231
def initialize(app)
  @app = app

Public Instance Methods

call(env) click to toggle source

if HTTPS is set in the environment, rewrite the SCRIPT_URI and SERVER_PORT; and strip index.html from the PATH_INFO and SCRIPT_URI.

# File lib/whimsy/asf/rack.rb, line 238
def call(env)
  if env['HTTPS'] == 'on'
    env['SCRIPT_URI'].sub!(/^http:/, 'https:')
    env['SERVER_PORT'] = '443'

    # for reasons I don't understand, Passenger on whimsy doesn't
    # forward root directory requests directly, so as a workaround
    # these requests are rewritten and the following code maps
    # the requests back:
    if env['PATH_INFO'] == '/index.html'
      env['PATH_INFO'] = '/'
      env['SCRIPT_URI'] += '/'