Remove duplication between request/response properties in NetworkEventActor (#37651)

- Remove request/response fields in `NetworkEventActor` which now stores
minimal request metadata needed : `URL`, `method`, `timestamps`, `raw
headers`, `body`.
- Refactor add_request and add_response: `add_request` takes the
incoming DevtoolsHttpRequest and populates
`request_url`, `request_method`, `request_started`,
`request_time_stamp`, `request_body`, `request_headers_raw`
`request_cookies`, `request_headers`,`total_time` and `event_timing`
(via a new helper that computes Timings)
While `add_response` takes the incoming DevtoolsHttpResponse and
populates `response_headers_raw`, `response_body` ,`response_cookies`,
`response_headers`, `response_start`, `response_content`
- Add a call to `resources_updated` to push initial request info in
`handle_network_event`
Testing: Run and logged servo in devtools mode and now, the request
header info isavailable as soon as the request gets initiated
Fixes: https://github.com/servo/servo/issues/37566

---------

Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
This commit is contained in:
Usman Yahaya Baba 2025-06-25 21:18:44 +01:00 committed by GitHub
parent 459397e1a1
commit 152eb63fb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 125 additions and 136 deletions

View file

@ -31,22 +31,30 @@ pub(crate) fn handle_network_event(
let mut actors = actors.lock().unwrap();
match network_event {
NetworkEvent::HttpRequest(httprequest) => {
// Scope mutable borrow
let event_actor = {
let (event_actor, resource_updates) = {
let actor = actors.find_mut::<NetworkEventActor>(&netevent_actor_name);
actor.add_request(httprequest);
actor.event_actor()
(actor.event_actor(), actor.resource_updates())
};
let browsing_context_actor =
actors.find::<BrowsingContextActor>(&browsing_context_actor_name);
for stream in &mut connections {
// Notify that a new network event has started
browsing_context_actor.resource_array(
event_actor.clone(),
"network-event".to_string(),
ResourceArrayType::Available,
stream,
);
// Also push initial resource update (request headers, cookies)
browsing_context_actor.resource_array(
resource_updates.clone(),
"network-event".to_string(),
ResourceArrayType::Updated,
stream,
);
}
},
NetworkEvent::HttpResponse(httpresponse) => {