Requests to custom protocols should appear in network panel
Categories
(WebExtensions :: Experiments, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: irakli, Unassigned)
References
(Blocks 1 open bug, )
Details
At the moment requests to protocols that are registered via [experimental protocol API] (https://bugzilla.mozilla.org/show_bug.cgi?id=libdweb-protocol) do not appear in networking. They should just like other requests.
Reporter | ||
Comment 1•5 years ago
|
||
:honza I remember we chatted about this during last all hands, if I recall correctly it was supposed to be relatively easy to fix but sadly I do not remember any details. Could you please remind me what do we need to do to make requests to custom nsIProtocolHandler
appear in the network panel ?
Thanks
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Updated•5 years ago
|
Comment 2•5 years ago
|
||
Hey Irakli!
Some pointers to the code base.
-
The entire DevTools backend implementation for the Network panel is in this dir:
https://searchfox.org/mozilla-central/source/devtools/server/actors/network-monitor -
The backend is listening to standard HTTP requests, and proper listeners are registered here:
https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#228-253
We mostly use HTTP-* observer notifications
- http-on-examine-response
- http-on-examine-cached-response
- http-on-modify-request
- http-on-failed-opening-request
But, there is also notification from workers:
- service-worker-synthesized-response
If you have specific notification about a request you could add a new listener here.
-
We are also using nsIHttpActivityDistributor to track HTTP activity.
The observer for this activity is added here:
https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#229 -
When a new HTTP request is noticed, we create an "activity object" that is used to track the request and collect all data related to it.
We are storing all these activity objects in a map where key is the nsIHttpChannel
There is a helper _findActivityObject
that can be used to get an activity object for specific channel
https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#729
- So, for example, when new HTTP request is created we call
_createNetworkEvent
, which produces that activity object (if it doesn't exist yet)
https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#719-726
This method also sends RDP packet to the client, so the new request appears in the Network panel
httpActivity.owner = this.owner.onNetworkEvent(event);
httpActivity.owner.addRequestHeaders(headers, extraStringData);
httpActivity.owner.addRequestCookies(cookies);
- add request headers and sent it to the client
- add request cookies headers and sent it to the client
-
There are other various helpers in the
network-monitor
directory used to track response bodies, JS stack-trace, etc. -
The goal here should be to hook into new events and plugin into the existing architecture.
Something like as follows:
- hook to new listeners/observers
- track when a new request appears
- create new activity object
- send custom data to the client (network panel).
- New API might be introduced in
httpActivity.owner
(see comment #5) - this would also mean to introduce new RDP packets, but this is very simple. For example this patch [1] sends a new 'isRacing' flag from the backend to the client.
Honza
Updated•5 years ago
|
Updated•2 years ago
|
Description
•