Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

request.ssl? should reflect rack.url_scheme

#5750

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?

Reported by Steven Parkes · October 1st, 2010 @ 10:38 PM

State: stale
Milestone: none
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. David Trasbo
    David Trasbo
    • State changed from new to invalid
    • Importance changed from to Low

    The 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.

    October 8th, 2010 @ 10:14 AM

  2. David Trasbo
    David Trasbo

    Yep, there was. ssl? is defined in Rack.

    October 8th, 2010 @ 10:17 AM

  3. José Valim
    José Valim

    Steven, this is the way both Rack and Rails check if a connection is using SSL:

    http://github.com/rack/rack/blob/master/lib/rack/request.rb#L269

    Not sure why Thin sets env["rack.url_scheme"] = "https" maybe you can point to somewhere in the rack specification?

    October 8th, 2010 @ 10:21 AM

  4. José Valim
    José Valim
    • 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.

    http://github.com/rack/rack/blob/master/test/spec_mock.rb#L106

    October 8th, 2010 @ 10:22 AM

  5. Steven Parkes
    Steven Parkes

    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.

    Thanks!

    October 8th, 2010 @ 01:59 PM

  6. José Valim
    José Valim

    Both are valid! Can you provide a patch for Rails 3-0-stable? I will fix it in rack. :)

    October 8th, 2010 @ 02:01 PM

  7. Steven Parkes
    Steven Parkes

    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?

    October 8th, 2010 @ 02:18 PM

  8. Jeff Kreeftmeijer
  9. Santiago Pastorino
    Santiago Pastorino

    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.

    February 9th, 2011 @ 12:31 AM

  10. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 9th, 2011 @ 12:31 AM

  11. Craig
    Craig

    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/...

    Any thoughts?

    April 20th, 2011 @ 12:08 PM