Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docs/7-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ subscription id you can pass to `off` to unsubscribe.

* `:request` an intercepted request, see `intercept` below. Requires `network.intercept` to be set up first.
Callbacks run in the order they were added and the rest are skipped once one handles the request.
* `:response` a request's response once it's fully loaded, see below. Works without `intercept`.
* `:response` a request's response once it's fully loaded, yielded as a `Network::Exchange`, see below. Works
without `intercept`.
* `:auth` a proxy/basic auth challenge, see `authorize` below. Requires `network.intercept` to be set up first.
Works like `:request`, an unhandled challenge gets Chrome's default response.
* `:dialog` a JS dialog (`alert`/`confirm`/`prompt`), see [Dialogs](./16-dialogs.md).
Expand All @@ -103,9 +104,11 @@ subscription id you can pass to `off` to unsubscribe.

Subscribes to a callback fired once a request's response has fully loaded, i.e. after
Chrome's `Network.loadingFinished` event, so `exchange.response.body` is always
available. Doesn't require `intercept` to be set up. The block receives the
`Network::Exchange` for that request; it's never yielded for requests that fail to
load (use `traffic` to inspect those instead).
available. Doesn't require `intercept` to be set up. Despite the event's name, the block
receives the `Network::Exchange` for that request, not a `Network::Response`: it pairs
`exchange.request` with `exchange.response`, so you can tell which request a response
belongs to. It's never yielded for requests that fail to load (use `traffic` to inspect
those instead).

```ruby
page.on(:response) do |exchange|
Expand Down
3 changes: 2 additions & 1 deletion lib/ferrum/interceptable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module Interceptable
#
# @yieldparam [Network::InterceptedRequest, Network::Exchange, Network::AuthRequest, Console::Message, Hash] arg
# For `:request`, the intercepted {Network::InterceptedRequest}. For
# `:response`, the finished {Network::Exchange}. For `:auth`, the
# `:response`, the finished {Network::Exchange}, not a {Network::Response}:
# read the response via `exchange.response`. For `:auth`, the
# {Network::AuthRequest} challenge. For `:console`, the new
# {Console::Message}. For any other (raw CDP) event name, the event's
# params `Hash`.
Expand Down
Loading