Class: ScreenshotScout::RawResponse

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#bodyString (readonly)

Returns the value of attribute body.

Returns:

  • (String)


6
7
8
# File 'lib/screenshotscout/responses.rb', line 6

def body
  @body
end

#content_typeString? (readonly)

Returns the value of attribute content_type.

Returns:

  • (String, nil)


6
7
8
# File 'lib/screenshotscout/responses.rb', line 6

def content_type
  @content_type
end

#headersHash[String, Array[String]] (readonly)

Returns the value of attribute headers.

Returns:

  • (Hash[String, Array[String]])


6
7
8
# File 'lib/screenshotscout/responses.rb', line 6

def headers
  @headers
end

#reason_phraseString (readonly)

Returns the value of attribute reason_phrase.

Returns:

  • (String)


6
7
8
# File 'lib/screenshotscout/responses.rb', line 6

def reason_phrase
  @reason_phrase
end

#statusInteger (readonly)

Returns the value of attribute status.

Returns:

  • (Integer)


6
7
8
# File 'lib/screenshotscout/responses.rb', line 6

def status
  @status
end

Instance Method Details

#header(name) ⇒ Array[String]

Parameters:

  • name (String)

Returns:

  • (Array[String])


20
21
22
# File 'lib/screenshotscout/responses.rb', line 20

def header(name)
  @normalized_headers.fetch(name.downcase, EMPTY_HEADER_VALUES)
end