Class: ScreenshotScout::RawResponse
- Inherits:
-
Object
- Object
- ScreenshotScout::RawResponse
- Defined in:
- lib/screenshotscout/responses.rb,
sig/screenshotscout.rbs
Overview
Exact buffered HTTP response data retained on successes and API failures.
Instance Attribute Summary collapse
-
#body ⇒ String
readonly
Returns the value of attribute body.
-
#content_type ⇒ String?
readonly
Returns the value of attribute content_type.
-
#headers ⇒ Hash[String, Array[String]]
readonly
Returns the value of attribute headers.
-
#reason_phrase ⇒ String
readonly
Returns the value of attribute reason_phrase.
-
#status ⇒ Integer
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #header(name) ⇒ Array[String]
-
#initialize(status:, reason_phrase:, headers:, content_type:, body:) ⇒ RawResponse
constructor
A new instance of RawResponse.
Constructor Details
#initialize(status:, reason_phrase:, headers:, content_type:, body:) ⇒ RawResponse
Returns a new instance of RawResponse.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/screenshotscout/responses.rb', line 8 def initialize(status:, reason_phrase:, headers:, content_type:, body:) @status = status @reason_phrase = reason_phrase.dup.freeze @headers = copy_headers(headers) @normalized_headers = @headers.to_h do |name, values| [name.downcase, values] end.freeze @content_type = content_type&.dup&.freeze @body = body.dup.freeze freeze end |
Instance Attribute Details
#body ⇒ String (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/screenshotscout/responses.rb', line 6 def body @body end |
#content_type ⇒ String? (readonly)
Returns the value of attribute content_type.
6 7 8 |
# File 'lib/screenshotscout/responses.rb', line 6 def content_type @content_type end |
#headers ⇒ Hash[String, Array[String]] (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/screenshotscout/responses.rb', line 6 def headers @headers end |
#reason_phrase ⇒ String (readonly)
Returns the value of attribute reason_phrase.
6 7 8 |
# File 'lib/screenshotscout/responses.rb', line 6 def reason_phrase @reason_phrase end |
#status ⇒ Integer (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/screenshotscout/responses.rb', line 6 def status @status end |
Instance Method Details
#header(name) ⇒ Array[String]
20 21 22 |
# File 'lib/screenshotscout/responses.rb', line 20 def header(name) @normalized_headers.fetch(name.downcase, EMPTY_HEADER_VALUES) end |