class RSence::Request

Simple Request class, slightly more involved than the Rack::Request it’s extending.

Attributes

header[R]
path[R]
query[R]

Public Class Methods

new(env) click to toggle source
Calls superclass method
# File lib/rsence/http/request.rb, line 21
def initialize(env)
  @header = RequestHeader.new
  super
  env2header()
  @path = path_info()
  @query = params()
end

Public Instance Methods

env2header() click to toggle source
# File lib/rsence/http/request.rb, line 31
def env2header
  [ ['SERVER_NAME',           'server-name'],
    ['HTTP_USER_AGENT',       'user-agent'],
    ['HTTP_ACCEPT_ENCODING',  'accept-encoding'],
    ['PATH_INFO',             'path-info'],
    ['HTTP_HOST',             'host'],
    ['HTTP_ACCEPT_LANGUAGE',  'accept-language'],
    ['SERVER_PROTOCOL',       'server-protocol'],
    ['REQUEST_PATH',          'request-path'],
    ['HTTP_KEEP_ALIVE',       'keep-alive'],
    ['SERVER_SOFTWARE',       'server-software'],
    ['REMOTE_ADDR',           'remote-addr'],
    ['HTTP_REFERER',          'referer'],
    ['HTTP_VERSION',          'version'],
    ['HTTP_ACCEPT_CHARSET',   'accept-charset'],
    ['REQUEST_URI',           'request-uri'],
    ['SERVER_PORT',           'server-port'],
    ['QUERY_STRING',          'query-string'],
    ['HTTP_ACCEPT',           'accept'],
    ['REQUEST_METHOD',        'request-method'],
    ['HTTP_CONNECTION',       'connection'],
    ['HTTP_SOAPACTION',       'soapaction'],
    ['HTTP_FORWARDED_HOST',   'forwarded-host']
  ].each do |env_key,header_key|
    if @env.has_key?(env_key)
      @header[header_key] = @env[env_key]
    end
    if env_key.start_with?( 'HTTP_' )
      x_env_key = "HTTP_X#{env_key[4..-1]}"
      if @env.has_key?( x_env_key )
        @header["x-#{header_key}"] = @env[ x_env_key ]
      end
    end
  end
end
unparsed_uri() click to toggle source
# File lib/rsence/http/request.rb, line 28
def unparsed_uri
  return @header['request-uri']
end