module ActionDispatch::Http::URL
def protocol
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com', 'HTTPS' => 'on'
req.protocol # => "http://"
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com'
Returns 'https://' if this is an SSL request and 'http://' otherwise.
def protocol @protocol ||= ssl? ? "https://" : "http://" end