Class: Gin::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Gin::Request
show all
- Includes:
- Constants
- Defined in:
- lib/gin/request.rb
Constant Summary
Constants included
from Constants
Constants::ASYNC_CALLBACK, Constants::CACHE_CTRL, Constants::CNT_DISPOSITION, Constants::CNT_LENGTH, Constants::CNT_TYPE, Constants::ENV_DEV, Constants::ENV_PROD, Constants::ENV_STAGE, Constants::ENV_TEST, Constants::EPOCH, Constants::ETAG, Constants::EXPIRES, Constants::FWD_FOR, Constants::FWD_HOST, Constants::GIN_APP, Constants::GIN_CTRL, Constants::GIN_ERRORS, Constants::GIN_PATH_PARAMS, Constants::GIN_RELOADED, Constants::GIN_ROUTE, Constants::GIN_STACK, Constants::GIN_STATIC, Constants::GIN_TARGET, Constants::GIN_TEMPLATES, Constants::GIN_TIMESTAMP, Constants::HOST_NAME, Constants::HTTP_VERSION, Constants::IF_MATCH, Constants::IF_MOD_SINCE, Constants::IF_NONE_MATCH, Constants::IF_UNMOD_SINCE, Constants::LAST_MOD, Constants::LOCATION, Constants::PATH_INFO, Constants::PRAGMA, Constants::QUERY_STRING, Constants::RACK_INPUT, Constants::REMOTE_ADDR, Constants::REMOTE_USER, Constants::REQ_METHOD, Constants::SERVER_NAME, Constants::SERVER_PORT, Constants::SESSION_SECRET
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(env) ⇒ Request
Returns a new instance of Request.
6
7
8
9
10
11
|
# File 'lib/gin/request.rb', line 6
def initialize env
@params = nil
@params_processed = false
@autocast_params = true
super
end
|
Instance Attribute Details
#autocast_params ⇒ Object
4
5
6
|
# File 'lib/gin/request.rb', line 4
def autocast_params
@autocast_params
end
|
Instance Method Details
#forwarded? ⇒ Boolean
14
15
16
|
# File 'lib/gin/request.rb', line 14
def forwarded?
@env.include? FWD_HOST
end
|
#idempotent? ⇒ Boolean
29
30
31
|
# File 'lib/gin/request.rb', line 29
def idempotent?
safe? or put? or delete?
end
|
#ip ⇒ Object
Also known as:
remote_ip
44
45
46
47
48
49
50
|
# File 'lib/gin/request.rb', line 44
def ip
if addr = @env['HTTP_X_FORWARDED_FOR']
(addr.split(',').grep(/\d\./).first || @env['REMOTE_ADDR']).to_s.strip
else
@env['REMOTE_ADDR']
end
end
|
#params ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/gin/request.rb', line 34
def params
return @params if @params_processed
@params = super
@params.update @env[GIN_PATH_PARAMS] if @env[GIN_PATH_PARAMS]
@params = process_params(@params)
@params_processed = true
@params
end
|
#safe? ⇒ Boolean
24
25
26
|
# File 'lib/gin/request.rb', line 24
def safe?
get? or head? or options? or trace?
end
|
#ssl? ⇒ Boolean
19
20
21
|
# File 'lib/gin/request.rb', line 19
def ssl?
scheme == 'https'
end
|