The webrick handler has a typo in line 73 that prevents the correct setting of rack.url_scheme unless ENV['HTTPS'] is defined. The check should be for env['HTTPS'] instead. It's that way in the mongrel handler, and webrick does set env['HTTPS'] on SSL requests.
The bug is in all versions of rack that I've looked at, including the latest releases.
Don't rely on ENV. Fixes #532