Class: Selenium::WebDriver::DevTools::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/devtools/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, code:, body:, headers:) ⇒ Response



43
44
45
46
47
48
# File 'lib/selenium/webdriver/devtools/response.rb', line 43

def initialize(id:, code:, body:, headers:)
  @id = id
  @code = code
  @body = body
  @headers = headers
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



24
25
26
# File 'lib/selenium/webdriver/devtools/response.rb', line 24

def body
  @body
end

#codeObject

Returns the value of attribute code.



24
25
26
# File 'lib/selenium/webdriver/devtools/response.rb', line 24

def code
  @code
end

#headersObject

Returns the value of attribute headers.



24
25
26
# File 'lib/selenium/webdriver/devtools/response.rb', line 24

def headers
  @headers
end

#idObject (readonly)

Returns the value of attribute id.



25
26
27
# File 'lib/selenium/webdriver/devtools/response.rb', line 25

def id
  @id
end

Class Method Details

.from(id, encoded_body, params) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates response from DevTools message.



32
33
34
35
36
37
38
39
40
41
# File 'lib/selenium/webdriver/devtools/response.rb', line 32

def self.from(id, encoded_body, params)
  new(
    id: id,
    code: params['responseStatusCode'],
    body: (Base64.strict_decode64(encoded_body) if encoded_body),
    headers: params.fetch('responseHeaders', []).each_with_object({}) do |header, hash|
      hash[header['name']] = header['value']
    end
  )
end

Instance Method Details

#==(other) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/selenium/webdriver/devtools/response.rb', line 50

def ==(other)
  self.class == other.class &&
    id == other.id &&
    code == other.code &&
    body == other.body &&
    headers == other.headers
end

#inspectObject



58
59
60
# File 'lib/selenium/webdriver/devtools/response.rb', line 58

def inspect
  %(#<#{self.class.name} @id="#{id}" @code="#{code}")
end