This project is archived and is in readonly mode.
request.ssl? should reflect rack.url_scheme
Reported by Steven Parkes | October 1st, 2010 @ 10:38 PM
Thin will set env["rack.url_scheme"] = "https" for SSL connections but the request object in Rails doesn't reflect this. It should, shouldn't it?
Comments and changes to this ticket
- State changed from new to invalid
- Importance changed from to Low
ssl?method was removed in http://github.com/rails/rails/commit/50215f9525b6b5e3bfe703724b9f68... - I posted a comment asking why because other methods in the same module seems to depend on it. There might be a perfectly good reason, so I'm marking this as invalid for now.
Steven, this is the way both Rack and Rails check if a connection is using SSL:
Not sure why Thin sets
env["rack.url_scheme"] = "https"maybe you can point to somewhere in the rack specification?
- State changed from invalid to open
- Assigned user set to José Valim
Hrm, actually after looking at Rack tests, I've noticed they indeed check for both "HTTPS" and "rack.url_scheme". I will check with Rack maintainers.
Thanks, José. I suggested the patch for Thin based on ... something I saw? Can't remember where I first saw rack.url_scheme. Might have been the rack tests. Maybe Sinatra?
Anyway, once we know what's "right", I can try to make sure Thin follows suit.
What's the rack fix? Request#ssl? looking at env["rack.url_scheme"] instead of env["HTTPS"] and env["HTTP_X_FORWARDED_PROTO"]?
Now that I'm a little more awake, rack.url_scheme is in the spec, but HTTPS and HTTP_X_FORWARDED_PROTO aren't. My interpretation is that rack clients should only look at rack.url_scheme or Request#ssl? and leave the HTTPS/HTTP_X_FORWARDED_PROTO to the rack container?
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
I believe this is still an issue in Rails, at least up to 3.0.7.
Looking at url.rb (https://github.com/rails/rails/blob/3-0-7/actionpack/lib/action_dis...) you can see that the "ssl?" method doesn't take into account the "rack.url_scheme" environment setting (available through request.env['rack.url_scheme'].
However, as mentioned before, the 3.0.7 tests still use it: https://github.com/rails/rails/blob/3-0-7/actionpack/test/dispatch/...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>