Calculate and send the missing transferred_size and content_size to dev tools (#38216)

The current behaviour in dev tools network monitor is missing data for
the `Transferred` size and `Content` size.
We currently have a fn `response_content` that constructs the
`ResponseContentMsg` struct where the two missing data fields are
defined and set to zero values.
These current changes calculates the data in the `response_content` fn
and sends a `NetworkEvent::HttpResponse` to the client when the final
body is done.
Currently, we have data appearing in the `Transferred` column of the
network panel
fixes: https://github.com/servo/servo/issues/38126

---------

Signed-off-by: uthmaniv <uthmanyahayababa@gmail.com>
This commit is contained in:
Usman Yahaya Baba 2025-08-02 11:41:53 +09:00 committed by GitHub
parent 52b04c9fd3
commit a27715a5a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 98 additions and 33 deletions

View file

@ -47,7 +47,7 @@ use servo_arc::Arc as ServoArc;
use servo_url::ServoUrl;
use uuid::Uuid;
use crate::http_loader::{expect_devtools_http_request, expect_devtools_http_response};
use crate::http_loader::{devtools_response_with_body, expect_devtools_http_request};
use crate::{
DEFAULT_USER_AGENT, create_embedder_proxy, create_embedder_proxy_and_receiver,
create_http_state, fetch, fetch_with_context, fetch_with_cors_cache, make_body, make_server,
@ -1296,7 +1296,7 @@ fn test_fetch_with_devtools() {
// notification received from devtools
let devhttprequests = expect_devtools_http_request(&devtools_port);
let mut devhttpresponse = expect_devtools_http_response(&devtools_port);
let mut devhttpresponse = devtools_response_with_body(&devtools_port);
//Creating default headers for request
let mut headers = HeaderMap::new();
@ -1356,7 +1356,7 @@ fn test_fetch_with_devtools() {
let httpresponse = DevtoolsHttpResponse {
headers: Some(response_headers),
status: HttpStatus::default(),
body: None,
body: Some(content.as_bytes().to_vec()),
pipeline_id: TEST_PIPELINE_ID,
browsing_context_id: TEST_WEBVIEW_ID.0,
};

View file

@ -159,6 +159,19 @@ pub fn expect_devtools_http_response(
}
}
pub fn devtools_response_with_body(
devtools_port: &Receiver<DevtoolsControlMsg>,
) -> DevtoolsHttpResponse {
let devhttpresponses = vec![
expect_devtools_http_response(devtools_port),
expect_devtools_http_response(devtools_port),
];
return devhttpresponses
.into_iter()
.find(|resp| resp.body.is_some())
.expect("One of the responses should have a body");
}
#[test]
fn test_check_default_headers_loaded_in_every_request() {
let expected_headers = Arc::new(Mutex::new(None));
@ -337,7 +350,7 @@ fn test_request_and_response_data_with_network_messages() {
// notification received from devtools
let devhttprequests = expect_devtools_http_request(&devtools_port);
let devhttpresponse = expect_devtools_http_response(&devtools_port);
let devhttpresponse = devtools_response_with_body(&devtools_port);
//Creating default headers for request
let mut headers = HeaderMap::new();
@ -409,7 +422,7 @@ fn test_request_and_response_data_with_network_messages() {
let httpresponse = DevtoolsHttpResponse {
headers: Some(response_headers),
status: HttpStatus::default(),
body: None,
body: Some(content.as_bytes().to_vec()),
pipeline_id: TEST_PIPELINE_ID,
browsing_context_id: TEST_WEBVIEW_ID.0,
};