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.
91 92 93 |
# File 'lib/sniffer/data_item.rb', line 91 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
91 92 93 |
# File 'lib/sniffer/data_item.rb', line 91 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
91 92 93 |
# File 'lib/sniffer/data_item.rb', line 91 def status @status end |
#timing ⇒ Object
Returns the value of attribute timing.
91 92 93 |
# File 'lib/sniffer/data_item.rb', line 91 def timing @timing end |
Instance Method Details
#to_h ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/sniffer/data_item.rb', line 93 def to_h { status: status, headers: headers, body: body && body.to_s, timing: timing } end |
#to_log ⇒ Object
rubocop:disable Metrics/AbcSize
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/sniffer/data_item.rb', line 103 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.to_s if log_settings["response_body"] end end |