Class: Sinatra::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/sinatra/base.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#acceptObject

Returns an array of acceptable media types for the response



26
27
28
# File 'lib/sinatra/base.rb', line 26

def accept
  @env['HTTP_ACCEPT'].to_s.split(',').map { |a| a.strip }
end

#paramsObject

Override Rack 0.9.x’s #params implementation (see #72 in lighthouse)



31
32
33
34
35
# File 'lib/sinatra/base.rb', line 31

def params
  self.GET.update(self.POST)
rescue EOFError, Errno::ESPIPE
  self.GET
end

#secure?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/sinatra/base.rb', line 37

def secure?
  (@env['HTTP_X_FORWARDED_PROTO'] || @env['rack.url_scheme']) == 'https'
end

#user_agentObject



21
22
23
# File 'lib/sinatra/base.rb', line 21

def user_agent
  @env['HTTP_USER_AGENT']
end