Permalink
Browse files

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

Signed-off-by: raggi <jftucker@gmail.com>
  • Loading branch information...
1 parent 733e548 commit 1598f873c891288954981435e707de26cf49395d @josevalim josevalim committed with raggi Oct 8, 2010
Showing with 5 additions and 1 deletion.
  1. +2 −1 lib/rack/request.rb
  2. +3 −0 test/spec_request.rb
View
@@ -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
rkh Oct 16, 2010 Member

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

manveru
manveru Oct 17, 2010 Member

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

end
protected
View
@@ -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?

0 comments on commit 1598f87

Please sign in to comment.