Class: Sniffer::DataItem::Response
- Inherits:
-
HttpObject
- Object
- HttpObject
- Sniffer::DataItem::Response
- Defined in:
- lib/sniffer/data_item.rb
Overview
Stores http response data
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
-
#timing ⇒ Object
Returns the value of attribute timing.
Instance Method Summary collapse
- #to_h ⇒ Object
-
#to_log ⇒ Object
rubocop:disable Metrics/AbcSize.
Methods inherited from HttpObject
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
84 85 86 |
# File 'lib/sniffer/data_item.rb', line 84 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
84 85 86 |
# File 'lib/sniffer/data_item.rb', line 84 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
84 85 86 |
# File 'lib/sniffer/data_item.rb', line 84 def status @status end |
#timing ⇒ Object
Returns the value of attribute timing.
84 85 86 |
# File 'lib/sniffer/data_item.rb', line 84 def timing @timing end |
Instance Method Details
#to_h ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/sniffer/data_item.rb', line 86 def to_h { status: status, headers: headers, body: body, timing: timing } end |
#to_log ⇒ Object
rubocop:disable Metrics/AbcSize
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sniffer/data_item.rb', line 96 def to_log {}.tap do |hash| hash[:status] = status if log_settings["response_status"] if log_settings["response_headers"] headers.each do |(k, v)| hash[:"rs_#{k.to_s.tr("-", '_').downcase}"] = v end end hash[:timing] = timing if log_settings["timing"] hash[:response_body] = body if log_settings["response_body"] end end |