Class: HttpEventLogger::Event::Response
- Inherits:
-
Object
- Object
- HttpEventLogger::Event::Response
- Defined in:
- lib/http_event_logger/event/response.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#time_taken_in_seconds ⇒ Object
readonly
Returns the value of attribute time_taken_in_seconds.
Instance Method Summary collapse
- #body ⇒ Object
- #body_with_formatting ⇒ Object
-
#initialize(args) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(args) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 16 17 |
# File 'lib/http_event_logger/event/response.rb', line 10 def initialize(args) @request = args[:request] @time_taken_in_seconds = args[:time_taken_in_seconds] @status = args[:status].to_s @headers = HttpEventLogger::Event::Headers.new(args[:headers]) @raw_body = args[:body] HttpEventLogger::Event::Observer.observe(:received, self) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/http_event_logger/event/response.rb', line 6 def headers @headers end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/http_event_logger/event/response.rb', line 6 def request @request end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/http_event_logger/event/response.rb', line 6 def status @status end |
#time_taken_in_seconds ⇒ Object (readonly)
Returns the value of attribute time_taken_in_seconds.
6 7 8 |
# File 'lib/http_event_logger/event/response.rb', line 6 def time_taken_in_seconds @time_taken_in_seconds end |
Instance Method Details
#body ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/http_event_logger/event/response.rb', line 19 def body if body_read_deferred? "[not available]" elsif body_gzip_encoded? Zlib::GzipReader.new(StringIO.new(@raw_body.to_s)).read else @raw_body.to_s end end |
#body_with_formatting ⇒ Object
29 30 31 |
# File 'lib/http_event_logger/event/response.rb', line 29 def body_with_formatting body.include?("\n") ? "\n#{body}" : body end |