protocol() public

Returns ‘https://’ if this is an SSL request and ‘http://’ otherwise.

class Request < Rack::Request
  include ActionDispatch::Http::URL
end

req = Request.new 'HTTP_HOST' => 'example.com'
req.protocol # => "http://"

req = Request.new 'HTTP_HOST' => 'example.com', 'HTTPS' => 'on'
req.protocol # => "https://"
Show source
Register or log in to add new notes.