Class: RSence::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- RSence::Request
- Defined in:
- lib/rsence/http/request.rb
Overview
Simple Request class, slightly more involved than the Rack::Request it’s extending.
Defined Under Namespace
Classes: RequestHeader
Constant Summary collapse
- @@env_transl =
{ 'SERVER_NAME' => 'server-name', 'PATH_INFO' => 'path-info', 'SERVER_PROTOCOL' => 'server-protocol', 'REQUEST_PATH' => 'request-path', 'SERVER_SOFTWARE' => 'server-software', 'REMOTE_ADDR' => 'remote-addr', 'REQUEST_URI' => 'request-uri', 'SERVER_PORT' => 'server-port', 'QUERY_STRING' => 'query-string', 'REQUEST_METHOD' => 'request-method' }
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #env2header ⇒ Object
-
#initialize(env) ⇒ Request
constructor
A new instance of Request.
- #unparsed_uri ⇒ Object
Constructor Details
#initialize(env) ⇒ Request
Returns a new instance of Request.
13 14 15 16 17 18 19 |
# File 'lib/rsence/http/request.rb', line 13 def initialize(env) @header = RequestHeader.new super env2header() @path = path_info() @query = params() end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
7 8 9 |
# File 'lib/rsence/http/request.rb', line 7 def header @header end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/rsence/http/request.rb', line 7 def path @path end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
7 8 9 |
# File 'lib/rsence/http/request.rb', line 7 def query @query end |
Instance Method Details
#env2header ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rsence/http/request.rb', line 35 def env2header @env.each do |env_key,env_val| if @@env_transl.has_key?(env_key) http_key = @@env_transl[env_key] @header[http_key] = @env[env_key] elsif env_key.start_with?( 'HTTP_' ) http_key = env_key[4..-1].gsub(/_([A-Z0-9]+)/) {|m|'-'+$1.downcase}[1..-1] @header[http_key] = @env[env_key] end end end |
#unparsed_uri ⇒ Object
20 21 22 |
# File 'lib/rsence/http/request.rb', line 20 def unparsed_uri return @header['request-uri'] end |