Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ssl? should also return true if rack.url_scheme is https.

Signed-off-by: raggi <jftucker@gmail.com>
  • Loading branch information...
commit 1598f873c891288954981435e707de26cf49395d 1 parent 733e548
@josevalim josevalim authored raggi committed
Showing with 5 additions and 1 deletion.
  1. +2 −1  lib/rack/request.rb
  2. +3 −0  test/spec_request.rb
View
3  lib/rack/request.rb
@@ -266,7 +266,8 @@ def ip
end
def ssl?
- @env['HTTPS'] == 'on' || @env['HTTP_X_FORWARDED_PROTO'] == 'https'
+ (@env['HTTPS'] == 'on' || @env['HTTP_X_FORWARDED_PROTO'] == 'https') ||
+ (@env['rack.url_scheme'] == 'https')
@rkh Owner
rkh added a note

Parentheses are a bit confusing. Any reason they are that way?

@manveru Owner
manveru added a note

They're not needed, just showing the default precedence, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
end
protected
View
3  test/spec_request.rb
@@ -236,6 +236,9 @@
request = Rack::Request.new(Rack::MockRequest.env_for("/", 'HTTPS' => 'on'))
request.should.be.ssl?
+ request = Rack::Request.new(Rack::MockRequest.env_for("/", 'rack.url_scheme' => 'https'))
+ request.should.be.ssl?
+
request = Rack::Request.new(Rack::MockRequest.env_for("/", 'HTTP_HOST' => 'www.example.org:8080'))
request.should.not.be.ssl?
Please sign in to comment.
Something went wrong with that request. Please try again.