Class: Sniffer::DataItem::Request
- Inherits:
-
HttpObject
- Object
- HttpObject
- Sniffer::DataItem::Request
- Defined in:
- lib/sniffer/data_item.rb
Overview
Stores http request data
Instance Attribute Summary collapse
-
#body ⇒ Object
writeonly
Sets the attribute body.
-
#headers ⇒ Object
writeonly
Sets the attribute headers.
-
#host ⇒ Object
writeonly
Sets the attribute host.
-
#method ⇒ Object
writeonly
Sets the attribute method.
-
#port ⇒ Object
writeonly
Sets the attribute port.
-
#query ⇒ Object
writeonly
Sets the attribute query.
Instance Method Summary collapse
- #to_h ⇒ Object
-
#to_log ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
Methods inherited from HttpObject
Instance Attribute Details
#body=(value) ⇒ Object (writeonly)
Sets the attribute body
62 63 64 |
# File 'lib/sniffer/data_item.rb', line 62 def body=(value) @body = value end |
#headers=(value) ⇒ Object (writeonly)
Sets the attribute headers
62 63 64 |
# File 'lib/sniffer/data_item.rb', line 62 def headers=(value) @headers = value end |
#host=(value) ⇒ Object (writeonly)
Sets the attribute host
62 63 64 |
# File 'lib/sniffer/data_item.rb', line 62 def host=(value) @host = value end |
#method=(value) ⇒ Object (writeonly)
Sets the attribute method
62 63 64 |
# File 'lib/sniffer/data_item.rb', line 62 def method=(value) @method = value end |
#port=(value) ⇒ Object (writeonly)
Sets the attribute port
62 63 64 |
# File 'lib/sniffer/data_item.rb', line 62 def port=(value) @port = value end |
#query=(value) ⇒ Object (writeonly)
Sets the attribute query
62 63 64 |
# File 'lib/sniffer/data_item.rb', line 62 def query=(value) @query = value end |
Instance Method Details
#to_h ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/sniffer/data_item.rb', line 64 def to_h { host: host, query: query, port: port, headers: headers, body: body&.to_s, method: method } end |
#to_log ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/sniffer/data_item.rb', line 76 def to_log {}.tap do |hash| if log_settings["request_url"] hash[:port] = port hash[:host] = host hash[:query] = query end if log_settings["request_headers"] headers.each do |(k, v)| hash[:"rq_#{k.to_s.tr("-", '_').downcase}"] = v end end hash[:method] = method if log_settings["request_method"] hash[:request_body] = body.to_s if log_settings["request_body"] end end |