Parent

Sinatra::Request

The request object. See Rack::Request for more info: rack.rubyforge.org/doc/classes/Rack/Request.html

Public Class Methods

new(env) click to toggle source
# File lib/sinatra/base.rb, line 15
def self.new(env)
  env['sinatra.request'] ||= super
end

Public Instance Methods

accept() click to toggle source

Returns an array of acceptable media types for the response

# File lib/sinatra/base.rb, line 20
def accept
  @env['sinatra.accept'] ||= begin
    entries = @env['HTTP_ACCEPT'].to_s.split(',')
    entries.map { |e| accept_entry(e) }.sort_by(&:last).map(&:first)
  end
end
forwarded?() click to toggle source
# File lib/sinatra/base.rb, line 48
def forwarded?
  @env.include? "HTTP_X_FORWARDED_HOST"
end
path_info=(value) click to toggle source
# File lib/sinatra/base.rb, line 56
def path_info=(value)
  @route = nil
  super
end
preferred_type(*types) click to toggle source
# File lib/sinatra/base.rb, line 27
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
route() click to toggle source
# File lib/sinatra/base.rb, line 52
def route
  @route ||= Rack::Utils.unescape(path_info)
end
secure?() click to toggle source

Whether or not the web server (or a reverse proxy in front of it) is using SSL to communicate with the client.

# File lib/sinatra/base.rb, line 39
def secure?
  @env['HTTPS'] == 'on' or
  @env['HTTP_X_FORWARDED_PROTO'] == 'https' or
  @env['rack.url_scheme'] == 'https'
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.