Class Sinatra::Request
In: lib/sinatra/base.rb
Parent: Rack::Request

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

Methods

External Aliases

ssl? -> secure?

Public Instance methods

Returns an array of acceptable media types for the response

[Source]

    # File lib/sinatra/base.rb, line 16
16:     def accept
17:       @env['sinatra.accept'] ||= begin
18:         entries = @env['HTTP_ACCEPT'].to_s.split(',')
19:         entries.map { |e| accept_entry(e) }.sort_by(&:last).map(&:first)
20:       end
21:     end

[Source]

    # File lib/sinatra/base.rb, line 44
44:     def forwarded?
45:       @env.include? "HTTP_X_FORWARDED_HOST"
46:     end

[Source]

    # File lib/sinatra/base.rb, line 52
52:     def path_info=(value)
53:       @route = nil
54:       super
55:     end

[Source]

    # File lib/sinatra/base.rb, line 23
23:     def preferred_type(*types)
24:       return accept.first if types.empty?
25:       types.flatten!
26:       accept.detect do |pattern|
27:         type = types.detect { |t| File.fnmatch(pattern, t) }
28:         return type if type
29:       end
30:     end

[Source]

    # File lib/sinatra/base.rb, line 48
48:     def route
49:       @route ||= Rack::Utils.unescape(path_info)
50:     end

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

[Source]

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

[Validate]