Class: Datadog::AppSec::Contrib::Rack::Gateway::Request
Overview
Gateway Request argument. Normalized extration of data from Rack::Request
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(env) ⇒ Request
Returns a new instance of Request.
16
17
18
19
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 16
def initialize(env)
super()
@env = env
end
|
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
14
15
16
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 14
def env
@env
end
|
Instance Method Details
#cookies ⇒ Object
65
66
67
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 65
def cookies
request.cookies
end
|
81
82
83
84
85
86
87
88
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 81
def form_hash
request.POST if request.form_data?
env['rack.request.form_hash']
end
|
#fullpath ⇒ Object
57
58
59
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 57
def fullpath
request.fullpath
end
|
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 42
def
result = request.env.each_with_object({}) do |(k, v), h|
h[k.delete_prefix('HTTP_').tap(&:downcase!).tap { |s| s.tr!('_', '-') }] = v if k.start_with?('HTTP_')
end
result['content-type'] = request.content_type if request.content_type
result['content-length'] = request.content_length || '0'
result
end
|
#host ⇒ Object
69
70
71
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 69
def host
request.host
end
|
#method ⇒ Object
38
39
40
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 38
def method
request.request_method
end
|
#path ⇒ Object
61
62
63
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 61
def path
request.path
end
|
#query ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 25
def query
request.query_string.split('&').each.with_object({}) do |e, hash|
k, v = e.split('=').map { |s| CGI.unescape(s) }
hash[k] ||= []
hash[k] << v
end
end
|
#remote_addr ⇒ Object
77
78
79
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 77
def remote_addr
env['REMOTE_ADDR']
end
|
#request ⇒ Object
21
22
23
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 21
def request
@request ||= ::Rack::Request.new(env)
end
|
#url ⇒ Object
53
54
55
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 53
def url
request.url
end
|
#user_agent ⇒ Object
73
74
75
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 73
def user_agent
request.user_agent
end
|