class Sinatra::Request
rack.rubyforge.org/doc/classes/Rack/Request.html<br>The request object. See Rack::Request for more info:
def accept
def accept @env['sinatra.accept'] ||= begin entries = @env['HTTP_ACCEPT'].to_s.split(',') entries.map { |e| accept_entry(e) }.sort_by { |e| e.last }.map { |e| e.first } end end
def accept_entry(entry)
def accept_entry(entry) type, *options = entry.gsub(/\s/, '').split(';') quality = 0 # we sort smalles first options.delete_if { |e| quality = 1 - e[2..-1].to_f if e =~ /^q=/ } [type, [quality, type.count('*'), 1 - options.size]] end
def forwarded?
def forwarded? @env.include? "HTTP_X_FORWARDED_HOST" end
def path_info=(value)
def path_info=(value) @route = nil super end
def preferred_type(*types)
def preferred_type(*types) return accept.first if types.empty? types.flatten! accept.detect do |pattern| type = types.detect { |t| File.fnmatch(pattern, t) } return type if type end end
def route
def route @route ||= Rack::Utils.unescape(path_info) end
def secure?
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