Class: Rack::IeRedirectFix
- Inherits:
-
Object
- Object
- Rack::IeRedirectFix
- Defined in:
- lib/rack-ie-redirect-fix.rb,
lib/rack-ie-redirect-fix/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ IeRedirectFix
constructor
A new instance of IeRedirectFix.
Constructor Details
#initialize(app) ⇒ IeRedirectFix
Returns a new instance of IeRedirectFix.
6 7 8 |
# File 'lib/rack-ie-redirect-fix.rb', line 6 def initialize app @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rack-ie-redirect-fix.rb', line 10 def call env status, headers, body = @app.call env if status.to_i == 302 uri = URI.parse headers['Location'] if uri.scheme == "http" and uri.host == env['SERVER_NAME'] uri.scheme = 'https' body_str = %Q{<html><body>You are being <a href="#{uri.to_s}">redirected</a>.</body></html>} headers = headers.merge 'Location' => uri.to_s, 'Content-Length' => body_str.size.to_s # The RSpec tests don't pick this up, but this is necessary body = [body_str] end end [status, headers, body] end |