Class: Capybara::Apparition::NetworkTraffic::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/apparition/network_traffic/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, response_parts = []) ⇒ Request

Returns a new instance of Request.



8
9
10
11
12
13
# File 'lib/capybara/apparition/network_traffic/request.rb', line 8

def initialize(data, response_parts = [])
  @data           = data
  @response_parts = response_parts
  @response = nil
  @blocked_params = nil
end

Instance Attribute Details

#blocked_params=(value) ⇒ Object (writeonly)

Sets the attribute blocked_params

Parameters:

  • value

    the value to set the attribute blocked_params to.



6
7
8
# File 'lib/capybara/apparition/network_traffic/request.rb', line 6

def blocked_params=(value)
  @blocked_params = value
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/capybara/apparition/network_traffic/request.rb', line 5

def response
  @response
end

#response_partsObject (readonly)

Returns the value of attribute response_parts.



5
6
7
# File 'lib/capybara/apparition/network_traffic/request.rb', line 5

def response_parts
  @response_parts
end

Instance Method Details

#blocked?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/capybara/apparition/network_traffic/request.rb', line 39

def blocked?
  !@blocked_params.nil?
end

#errorObject



43
44
45
# File 'lib/capybara/apparition/network_traffic/request.rb', line 43

def error
  response_parts.last&.error
end

#headersObject



31
32
33
# File 'lib/capybara/apparition/network_traffic/request.rb', line 31

def headers
  @data[:request]&.dig('headers')
end

#methodObject



27
28
29
# File 'lib/capybara/apparition/network_traffic/request.rb', line 27

def method
  @data[:request]&.dig('method')
end

#request_idObject



19
20
21
# File 'lib/capybara/apparition/network_traffic/request.rb', line 19

def request_id
  @data[:request_id]
end

#timeObject



35
36
37
# File 'lib/capybara/apparition/network_traffic/request.rb', line 35

def time
  @data[:timestamp] && Time.parse(@data[:timestamp])
end

#urlObject



23
24
25
# File 'lib/capybara/apparition/network_traffic/request.rb', line 23

def url
  @data[:request]&.dig('url')
end