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 Class methods

[Source]

    # File lib/sinatra/base.rb, line 15
15:     def self.new(env)
16:       env['sinatra.request'] ||= super
17:     end

Public Instance methods

Returns an array of acceptable media types for the response

[Source]

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

[Source]

    # File lib/sinatra/base.rb, line 48
48:     def forwarded?
49:       @env.include? "HTTP_X_FORWARDED_HOST"
50:     end

[Source]

    # File lib/sinatra/base.rb, line 56
56:     def path_info=(value)
57:       @route = nil
58:       super
59:     end

[Source]

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

[Source]

    # File lib/sinatra/base.rb, line 52
52:     def route
53:       @route ||= Rack::Utils.unescape(path_info)
54:     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 39
39:       def secure?
40:         @env['HTTPS'] == 'on' or
41:         @env['HTTP_X_FORWARDED_PROTO'] == 'https' or
42:         @env['rack.url_scheme'] == 'https'
43:       end

[Validate]