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.
109 110 111 |
# File 'lib/sniffer/data_item.rb', line 109 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
109 110 111 |
# File 'lib/sniffer/data_item.rb', line 109 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
109 110 111 |
# File 'lib/sniffer/data_item.rb', line 109 def status @status end |
#timing ⇒ Object
Returns the value of attribute timing.
109 110 111 |
# File 'lib/sniffer/data_item.rb', line 109 def timing @timing end |
Instance Method Details
#to_h ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/sniffer/data_item.rb', line 111 def to_h { status: status, headers: headers, body: # frozen_string_literal: true # Sniffer data item stores a request info # Basic object for request and response objects # Stores http request data # rubocop:enable # Stores http response data body&.to_s, timing: timing } end |
#to_log ⇒ Object
rubocop:disable Metrics/AbcSize
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/sniffer/data_item.rb', line 128 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 |