module Roda::RodaPlugins::RedirectHttpToHttps::RequestMethods
Public Instance Methods
Source
# File lib/roda/plugins/redirect_http_to_https.rb, line 67 def redirect_http_to_https return if ssl? opts = roda_class.opts[:redirect_http_to_https] res = response if body = opts[:body] res.write(body) end if headers = opts[:headers] res.headers.merge!(headers) end path = if prefix = opts[:prefix] prefix + fullpath else "https://#{host}#{opts[:port_string]}#{fullpath}" end unless status = opts[:status_map][@env['REQUEST_METHOD']] raise RodaError, "redirect_http_to_https :status_map provided does not support #{@env['REQUEST_METHOD']}" end redirect(path, status) end
Redirect HTTP requests to HTTPS. While this doesn’t secure the current request, it makes it more likely that the browser will submit future requests securely via HTTPS.