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

Returns a new instance of Response.


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

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.


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

def body
  @body
end

#codeObject

Returns the value of attribute code.


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

def code
  @code
end

#headersObject

Returns the value of attribute headers.


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

def headers
  @headers
end

#idObject (readonly)

Returns the value of attribute id.


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

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.


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

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

Instance Method Details

#==(other) ⇒ Object


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

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

#inspectObject


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

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