class Sinatra::Request

def secure?

using SSL to communicate with the client.
Whether or not the web server (or a reverse proxy in front of it) is
def secure?
  @env['HTTPS'] == 'on' or
  @env['HTTP_X_FORWARDED_PROTO'] == 'https' or
  @env['rack.url_scheme'] == 'https'
end