class Sinatra::Request

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

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
accept?(*types) click to toggle source
Alias for: preferred_type
forwarded?() click to toggle source
# File lib/sinatra/base.rb, line 39
def forwarded?
  @env.include? "HTTP_X_FORWARDED_HOST"
end
idempotent?() click to toggle source
# File lib/sinatra/base.rb, line 47
def idempotent?
  safe? or put? or delete?
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
Also aliased as: accept?
safe?() click to toggle source
# File lib/sinatra/base.rb, line 43
def safe?
  get? or head? or options? or trace?
end