Skip to content

Commit

Permalink
Add support for browser.on(:response).
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
postmodern committed Oct 1, 2022
1 parent d6e8c22 commit 152874a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/ferrum/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ def on(name, &block)
exchange.intercepted_request = request
block.call(request, index, total)
end
when :response
@client.on('Network.responseReceived') do |params, index, total|
exchange = select(params["requestId"]).last

if exchange
block.call(exchange, index, total)
end
end
when :auth
@client.on("Fetch.authRequired") do |params, index, total|
request = Network::AuthRequest.new(self, params)
Expand Down

0 comments on commit 152874a

Please sign in to comment.