Skip to content

Commit ff5bf72

Browse files
committed
Add support for browser.on(:response).
* This adds an additional callback for the `Network.responseReceived` event when a response is received. It will look up the `Ferrum::Network::Exchange` object with the matching `requestId` and passes it back to the block, once a response has been received for a request.
1 parent d141613 commit ff5bf72

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/ferrum/page.rb

+8
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,14 @@ def on(name, &block)
303303
exchange.intercepted_request = request
304304
block.call(request, index, total)
305305
end
306+
when :response
307+
@client.on('Network.responseReceived') do |params, index, total|
308+
exchange = network.select(params["requestId"]).last
309+
310+
if exchange
311+
block.call(exchange, index, total)
312+
end
313+
end
306314
when :auth
307315
@client.on("Fetch.authRequired") do |params, index, total|
308316
request = Network::AuthRequest.new(self, params)

0 commit comments

Comments
 (0)