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.
47 48 49 |
# File 'lib/sniffer/data_item.rb', line 47 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
47 48 49 |
# File 'lib/sniffer/data_item.rb', line 47 def headers @headers end |
#host ⇒ Object
Returns the value of attribute host.
47 48 49 |
# File 'lib/sniffer/data_item.rb', line 47 def host @host end |
#method ⇒ Object
Returns the value of attribute method.
47 48 49 |
# File 'lib/sniffer/data_item.rb', line 47 def method @method end |
#port ⇒ Object
Returns the value of attribute port.
47 48 49 |
# File 'lib/sniffer/data_item.rb', line 47 def port @port end |
#query ⇒ Object
Returns the value of attribute query.
47 48 49 |
# File 'lib/sniffer/data_item.rb', line 47 def query @query end |
Instance Method Details
#to_h ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/sniffer/data_item.rb', line 49 def to_h { host: host, query: query, port: port, headers: headers, body: body, method: method } end |
#to_log ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/sniffer/data_item.rb', line 61 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 if log_settings["request_body"] end end |