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
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#host ⇒ Object
Returns the value of attribute host.
-
#method ⇒ Object
Returns the value of attribute method.
-
#port ⇒ Object
Returns the value of attribute port.
-
#query ⇒ Object
Returns the value of 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 ⇒ Object
Returns the value of attribute body.
54 55 56 |
# File 'lib/sniffer/data_item.rb', line 54 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
54 55 56 |
# File 'lib/sniffer/data_item.rb', line 54 def headers @headers end |
#host ⇒ Object
Returns the value of attribute host.
54 55 56 |
# File 'lib/sniffer/data_item.rb', line 54 def host @host end |
#method ⇒ Object
Returns the value of attribute method.
54 55 56 |
# File 'lib/sniffer/data_item.rb', line 54 def method @method end |
#port ⇒ Object
Returns the value of attribute port.
54 55 56 |
# File 'lib/sniffer/data_item.rb', line 54 def port @port end |
#query ⇒ Object
Returns the value of attribute query.
54 55 56 |
# File 'lib/sniffer/data_item.rb', line 54 def query @query end |
Instance Method Details
#to_h ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sniffer/data_item.rb', line 56 def to_h { host: host, query: query, port: port, headers: headers, body: body && body.to_s, method: method } end |
#to_log ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sniffer/data_item.rb', line 68 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 |