Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
refactor(fetch): preserve response header bytes end to end
ldm06d08975a6953
diff --git a/Cargo.lock b/Cargo.lockindex 7ce6816ab..ae13e145f 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2514,6 +2514,7 @@ name = "moli-cookie-jar"version = "0.1.0"dependencies = ["moli-cookie-store",+ "moli-header-field","moli-site","moli-storage-key","parking_lot",@@ -2644,6 +2645,7 @@ dependencies = ["encoding_rs","moli-charset-parser","moli-content-type",+ "moli-header-field",][[package]]@@ -2712,6 +2714,8 @@ name = "moli-header-field"version = "0.1.0"dependencies = ["anyhow",+ "serde",+ "serde_json",][[package]]@@ -3225,6 +3229,7 @@ dependencies = ["base64 0.22.1","moli-browser-profile","moli-crypto",+ "moli-header-field","moli-indexeddb","moli-opfs","moli-storage-key",@@ -3374,6 +3379,7 @@ dependencies = ["http","mime","moli-content-type",+ "moli-header-field",][[package]]diff --git a/moli-cookie-jar/Cargo.toml b/moli-cookie-jar/Cargo.tomlindex a032d756b..8017bccc1 100644--- a/moli-cookie-jar/Cargo.toml+++ b/moli-cookie-jar/Cargo.toml@@ -9,6 +9,7 @@ default = []test-support = [][dependencies]+moli-header-field = { path = "../moli-header-field" }cookie_store = { package = "moli-cookie-store", path = "../moli-cookie-store", default-features = false, features = ["public_suffix"] }moli-site = { path = "../moli-site" }moli-storage-key = { path = "../moli-storage-key" }diff --git a/moli-cookie-jar/src/jar.rs b/moli-cookie-jar/src/jar.rsindex 885e2a27e..7c48bd952 100644--- a/moli-cookie-jar/src/jar.rs+++ b/moli-cookie-jar/src/jar.rs@@ -186,7 +186,7 @@ impl BrowserCookieStore {}#[cfg(any(test, feature = "test-support"))]- pub fn store_response_headers(&mut self, response_url: &Url, headers: &[(String, String)]) {+ pub fn store_response_headers(&mut self, response_url: &Url, headers: &[(String, Vec<u8>)]) {let reports = self.store_response_headers_with_reports(response_url, headers);for ((_, value), report) in headers.iter()@@ -194,7 +194,7 @@ impl BrowserCookieStore {.zip(reports.iter()){if !report.is_accepted() || !report.warning_reasons.is_empty() {- tracing::debug!(?report, header = %value, "processed set-cookie header");+ tracing::debug!(?report, header = %moli_header_field::decode_header_value(value), "processed set-cookie header");}}}@@ -203,7 +203,7 @@ impl BrowserCookieStore {pub fn store_response_headers_with_reports(&mut self,response_url: &Url,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Vec<StoredCookieSetReport> {self.store_response_headers_with_context_reports(response_url,@@ -217,7 +217,7 @@ impl BrowserCookieStore {pub fn store_response_headers_with_context_reports(&mut self,response_url: &Url,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],request_context: &NetworkCookieRequestContext,) -> Vec<StoredCookieSetReport> {let mut reports = Vec::new();@@ -226,7 +226,8 @@ impl BrowserCookieStore {.iter().filter(|(name, _)| name.eq_ignore_ascii_case("set-cookie")){- let normalized = normalize_expires_utc_timezone(value);+ let value = moli_header_field::decode_header_value(value);+ let normalized = normalize_expires_utc_timezone(&value);reports.push(stored_set_report_from_core(self.full_core.set_response_cookie_str_with_access_result(normalized.as_ref(),diff --git a/moli-cookie-jar/src/tests.rs b/moli-cookie-jar/src/tests.rsindex c07935cb5..38d5df9c0 100644--- a/moli-cookie-jar/src/tests.rs+++ b/moli-cookie-jar/src/tests.rs@@ -96,10 +96,10 @@ fn document_cookie_reads_network_cookie_but_hides_httponly() {store.store_response_headers(&url,&[- ("set-cookie".to_owned(), "theme=dark; Path=/app".to_owned()),+ ("set-cookie".to_owned(), b"theme=dark; Path=/app".to_vec()),("set-cookie".to_owned(),- "secret=server; Path=/app; HttpOnly".to_owned(),+ b"secret=server; Path=/app; HttpOnly".to_vec(),),],);@@ -120,7 +120,7 @@ fn document_cookie_cannot_overwrite_existing_httponly_cookie() {&url,&[("set-cookie".to_owned(),- "sid=server; Path=/app; HttpOnly".to_owned(),+ b"sid=server; Path=/app; HttpOnly".to_vec(),)],);store.set_document_cookie(&url, "sid=client; Path=/app");@@ -141,7 +141,7 @@ fn document_cookie_httponly_guard_reads_canonical_core() {&url,&[("set-cookie".to_owned(),- "sid=server; Path=/app; HttpOnly".to_owned(),+ b"sid=server; Path=/app; HttpOnly".to_vec(),)],);@@ -183,7 +183,7 @@ fn unknown_scheme_uncanonicalizable_host_is_rejected_like_chromium_cookie_util()let report = store.store_response_headers_with_reports(&request_url,- &[("set-cookie".to_owned(), "sid=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/".to_vec())],);assert_eq!(report.len(), 1);@@ -198,7 +198,7 @@ fn file_url_without_host_accepts_host_cookie_like_chromium_cookie_util() {let report = store.store_response_headers_with_reports(&request_url,- &[("set-cookie".to_owned(), "sid=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/".to_vec())],);assert_eq!(report.len(), 1);@@ -214,7 +214,7 @@ fn blob_file_underlying_url_accepts_response_cookie_like_chromium_site_for_cookilet report = store.store_response_headers_with_reports(&nested_url,- &[("set-cookie".to_owned(), "sid=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/".to_vec())],);assert_eq!(report.len(), 1);@@ -229,7 +229,7 @@ fn store_response_headers_accepts_mixed_case_set_cookie_name() {let reports = store.store_response_headers_with_reports(&url,- &[("Set-Cookie".to_owned(), "sid=1; Path=/app".to_owned())],+ &[("Set-Cookie".to_owned(), b"sid=1; Path=/app".to_vec())],);assert_eq!(reports.len(), 1);@@ -311,10 +311,10 @@ fn document_cookie_access_report_projects_httponly_exclusion() {store.store_response_headers(&url,&[- ("set-cookie".to_owned(), "theme=dark; Path=/app".to_owned()),+ ("set-cookie".to_owned(), b"theme=dark; Path=/app".to_vec()),("set-cookie".to_owned(),- "secret=server; Path=/app; HttpOnly".to_owned(),+ b"secret=server; Path=/app; HttpOnly".to_vec(),),],);@@ -357,7 +357,7 @@ fn document_cookie_access_report_projects_schemeful_downgrade_like_chromium_scri&document_url,&[("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),)],);@@ -388,7 +388,7 @@ fn document_cookie_access_report_treats_wss_and_https_as_schemefully_same_site_l&parse("https://api.example.com/socket"),&[("set-cookie".to_owned(),- "lax=1; Path=/; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; Secure; SameSite=Lax".to_vec(),)],);@@ -419,7 +419,7 @@ fn document_cookie_access_report_projects_cross_site_when_site_for_cookies_is_cr&document_url,&[("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),)],);@@ -449,7 +449,7 @@ fn document_cookie_access_report_treats_ws_and_http_as_schemefully_same_site_lik&parse("http://api.example.com/socket"),&[("set-cookie".to_owned(),- "lax=1; Path=/; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; SameSite=Lax".to_vec(),)],);@@ -478,7 +478,7 @@ fn document_cookie_access_report_treats_local_file_urls_as_same_site_like_chromistore.store_response_headers(&document_url,- &[("set-cookie".to_owned(), "lax=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"lax=1; Path=/".to_vec())],);let report = store.document_cookie_access_report_with_context(&document_url, &browser_context);@@ -506,7 +506,7 @@ fn document_cookie_access_report_treats_nonlocal_file_urls_as_cross_site_like_chstore.store_response_headers(&document_url,- &[("set-cookie".to_owned(), "lax=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"lax=1; Path=/".to_vec())],);let report = store.document_cookie_access_report_with_context(&document_url, &browser_context);@@ -535,7 +535,7 @@ fn document_cookie_access_report_treats_secure_blob_urls_as_same_site_like_chrom&parse("https://example.org/resource"),&[("set-cookie".to_owned(),- "lax=1; Path=/; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; Secure; SameSite=Lax".to_vec(),)],);@@ -566,7 +566,7 @@ fn document_cookie_access_report_treats_insecure_blob_urls_as_schemeful_cross_si&parse("http://example.org/resource"),&[("set-cookie".to_owned(),- "lax=1; Path=/; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; SameSite=Lax".to_vec(),)],);@@ -597,7 +597,7 @@ fn document_cookie_access_report_treats_secure_blob_urls_with_insecure_site_for_&parse("https://example.org/resource"),&[("set-cookie".to_owned(),- "lax=1; Path=/; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; Secure; SameSite=Lax".to_vec(),)],);@@ -622,7 +622,7 @@ fn document_cookie_reads_for_blob_file_urls_like_chromium_site_for_cookies() {store.store_response_headers(&parse("file:///C:/app/index.html"),- &[("set-cookie".to_owned(), "lax=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"lax=1; Path=/".to_vec())],);assert_eq!(store.document_cookie(&document_url), "lax=1");@@ -637,7 +637,7 @@ fn document_cookie_reads_for_secure_blob_urls_like_underlying_origin() {&parse("https://example.org/resource"),&[("set-cookie".to_owned(),- "lax=1; Path=/; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; Secure; SameSite=Lax".to_vec(),)],);@@ -653,7 +653,7 @@ fn document_cookie_reads_for_insecure_blob_urls_like_underlying_origin() {&parse("http://example.org/resource"),&[("set-cookie".to_owned(),- "lax=1; Path=/; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; SameSite=Lax".to_vec(),)],);@@ -671,7 +671,7 @@ fn document_cookie_access_report_treats_blob_file_urls_as_same_site_like_chromiustore.store_response_headers(&parse("file:///C:/app/index.html"),- &[("set-cookie".to_owned(), "lax=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"lax=1; Path=/".to_vec())],);let report = store.document_cookie_access_report_with_context(&document_url, &browser_context);@@ -699,7 +699,7 @@ fn document_cookie_access_report_treats_blob_file_urls_with_nonlocal_site_for_costore.store_response_headers(&parse("file:///C:/app/index.html"),- &[("set-cookie".to_owned(), "lax=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"lax=1; Path=/".to_vec())],);let report = store.document_cookie_access_report_with_context(&document_url, &browser_context);@@ -722,7 +722,7 @@ fn observation_request_access_report_does_not_touch_access_time() {store.store_response_headers(&url,- &[("set-cookie".to_owned(), "theme=dark; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"theme=dark; Path=/app".to_vec())],);let before = store@@ -755,7 +755,7 @@ fn network_cookie_header_reflects_http_writes() {&response_url,&[("set-cookie".to_owned(),- "theme=dark; Path=/app; Secure".to_owned(),+ b"theme=dark; Path=/app; Secure".to_vec(),)],);@@ -772,7 +772,7 @@ fn rejected_http_cookie_is_not_stored() {store.store_response_headers(&url,- &[("set-cookie".to_owned(), "__Secure-sid=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"__Secure-sid=1; Path=/".to_vec())],);assert_eq!(store.cookie_header(&url), None);@@ -850,7 +850,7 @@ fn network_cookie_header_reflects_http_removals() {&url,&[("set-cookie".to_owned(),- "sid=server; Path=/app; Secure".to_owned(),+ b"sid=server; Path=/app; Secure".to_vec(),)],);assert_eq!(@@ -862,7 +862,7 @@ fn network_cookie_header_reflects_http_removals() {&url,&[("set-cookie".to_owned(),- "sid=gone; Path=/app; Secure; Max-Age=0".to_owned(),+ b"sid=gone; Path=/app; Secure; Max-Age=0".to_vec(),)],);@@ -931,7 +931,7 @@ fn clear_removes_all_network_visible_cookies() {&url,&[("set-cookie".to_owned(),- "sid=server; Path=/app; Secure".to_owned(),+ b"sid=server; Path=/app; Secure".to_vec(),)],);store.set_document_cookie(&url, "theme=dark; Path=/app");@@ -948,19 +948,19 @@ fn sites_with_cookies_uses_registrable_site_keys() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "a=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"a=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://cdn.example.com/assets/index.html"),- &[("set-cookie".to_owned(), "b=1; Path=/assets".to_owned())],+ &[("set-cookie".to_owned(), b"b=1; Path=/assets".to_vec())],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),- &[("set-cookie".to_owned(), "c=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"c=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://127.0.0.1/app/index.html"),- &[("set-cookie".to_owned(), "d=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"d=1; Path=/app".to_vec())],);assert_eq!(@@ -979,22 +979,22 @@ fn cookie_site_data_counts_cookies_per_registrable_site() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "a=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"a=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://cdn.example.com/assets/index.html"),- &[("set-cookie".to_owned(), "b=1; Path=/assets".to_owned())],+ &[("set-cookie".to_owned(), b"b=1; Path=/assets".to_vec())],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),&[- ("set-cookie".to_owned(), "c=1; Path=/app".to_owned()),- ("set-cookie".to_owned(), "d=1; Path=/app".to_owned()),+ ("set-cookie".to_owned(), b"c=1; Path=/app".to_vec()),+ ("set-cookie".to_owned(), b"d=1; Path=/app".to_vec()),],);store.store_response_headers(&parse("https://127.0.0.1/app/index.html"),- &[("set-cookie".to_owned(), "e=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"e=1; Path=/app".to_vec())],);let site_data = store.cookie_site_data();@@ -1015,13 +1015,13 @@ fn cookie_site_data_persistent_scope_excludes_session_cookies() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://app.example.com/app/index.html"),&[("set-cookie".to_owned(),- "persistent=1; Path=/app; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1041,15 +1041,15 @@ fn clear_cookies_for_sites_removes_all_matching_registrable_sites() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "a=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"a=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://cdn.example.com/assets/index.html"),- &[("set-cookie".to_owned(), "b=1; Path=/assets".to_owned())],+ &[("set-cookie".to_owned(), b"b=1; Path=/assets".to_vec())],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),- &[("set-cookie".to_owned(), "c=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"c=1; Path=/app".to_vec())],);let removed = store.clear_cookies_for_sites(&["sub.example.com"]);@@ -1072,20 +1072,20 @@ fn clear_cookies_for_sites_report_projects_replaced_and_remaining_state() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://cdn.example.com/assets/index.html"),&[("set-cookie".to_owned(),- "persistent=1; Path=/assets; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/assets; Max-Age=3600".to_vec(),)],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1118,20 +1118,20 @@ fn preview_clear_cookies_for_sites_reports_targeted_removal_without_mutation() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://cdn.example.com/assets/index.html"),&[("set-cookie".to_owned(),- "persistent=1; Path=/assets; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/assets; Max-Age=3600".to_vec(),)],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1176,20 +1176,20 @@ fn preview_clear_cookies_for_sites_with_persistent_scope_keeps_session_slice() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://app.example.com/app/index.html"),&[("set-cookie".to_owned(),- "persist=1; Path=/app; Max-Age=3600".to_owned(),+ b"persist=1; Path=/app; Max-Age=3600".to_vec(),)],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1223,13 +1223,13 @@ fn clear_cookies_for_sites_with_session_scope_preserves_persistent_cookie() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://app.example.com/app/index.html"),&[("set-cookie".to_owned(),- "persist=1; Path=/app; Max-Age=3600".to_owned(),+ b"persist=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1261,20 +1261,20 @@ fn preview_clear_cookie_store_with_persistent_scope_keeps_session_sites() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://app.example.com/app/index.html"),&[("set-cookie".to_owned(),- "persist=1; Path=/app; Max-Age=3600".to_owned(),+ b"persist=1; Path=/app; Max-Age=3600".to_vec(),)],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1302,18 +1302,18 @@ fn clear_cookie_store_with_session_scope_preserves_persistent_store_state() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://app.example.com/app/index.html"),&[("set-cookie".to_owned(),- "persist=1; Path=/app; Max-Age=3600".to_owned(),+ b"persist=1; Path=/app; Max-Age=3600".to_vec(),)],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),- &[("set-cookie".to_owned(), "other=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"other=1; Path=/app".to_vec())],);let report = store.clear_with_scope_and_report(super::CookieSiteDataClearScope::Session);@@ -1337,13 +1337,13 @@ fn preview_clear_with_registrable_site_target_projects_targeted_clear_shape() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1374,18 +1374,18 @@ fn clear_with_registrable_site_target_projects_targeted_clear_report() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://cdn.example.com/assets/index.html"),&[("set-cookie".to_owned(),- "persist=1; Path=/assets; Max-Age=3600".to_owned(),+ b"persist=1; Path=/assets; Max-Age=3600".to_vec(),)],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),- &[("set-cookie".to_owned(), "other=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"other=1; Path=/app".to_vec())],);let report = store.clear_with_scope_and_target_report(@@ -1418,13 +1418,13 @@ fn preview_site_data_operation_clear_uses_generic_targeted_clear_seam() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1455,13 +1455,13 @@ fn cookie_storage_state_snapshot_distinguishes_live_and_persistent_views() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),&[("set-cookie".to_owned(),- "persistent=1; Path=/app; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1492,20 +1492,20 @@ fn cookie_storage_state_snapshot_for_sites_filters_live_and_persistent_views() {store.store_response_headers(&parse("https://app.example.com/app/index.html"),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&parse("https://cdn.example.com/assets/index.html"),&[("set-cookie".to_owned(),- "persistent=1; Path=/assets; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/assets; Max-Age=3600".to_vec(),)],);store.store_response_headers(&parse("https://foo.co.uk/app/index.html"),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);@@ -1532,7 +1532,7 @@ fn cookies_enumeration_reads_priority_and_source_metadata_from_full_core() {&url,&[("set-cookie".to_owned(),- "sid=server; Path=/app; Secure; HttpOnly; Priority=High".to_owned(),+ b"sid=server; Path=/app; Secure; HttpOnly; Priority=High".to_vec(),)],);@@ -1557,7 +1557,7 @@ fn cookies_enumeration_drops_metadata_entries_missing_from_full_core() {&url,&[("set-cookie".to_owned(),- "sid=server; Path=/app; Secure".to_owned(),+ b"sid=server; Path=/app; Secure".to_vec(),)],);assert_eq!(store.cookies().len(), 1);@@ -1642,14 +1642,14 @@ fn delete_cookies_updates_network_visible_cookie_header() {&response_url,&[("set-cookie".to_owned(),- "shared=1; Domain=example.com; Path=/app; Secure".to_owned(),+ b"shared=1; Domain=example.com; Path=/app; Secure".to_vec(),)],);store.store_response_headers(&response_url,&[("set-cookie".to_owned(),- "host=1; Path=/app; Secure".to_owned(),+ b"host=1; Path=/app; Secure".to_vec(),)],);assert_eq!(@@ -1672,14 +1672,14 @@ fn delete_cookies_url_host_filter_uses_full_core_host_only_state() {&response_url,&[("set-cookie".to_owned(),- "host=1; Path=/app; Secure".to_owned(),+ b"host=1; Path=/app; Secure".to_vec(),)],);store.store_response_headers(&response_url,&[("set-cookie".to_owned(),- "shared=1; Domain=example.com; Path=/app; Secure".to_owned(),+ b"shared=1; Domain=example.com; Path=/app; Secure".to_vec(),)],);@@ -1701,7 +1701,7 @@ fn dot_prefixed_ip_domain_cookie_is_accepted_as_host_cookie_like_chromium() {&url,&[("set-cookie".to_owned(),- "sid=1; Domain=.192.0.2.3; Path=/".to_owned(),+ b"sid=1; Domain=.192.0.2.3; Path=/".to_vec(),)],);@@ -1721,7 +1721,7 @@ fn trailing_dot_cookie_domain_is_rejected_like_chromium_cookie_util() {&url,&[("set-cookie".to_owned(),- "sid=1; Domain=.foo.com..; Path=/".to_owned(),+ b"sid=1; Domain=.foo.com..; Path=/".to_vec(),)],);@@ -1738,7 +1738,7 @@ fn percent_encoded_cookie_domain_is_rejected_like_chromium_cookie_util() {&url,&[("set-cookie".to_owned(),- "sid=1; Domain=a%2Etest; Path=/".to_owned(),+ b"sid=1; Domain=a%2Etest; Path=/".to_vec(),)],);@@ -1755,7 +1755,7 @@ fn uncanonicalizable_cookie_domain_is_rejected_like_chromium_cookie_util() {&url,&[("set-cookie".to_owned(),- "sid=1; Domain=a^test; Path=/".to_owned(),+ b"sid=1; Domain=a^test; Path=/".to_vec(),)],);@@ -1772,7 +1772,7 @@ fn dot_prefixed_public_suffix_identical_host_becomes_host_only_like_chromium() {&url,&[("set-cookie".to_owned(),- "hostonly=1; Domain=.github.io; Path=/; Secure".to_owned(),+ b"hostonly=1; Domain=.github.io; Path=/; Secure".to_vec(),)],);@@ -1793,7 +1793,7 @@ fn dot_prefixed_public_suffix_identical_host_becomes_host_only_for_gov_uk_like_c&url,&[("set-cookie".to_owned(),- "hostonly=1; Domain=.gov.uk; Path=/; Secure".to_owned(),+ b"hostonly=1; Domain=.gov.uk; Path=/; Secure".to_vec(),)],);@@ -1814,7 +1814,7 @@ fn noncanonical_public_suffix_identical_host_becomes_host_only_for_gov_uk_like_c&url,&[("set-cookie".to_owned(),- "hostonly=1; Domain=GoV.Uk; Path=/; Secure".to_owned(),+ b"hostonly=1; Domain=GoV.Uk; Path=/; Secure".to_vec(),)],);@@ -1835,7 +1835,7 @@ fn parent_domain_attribute_is_accepted_for_subdomain_request_host_like_chromium(&url,&[("set-cookie".to_owned(),- "sid=1; Domain=globex.com; Path=/".to_owned(),+ b"sid=1; Domain=globex.com; Path=/".to_vec(),)],);@@ -1853,7 +1853,7 @@ fn subdomain_attribute_is_rejected_for_parent_request_host_like_chromium() {&parse("http://globex.com/"),&[("set-cookie".to_owned(),- "sid=1; Domain=mail.globex.com; Path=/".to_owned(),+ b"sid=1; Domain=mail.globex.com; Path=/".to_vec(),)],);@@ -1869,7 +1869,7 @@ fn substring_but_not_subdomain_domain_attribute_is_rejected_like_chromium() {&parse("http://myglobex.com/"),&[("set-cookie".to_owned(),- "sid=1; Domain=globex.com; Path=/".to_owned(),+ b"sid=1; Domain=globex.com; Path=/".to_vec(),)],);@@ -1886,14 +1886,14 @@ fn trailing_dot_domain_attribute_mismatch_is_rejected_like_chromium_cookie_util(&url,&[("set-cookie".to_owned(),- "sid=1; Domain=.foo.com..; Path=/".to_owned(),+ b"sid=1; Domain=.foo.com..; Path=/".to_vec(),)],);store.store_response_headers(&url,&[("set-cookie".to_owned(),- "sid=1; Domain=.foo.com.; Path=/".to_owned(),+ b"sid=1; Domain=.foo.com.; Path=/".to_vec(),)],);@@ -1909,14 +1909,14 @@ fn invalid_ip_subdomain_domain_attribute_is_rejected_like_chromium_cookie_util()&parse("http://192.0.2.3/"),&[("set-cookie".to_owned(),- "sid=1; Domain=192; Path=/".to_owned(),+ b"sid=1; Domain=192; Path=/".to_vec(),)],);store.store_response_headers(&parse("http://0.0.16.0/0000000"),&[("set-cookie".to_owned(),- "sid=1; Domain=00000000; Path=/".to_owned(),+ b"sid=1; Domain=00000000; Path=/".to_vec(),)],);@@ -1932,7 +1932,7 @@ fn unknown_registry_identical_domain_attribute_is_accepted_like_chromium_cookie_&url,&[("set-cookie".to_owned(),- "sid=1; Domain=qjz9; Path=/".to_owned(),+ b"sid=1; Domain=qjz9; Path=/".to_vec(),)],);@@ -1951,7 +1951,7 @@ fn secure_cookie_from_insecure_origin_is_ignored() {&parse("http://example.com/login"),&[("set-cookie".to_owned(),- "sid=secure; Path=/; Secure".to_owned(),+ b"sid=secure; Path=/; Secure".to_vec(),)],);@@ -1964,7 +1964,7 @@ fn secure_prefix_requires_secure_attribute() {store.store_response_headers(&parse("https://example.com/"),- &[("set-cookie".to_owned(), "__Secure-sid=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"__Secure-sid=1; Path=/".to_vec())],);assert_eq!(store.cookie_header(&parse("https://example.com/")), None);@@ -1977,20 +1977,20 @@ fn host_prefix_requires_host_only_secure_and_explicit_root_path() {store.store_response_headers(&url,- &[("set-cookie".to_owned(), "__Host-a=1; Secure".to_owned())],+ &[("set-cookie".to_owned(), b"__Host-a=1; Secure".to_vec())],);store.store_response_headers(&url,&[("set-cookie".to_owned(),- "__Host-b=1; Secure; Path=/".to_owned(),+ b"__Host-b=1; Secure; Path=/".to_vec(),)],);store.store_response_headers(&url,&[("set-cookie".to_owned(),- "__Host-c=1; Secure; Path=/; Domain=example.com".to_owned(),+ b"__Host-c=1; Secure; Path=/; Domain=example.com".to_vec(),)],);@@ -2008,14 +2008,14 @@ fn http_prefix_requires_secure_and_http_only() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- "__Http-token=1; Path=/; Secure".to_owned(),+ b"__Http-token=1; Path=/; Secure".to_vec(),)],);store.store_response_headers(&parse("https://example.com/"),&[("set-cookie".to_owned(),- "__Http-token=2; Path=/; Secure; HttpOnly".to_owned(),+ b"__Http-token=2; Path=/; Secure; HttpOnly".to_vec(),)],);@@ -2034,21 +2034,21 @@ fn host_http_prefix_requires_host_only_secure_http_only_and_explicit_root_path()&parse("https://example.com/"),&[("set-cookie".to_owned(),- "__Host-Http-token=1; Path=/; Secure".to_owned(),+ b"__Host-Http-token=1; Path=/; Secure".to_vec(),)],);store.store_response_headers(&parse("https://example.com/"),&[("set-cookie".to_owned(),- "__Host-Http-token=2; Path=/; Secure; HttpOnly; Domain=example.com".to_owned(),+ b"__Host-Http-token=2; Path=/; Secure; HttpOnly; Domain=example.com".to_vec(),)],);store.store_response_headers(&parse("https://example.com/"),&[("set-cookie".to_owned(),- "__Host-Http-token=3; Path=/; Secure; HttpOnly".to_owned(),+ b"__Host-Http-token=3; Path=/; Secure; HttpOnly".to_vec(),)],);@@ -2066,7 +2066,7 @@ fn empty_name_cookie_cannot_smuggle_protected_prefixes_in_value() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- "=__Secure-token; Path=/; Secure".to_owned(),+ b"=__Secure-token; Path=/; Secure".to_vec(),)],);@@ -2081,14 +2081,14 @@ fn same_site_none_requires_secure() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- "cross=1; Path=/; SameSite=None".to_owned(),+ b"cross=1; Path=/; SameSite=None".to_vec(),)],);store.store_response_headers(&parse("https://example.com/"),&[("set-cookie".to_owned(),- "cross=1; Path=/; SameSite=None; Secure".to_owned(),+ b"cross=1; Path=/; SameSite=None; Secure".to_vec(),)],);@@ -2106,14 +2106,14 @@ fn insecure_cookie_cannot_overlay_existing_secure_cookie() {&parse("https://example.com/login"),&[("set-cookie".to_owned(),- "sid=secure; Domain=example.com; Path=/login; Secure".to_owned(),+ b"sid=secure; Domain=example.com; Path=/login; Secure".to_vec(),)],);store.store_response_headers(&parse("http://sub.example.com/login"),&[("set-cookie".to_owned(),- "sid=insecure; Domain=example.com; Path=/login".to_owned(),+ b"sid=insecure; Domain=example.com; Path=/login".to_vec(),)],);@@ -2135,7 +2135,7 @@ fn secure_overlay_guard_reads_canonical_core() {&parse("https://example.com/login"),&[("set-cookie".to_owned(),- "sid=secure; Domain=example.com; Path=/login; Secure".to_owned(),+ b"sid=secure; Domain=example.com; Path=/login; Secure".to_vec(),)],);@@ -2145,7 +2145,7 @@ fn secure_overlay_guard_reads_canonical_core() {&parse("http://sub.example.com/login"),&[("set-cookie".to_owned(),- "sid=insecure; Domain=example.com; Path=/login".to_owned(),+ b"sid=insecure; Domain=example.com; Path=/login".to_vec(),)],);@@ -2160,8 +2160,8 @@ fn cookie_header_keeps_original_creation_order_for_same_path_length() {let mut store = BrowserCookieStore::default();let url = parse("https://example.com/");- store.store_response_headers(&url, &[("set-cookie".to_owned(), "b=2; Path=/".to_owned())]);- store.store_response_headers(&url, &[("set-cookie".to_owned(), "a=1; Path=/".to_owned())]);+ store.store_response_headers(&url, &[("set-cookie".to_owned(), b"b=2; Path=/".to_vec())]);+ store.store_response_headers(&url, &[("set-cookie".to_owned(), b"a=1; Path=/".to_vec())]);assert_eq!(store.cookie_header(&url), Some("b=2; a=1".to_owned()));}@@ -2177,7 +2177,7 @@ fn response_header_reports_project_sanitized_attribute_warnings() {&url,&[("set-cookie".to_owned(),- format!("sid=1; Domain={oversized_domain}; Path={invalid_path}; Secure"),+ format!("sid=1; Domain={oversized_domain}; Path={invalid_path}; Secure").into_bytes(),)],);@@ -2205,7 +2205,7 @@ fn response_header_reports_project_secure_access_warning_for_localhost_http() {&url,&[("set-cookie".to_owned(),- "sid=1; Path=/app; Secure".to_owned(),+ b"sid=1; Path=/app; Secure".to_vec(),)],);@@ -2227,11 +2227,11 @@ fn request_access_report_projects_schemeful_same_site_warning() {&[("set-cookie".to_owned(),- "strict=1; Path=/foo; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "none=1; Path=/foo; Secure; SameSite=None".to_owned(),+ b"none=1; Path=/foo; Secure; SameSite=None".to_vec(),),],);@@ -2300,7 +2300,7 @@ fn request_access_report_projects_lax_schemeful_same_site_warning() {&url,&[("set-cookie".to_owned(),- "lax=1; Path=/foo; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/foo; Secure; SameSite=Lax".to_vec(),)],);@@ -2338,7 +2338,7 @@ fn request_access_report_projects_secure_access_warning_for_localhost_http() {&url,&[("set-cookie".to_owned(),- "sid=1; Path=/app; Secure".to_owned(),+ b"sid=1; Path=/app; Secure".to_vec(),)],);@@ -2362,7 +2362,7 @@ fn request_access_report_projects_schemeful_only_redirect_metadata() {&url,&[("set-cookie".to_owned(),- "strict=1; Path=/foo; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; SameSite=Strict".to_vec(),)],);@@ -2408,7 +2408,7 @@ fn request_access_report_projects_http_method_and_redirect_type() {&url,&[("set-cookie".to_owned(),- "strict=1; Path=/foo; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; Secure; SameSite=Strict".to_vec(),)],);@@ -2450,7 +2450,7 @@ fn redirected_top_level_get_with_cross_site_initiator_and_same_site_frame_projec&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -2499,7 +2499,7 @@ fn redirected_top_level_post_with_cross_site_initiator_and_same_site_frame_proje&request_url,&[("set-cookie".to_owned(),- "lax=1; Path=/; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; Secure; SameSite=Lax".to_vec(),)],);@@ -2556,7 +2556,7 @@ fn redirected_top_level_get_with_same_site_initiator_and_frame_projects_partial_&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -2608,7 +2608,7 @@ fn redirected_top_level_post_with_same_site_initiator_and_frame_projects_partial&request_url,&[("set-cookie".to_owned(),- "lax=1; Path=/; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; Secure; SameSite=Lax".to_vec(),)],);@@ -2668,7 +2668,7 @@ fn redirected_subresource_get_with_same_site_initiator_and_frame_projects_partia&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -2721,7 +2721,7 @@ fn redirected_subresource_post_with_same_site_initiator_and_frame_projects_parti&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -2782,7 +2782,7 @@ fn redirected_top_level_get_with_same_site_initiator_and_frame_projects_all_same&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -2828,7 +2828,7 @@ fn redirected_top_level_post_with_same_site_initiator_and_frame_projects_all_sam&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -2882,7 +2882,7 @@ fn redirected_subresource_get_with_same_site_initiator_and_frame_projects_all_sa&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -2931,7 +2931,7 @@ fn redirected_subresource_post_with_same_site_initiator_and_frame_projects_all_s&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -2988,7 +2988,7 @@ fn redirected_subresource_get_with_cross_site_initiator_and_same_site_frame_proj&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -3041,7 +3041,7 @@ fn redirected_subresource_post_with_cross_site_initiator_and_same_site_frame_pro&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -3102,7 +3102,7 @@ fn redirected_top_level_get_with_same_site_chain_but_cross_site_final_stays_cros&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -3155,7 +3155,7 @@ fn redirected_subresource_get_with_same_site_chain_but_cross_site_final_stays_cr&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -3208,7 +3208,7 @@ fn redirected_top_level_post_with_same_site_chain_but_cross_site_final_stays_cro&request_url,&[("set-cookie".to_owned(),- "lax=1; Path=/; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; Secure; SameSite=Lax".to_vec(),)],);@@ -3268,7 +3268,7 @@ fn redirected_subresource_post_with_same_site_chain_but_cross_site_final_stays_c&request_url,&[("set-cookie".to_owned(),- "lax=1; Path=/; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; Secure; SameSite=Lax".to_vec(),)],);@@ -3325,7 +3325,7 @@ fn lowercase_safe_http_method_still_allows_top_level_lax_cookie() {&request_url,&[("set-cookie".to_owned(),- "lax=1; Path=/foo; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/foo; Secure; SameSite=Lax".to_vec(),)],);@@ -3362,7 +3362,7 @@ fn websocket_secure_scheme_is_schemefully_same_site_with_https_initiator_like_ch&parse("https://api.example.com/socket"),&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),)],);@@ -3413,7 +3413,7 @@ fn websocket_insecure_scheme_is_schemefully_same_site_with_http_initiator_like_c&parse("http://api.example.com/socket"),&[("set-cookie".to_owned(),- "strict=1; Path=/; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; SameSite=Strict".to_vec(),)],);@@ -3444,7 +3444,7 @@ fn websocket_insecure_scheme_is_cross_site_with_cross_site_initiator_like_chromi&parse("http://api.example.com/socket"),&[("set-cookie".to_owned(),- "strict=1; Path=/; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; SameSite=Strict".to_vec(),)],);@@ -3480,7 +3480,7 @@ fn top_level_get_request_reports_schemeful_lax_for_cross_scheme_same_site_initia&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/foo; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; Secure; SameSite=Strict".to_vec(),)],);@@ -3515,7 +3515,7 @@ fn top_level_get_request_reports_schemeful_lax_for_cross_scheme_same_site_initia&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/foo; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; SameSite=Strict".to_vec(),)],);@@ -3550,7 +3550,7 @@ fn top_level_post_request_reports_schemeful_lax_unsafe_for_cross_scheme_same_sit&request_url,&[("set-cookie".to_owned(),- "lax=1; Path=/foo; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/foo; Secure; SameSite=Lax".to_vec(),)],);@@ -3586,7 +3586,7 @@ fn top_level_post_request_reports_schemeful_lax_unsafe_for_cross_scheme_same_sit&request_url,&[("set-cookie".to_owned(),- "lax=1; Path=/foo; SameSite=Lax".to_owned(),+ b"lax=1; Path=/foo; SameSite=Lax".to_vec(),)],);@@ -3621,7 +3621,7 @@ fn subresource_request_reports_schemeful_cross_site_for_cross_scheme_same_site_i&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/foo; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; Secure; SameSite=Strict".to_vec(),)],);@@ -3657,7 +3657,7 @@ fn subresource_request_reports_schemeful_cross_site_for_cross_scheme_site_for_co&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/foo; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; Secure; SameSite=Strict".to_vec(),)],);@@ -3702,7 +3702,7 @@ fn subresource_post_reports_schemeful_cross_site_for_cross_scheme_site_for_cooki&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/foo; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; Secure; SameSite=Strict".to_vec(),)],);@@ -3749,7 +3749,7 @@ fn subresource_get_with_cross_site_initiator_stays_cross_site_even_if_site_for_c&request_url,&[("set-cookie".to_owned(),- "strict=1; Path=/foo; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; Secure; SameSite=Strict".to_vec(),)],);@@ -3789,7 +3789,7 @@ fn subresource_post_with_cross_site_initiator_stays_cross_site_even_if_site_for_&request_url,&[("set-cookie".to_owned(),- "lax=1; Path=/foo; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/foo; Secure; SameSite=Lax".to_vec(),)],);@@ -3837,7 +3837,7 @@ fn request_access_report_projects_browser_site_context_snapshot() {&response_url,&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),)],);@@ -3878,7 +3878,7 @@ fn request_access_report_is_agnostic_to_source_port() {&response_url,&[("set-cookie".to_owned(),- "sid=1; Path=/app; Secure".to_owned(),+ b"sid=1; Path=/app; Secure".to_vec(),)],);@@ -3906,7 +3906,7 @@ fn host_only_cookie_is_shared_across_ports_of_the_same_host() {store.store_response_headers(&set_url,- &[("set-cookie".to_owned(), "a=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"a=1; Path=/".to_vec())],);assert_eq!(store.document_cookie(&other_port_url), "a=1");@@ -3921,7 +3921,7 @@ fn request_access_report_projects_source_scheme_mismatch_exclusion() {store.store_response_headers(&response_url,- &[("set-cookie".to_owned(), "sid=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/app".to_vec())],);let report = store.cookie_access_report_for_request(@@ -3945,7 +3945,7 @@ fn request_access_report_accumulates_multiple_exclusion_reasons() {&response_url,&[("set-cookie".to_owned(),- "strict=1; Path=/foo; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; Secure; SameSite=Strict".to_vec(),)],);@@ -3977,11 +3977,11 @@ fn request_access_report_projects_access_semantics_and_secure_access_capability(&[("set-cookie".to_owned(),- "strict=1; Path=/foo; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/foo; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "sid=1; Path=/foo; Secure".to_owned(),+ b"sid=1; Path=/foo; Secure".to_vec(),),],);@@ -4033,15 +4033,15 @@ fn cookie_replacement_preserves_creation_order() {store.store_response_headers(&url,- &[("set-cookie".to_owned(), "first=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"first=1; Path=/".to_vec())],);store.store_response_headers(&url,- &[("set-cookie".to_owned(), "second=2; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"second=2; Path=/".to_vec())],);store.store_response_headers(&url,- &[("set-cookie".to_owned(), "first=3; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"first=3; Path=/".to_vec())],);assert_eq!(@@ -4130,7 +4130,7 @@ fn partitioned_cookie_is_stored_from_http_and_document_sources() {&url,&[("set-cookie".to_owned(),- "__Host-chip=1; Secure; Path=/; Partitioned".to_owned(),+ b"__Host-chip=1; Secure; Path=/; Partitioned".to_vec(),)],);store.set_document_cookie(&url, "__Host-domchip=1; Secure; Path=/; Partitioned");@@ -4187,7 +4187,7 @@ fn third_party_response_cookie_is_scoped_to_top_level_site() {&response_url,&[("set-cookie".to_owned(),- "cf_clearance=token; Secure; SameSite=None; Partitioned; Path=/".to_owned(),+ b"cf_clearance=token; Secure; SameSite=None; Partitioned; Path=/".to_vec(),)],&context_a,);@@ -4234,7 +4234,7 @@ fn delete_cookies_with_partition_key_keeps_other_top_level_sites() {&response_url,&[("set-cookie".to_owned(),- format!("chip={value}; Secure; SameSite=None; Partitioned; Path=/"),+ format!("chip={value}; Secure; SameSite=None; Partitioned; Path=/").into_bytes(),)],context,);@@ -4270,7 +4270,7 @@ fn response_cookie_records_priority_and_source_metadata() {&parse("https://example.com:8443/"),&[("set-cookie".to_owned(),- "prio=1; Path=/; Secure; Priority=High".to_owned(),+ b"prio=1; Path=/; Secure; Priority=High".to_vec(),)],);@@ -4291,13 +4291,13 @@ fn max_age_takes_precedence_over_expires_for_immediate_removal() {store.store_response_headers(&url,- &[("set-cookie".to_owned(), "sid=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/".to_vec())],);store.store_response_headers(&url,&[("set-cookie".to_owned(),- "sid=2; Path=/; Max-Age=0; Expires=Wed, 21 Oct 2099 07:28:00 GMT".to_owned(),+ b"sid=2; Path=/; Max-Age=0; Expires=Wed, 21 Oct 2099 07:28:00 GMT".to_vec(),)],);@@ -4313,7 +4313,7 @@ fn max_age_takes_precedence_over_past_expires_when_positive() {&url,&[("set-cookie".to_owned(),- "sid=1; Path=/; Max-Age=3600; Expires=Wed, 21 Oct 2015 07:28:00 GMT".to_owned(),+ b"sid=1; Path=/; Max-Age=3600; Expires=Wed, 21 Oct 2015 07:28:00 GMT".to_vec(),)],);@@ -4330,7 +4330,7 @@ fn oversized_path_attribute_is_ignored_and_defaults_request_path() {&url,&[("set-cookie".to_owned(),- format!("fallback=1; Path={oversized_path}"),+ format!("fallback=1; Path={oversized_path}").into_bytes(),)],);@@ -4351,7 +4351,7 @@ fn oversized_domain_attribute_is_ignored_and_cookie_becomes_host_only() {&url,&[("set-cookie".to_owned(),- format!("hostonly=1; Domain={oversized_domain}; Path=/"),+ format!("hostonly=1; Domain={oversized_domain}; Path=/").into_bytes(),)],);@@ -4374,7 +4374,7 @@ fn oversized_cookie_name_plus_value_is_rejected() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- format!("huge={oversized_value}; Path=/; Secure"),+ format!("huge={oversized_value}; Path=/; Secure").into_bytes(),)],);@@ -4391,19 +4391,19 @@ fn per_domain_eviction_prefers_removing_non_secure_cookie() {&url,&[("set-cookie".to_owned(),- format!("secure{index}=1; Path=/; Secure"),+ format!("secure{index}=1; Path=/; Secure").into_bytes(),)],);}store.store_response_headers(&url,- &[("set-cookie".to_owned(), "plain=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"plain=1; Path=/".to_vec())],);store.store_response_headers(&url,&[("set-cookie".to_owned(),- "newsecure=1; Path=/; Secure".to_owned(),+ b"newsecure=1; Path=/; Secure".to_vec(),)],);@@ -4423,13 +4423,13 @@ fn per_domain_eviction_rejects_new_non_secure_cookie_when_all_existing_are_secur&url,&[("set-cookie".to_owned(),- format!("secure{index}=1; Path=/; Secure"),+ format!("secure{index}=1; Path=/; Secure").into_bytes(),)],);}store.store_response_headers(&url,- &[("set-cookie".to_owned(), "plain=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"plain=1; Path=/".to_vec())],);assert_eq!(@@ -4446,14 +4446,17 @@ fn per_domain_eviction_removes_oldest_non_secure_cookie_first() {for index in 1..=5 {store.store_response_headers(&url,- &[("set-cookie".to_owned(), format!("plain{index}=1; Path=/"))],+ &[(+ "set-cookie".to_owned(),+ format!("plain{index}=1; Path=/").into_bytes(),+ )],);}store.store_response_headers(&url,&[("set-cookie".to_owned(),- "secure=1; Path=/; Secure".to_owned(),+ b"secure=1; Path=/; Secure".to_vec(),)],);@@ -4473,13 +4476,14 @@ fn expired_cookies_are_removed_before_domain_eviction() {&url,&[("set-cookie".to_owned(),- format!("stale{index}=1; Path=/; Expires=Wed, 21 Oct 2015 07:28:00 GMT"),+ format!("stale{index}=1; Path=/; Expires=Wed, 21 Oct 2015 07:28:00 GMT")+ .into_bytes(),)],);}store.store_response_headers(&url,- &[("set-cookie".to_owned(), "fresh=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"fresh=1; Path=/".to_vec())],);assert_eq!(@@ -4494,19 +4498,19 @@ fn global_eviction_applies_when_total_cookie_limit_is_hit() {store.store_response_headers(&parse("https://one.example/"),- &[("set-cookie".to_owned(), "a=1; Path=/; Secure".to_owned())],+ &[("set-cookie".to_owned(), b"a=1; Path=/; Secure".to_vec())],);store.store_response_headers(&parse("https://two.example/"),- &[("set-cookie".to_owned(), "b=1; Path=/; Secure".to_owned())],+ &[("set-cookie".to_owned(), b"b=1; Path=/; Secure".to_vec())],);store.store_response_headers(&parse("https://three.example/"),- &[("set-cookie".to_owned(), "c=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"c=1; Path=/".to_vec())],);store.store_response_headers(&parse("https://four.example/"),- &[("set-cookie".to_owned(), "d=1; Path=/; Secure".to_owned())],+ &[("set-cookie".to_owned(), b"d=1; Path=/; Secure".to_vec())],);assert_eq!(store.cookies().len(), 3);@@ -4526,28 +4530,28 @@ fn eviction_prefers_lower_priority_before_higher_priority() {&url,&[("set-cookie".to_owned(),- "low=1; Path=/; Priority=Low".to_owned(),+ b"low=1; Path=/; Priority=Low".to_vec(),)],);store.store_response_headers(&url,&[("set-cookie".to_owned(),- "high=1; Path=/; Priority=High".to_owned(),+ b"high=1; Path=/; Priority=High".to_vec(),)],);store.store_response_headers(&url,&[("set-cookie".to_owned(),- "medium=1; Path=/; Priority=Medium".to_owned(),+ b"medium=1; Path=/; Priority=Medium".to_vec(),)],);store.store_response_headers(&url,&[("set-cookie".to_owned(),- "high2=1; Path=/; Priority=High".to_owned(),+ b"high2=1; Path=/; Priority=High".to_vec(),)],);@@ -4565,7 +4569,7 @@ fn invalid_priority_falls_back_to_medium() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- "prio=1; Path=/; Priority=NotReal".to_owned(),+ b"prio=1; Path=/; Priority=NotReal".to_vec(),)],);@@ -4585,21 +4589,21 @@ fn upstream_samesite_request_context_matrix() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- "strict=1; Path=/; SameSite=Strict; Secure".to_owned(),+ b"strict=1; Path=/; SameSite=Strict; Secure".to_vec(),)],);store.store_response_headers(&parse("https://example.com/"),&[("set-cookie".to_owned(),- "lax=1; Path=/; SameSite=Lax; Secure".to_owned(),+ b"lax=1; Path=/; SameSite=Lax; Secure".to_vec(),)],);store.store_response_headers(&parse("https://example.com/"),&[("set-cookie".to_owned(),- "none=1; Path=/; SameSite=None; Secure".to_owned(),+ b"none=1; Path=/; SameSite=None; Secure".to_vec(),)],);@@ -4616,7 +4620,7 @@ fn upstream_partitioned_cookie_cases() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- "chip=1; Path=/; Secure; SameSite=None; Partitioned".to_owned(),+ b"chip=1; Path=/; Secure; SameSite=None; Partitioned".to_vec(),)],);@@ -4635,7 +4639,7 @@ fn upstream_cookie_quota_and_eviction_cases() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- format!("c{index}=1; Path=/; Secure"),+ format!("c{index}=1; Path=/; Secure").into_bytes(),)],);}@@ -4650,7 +4654,7 @@ fn upstream_schemeful_samesite_treats_http_to_https_as_cross_site() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- "strict=1; Path=/; SameSite=Strict; Secure".to_owned(),+ b"strict=1; Path=/; SameSite=Strict; Secure".to_vec(),)],);@@ -4668,7 +4672,7 @@ fn upstream_partitioned_cookie_isolated_by_top_level_site() {&widget_url,&[("set-cookie".to_owned(),- "chip=1; Path=/; Secure; SameSite=None; Partitioned".to_owned(),+ b"chip=1; Path=/; Secure; SameSite=None; Partitioned".to_vec(),)],&matching_context,);@@ -4697,7 +4701,7 @@ fn upstream_public_suffix_domain_rejection() {&parse("https://foo.co.uk/"),&[("set-cookie".to_owned(),- "wide=1; Domain=co.uk; Path=/; Secure".to_owned(),+ b"wide=1; Domain=co.uk; Path=/; Secure".to_vec(),)],);@@ -4711,7 +4715,7 @@ fn deeper_rule_does_not_shadow_parent_wildcard_during_domain_rejection() {&parse("https://foo.oci.customer-oci.com/"),&[("set-cookie".to_owned(),- "wide=1; Domain=oci.customer-oci.com; Path=/; Secure".to_owned(),+ b"wide=1; Domain=oci.customer-oci.com; Path=/; Secure".to_vec(),)],);@@ -4725,7 +4729,7 @@ fn public_suffix_identical_host_domain_downgrades_to_host_only() {&parse("https://github.io/"),&[("set-cookie".to_owned(),- "hostonly=1; Domain=github.io; Path=/; Secure".to_owned(),+ b"hostonly=1; Domain=github.io; Path=/; Secure".to_vec(),)],);@@ -4745,7 +4749,7 @@ fn upstream_priority_influences_eviction_order() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- format!("low{index}=1; Path=/; Secure; Priority=Low"),+ format!("low{index}=1; Path=/; Secure; Priority=Low").into_bytes(),)],);}@@ -4753,7 +4757,7 @@ fn upstream_priority_influences_eviction_order() {&parse("https://example.com/"),&[("set-cookie".to_owned(),- "high=1; Path=/; Secure; Priority=High".to_owned(),+ b"high=1; Path=/; Secure; Priority=High".to_vec(),)],);@@ -4769,7 +4773,7 @@ fn upstream_cookie_source_metadata_is_preserved() {let mut store = BrowserCookieStore::default();store.store_response_headers(&parse("https://example.com:8443/"),- &[("set-cookie".to_owned(), "sid=1; Path=/; Secure".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/; Secure".to_vec())],);let cookie = storediff --git a/moli-core/src/page/page_state_cache.rs b/moli-core/src/page/page_state_cache.rsindex 7b182ba34..1e7f1b9c2 100644--- a/moli-core/src/page/page_state_cache.rs+++ b/moli-core/src/page/page_state_cache.rs@@ -54,7 +54,7 @@ impl PageStateCache {&self.state().navigation_redirect_chain}- pub(super) fn headers(&self) -> &[(String, String)] {+ pub(super) fn headers(&self) -> &[(String, Vec<u8>)] {&self.state().headers}diff --git a/moli-core/src/page/renderer_command_support.rs b/moli-core/src/page/renderer_command_support.rsindex 61f68e78e..70d9fed5e 100644--- a/moli-core/src/page/renderer_command_support.rs+++ b/moli-core/src/page/renderer_command_support.rs@@ -164,7 +164,7 @@ impl Page {self.page_state.status()}- pub fn headers(&self) -> &[(String, String)] {+ pub fn headers(&self) -> &[(String, Vec<u8>)] {self.page_state.headers()}diff --git a/moli-core/src/page/subresource_support.rs b/moli-core/src/page/subresource_support.rsindex c4c04f7db..7e1cfc3f6 100644--- a/moli-core/src/page/subresource_support.rs+++ b/moli-core/src/page/subresource_support.rs@@ -212,7 +212,7 @@ impl Page {&mut self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> Result<()> {let pending = self.start_fulfill_pending_subresource_fetch(@@ -228,7 +228,7 @@ impl Page {&self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> Result<PendingPageCommand> {self.start_page_command(RendererPageCommand::FulfillPendingSubresourceFetch {@@ -256,7 +256,7 @@ impl Page {&mut self,internal_id: u64,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> Result<()> {let pending = self.start_continue_pending_subresource_response(internal_id,@@ -270,7 +270,7 @@ impl Page {&self,internal_id: u64,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> Result<PendingPageCommand> {self.start_page_command(RendererPageCommand::ContinuePendingSubresourceResponse {internal_id,@@ -332,7 +332,7 @@ impl Page {&mut self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> Result<()> {let pending = self.start_fulfill_pending_subresource_response(@@ -348,7 +348,7 @@ impl Page {&self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> Result<PendingPageCommand> {self.start_page_command(RendererPageCommand::FulfillPendingSubresourceResponse {diff --git a/moli-core/src/runtime/mod.rs b/moli-core/src/runtime/mod.rsindex 765ec5144..3a5e635ed 100644--- a/moli-core/src/runtime/mod.rs+++ b/moli-core/src/runtime/mod.rs@@ -210,7 +210,7 @@ impl RawDocument {self.response.status}- pub fn headers(&self) -> &[(String, String)] {+ pub fn headers(&self) -> &[(String, Vec<u8>)] {&self.response.headers}diff --git a/moli-core/src/runtime/navigation_engine.rs b/moli-core/src/runtime/navigation_engine.rsindex c4b4779e9..2bd6dd673 100644--- a/moli-core/src/runtime/navigation_engine.rs+++ b/moli-core/src/runtime/navigation_engine.rs@@ -45,7 +45,7 @@ struct DocumentPageLoadOptions {pub redirected: bool,pub redirect_count: usize,pub response_status: u16,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,pub response_body: String,pub document_start_scripts: Vec<DocumentStartScript>,pub runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1315,7 +1315,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1376,7 +1376,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1427,7 +1427,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1498,7 +1498,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1567,7 +1567,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1621,7 +1621,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1686,7 +1686,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1760,7 +1760,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1846,7 +1846,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1901,7 +1901,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -1968,7 +1968,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -2179,7 +2179,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,@@ -2245,7 +2245,7 @@ impl NavigationEngine {redirected: bool,redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,document_start_scripts: Vec<DocumentStartScript>,runtime_bindings: Vec<crate::page::RuntimeBindingRegistration>,diff --git a/moli-core/src/runtime/tests.rs b/moli-core/src/runtime/tests.rsindex 36eae7089..c54876938 100644--- a/moli-core/src/runtime/tests.rs+++ b/moli-core/src/runtime/tests.rs@@ -83,7 +83,7 @@ async fn external_raw_bridge_drop_after_body_eof_cancels_pending_fetch_completioResponseHead {final_url: Url::parse("https://bridge.test/document")?,status: 200,- headers: vec![("content-type".to_owned(), "text/html".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/html".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -2607,7 +2607,7 @@ async fn standalone_selector_observes_replacement_document_before_load() -> Resu.headers.iter().any(|(name, value)| {- name.eq_ignore_ascii_case("X-Fixture-Document") && value == "replacement"+ name.eq_ignore_ascii_case("X-Fixture-Document") && value == b"replacement"}));diff --git a/moli-encoding/Cargo.toml b/moli-encoding/Cargo.tomlindex 908d89776..4882e295d 100644--- a/moli-encoding/Cargo.toml+++ b/moli-encoding/Cargo.toml@@ -5,6 +5,7 @@ version = "0.1.0"edition = "2024"[dependencies]+moli-header-field = { path = "../moli-header-field" }encoding_rs = "0.8"moli-charset-parser = { path = "../moli-charset-parser" }moli-content-type = { path = "../moli-content-type" }diff --git a/moli-encoding/src/document.rs b/moli-encoding/src/document.rsindex 88df60445..1ceb79b9f 100644--- a/moli-encoding/src/document.rs+++ b/moli-encoding/src/document.rs@@ -13,13 +13,13 @@ const UTF16BE_XML_PREFIX: &[u8; 6] = b"\0<\0?\0x";pub type LegacyEncodingDetector =fn(bytes: &[u8], url_hint: Option<&str>) -> Option<&'static Encoding>;-pub fn decode_html_document(bytes: &[u8], headers: &[(String, String)]) -> (String, &'static str) {+pub fn decode_html_document(bytes: &[u8], headers: &[(String, Vec<u8>)]) -> (String, &'static str) {decode_html_document_with_fallback(bytes, headers, None)}pub fn decode_html_document_with_fallback(bytes: &[u8],- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],fallback_encoding: Option<&str>,) -> (String, &'static str) {let mut decoder = HtmlDocumentStreamingDecoder::new_with_fallback(headers, fallback_encoding);@@ -50,12 +50,12 @@ pub struct HtmlDocumentStreamingDecoder {}impl HtmlDocumentStreamingDecoder {- pub fn new(headers: &[(String, String)]) -> Self {+ pub fn new(headers: &[(String, Vec<u8>)]) -> Self {Self::new_with_options(headers, None, None, None)}pub fn new_with_legacy_encoding_detector(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],url_hint: &str,detector: LegacyEncodingDetector,) -> Self {@@ -63,14 +63,14 @@ impl HtmlDocumentStreamingDecoder {}pub fn new_with_fallback(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],fallback_encoding: Option<&str>,) -> Self {Self::new_with_options(headers, fallback_encoding, None, None)}fn new_with_options(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],fallback_encoding: Option<&str>,url_hint: Option<&str>,legacy_encoding_detector: Option<LegacyEncodingDetector>,diff --git a/moli-encoding/src/labels.rs b/moli-encoding/src/labels.rsindex edc3bd0bf..0836d609d 100644--- a/moli-encoding/src/labels.rs+++ b/moli-encoding/src/labels.rs@@ -38,15 +38,17 @@ pub fn charset_from_content_type(value: &str) -> Option<String> {(!charset.is_empty()).then(|| charset.to_owned())}-pub fn charset_from_headers(headers: &[(String, String)]) -> Option<String> {+pub fn charset_from_headers(headers: &[(String, Vec<u8>)]) -> Option<String> {headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("content-type"))- .and_then(|(_, value)| charset_from_content_type(value))+ .and_then(|(_, value)| {+ charset_from_content_type(&moli_header_field::decode_header_value(value))+ })}/// Selects Chromium's transport encoding from HTTP response headers.-pub fn encoding_from_response_headers(headers: &[(String, String)]) -> Option<&'static Encoding> {+pub fn encoding_from_response_headers(headers: &[(String, Vec<u8>)]) -> Option<&'static Encoding> {charset_from_headers(headers).as_deref().and_then(encoding_for_response_charset)diff --git a/moli-encoding/src/script.rs b/moli-encoding/src/script.rsindex 8c95ffa8a..406cc748b 100644--- a/moli-encoding/src/script.rs+++ b/moli-encoding/src/script.rs@@ -11,7 +11,7 @@ pub fn decode_utf8(bytes: &[u8]) -> String {pub fn decode_classic_script_source(bytes: &[u8],- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],script_charset: Option<&str>,document_character_set: Option<&str>,) -> String {diff --git a/moli-encoding/src/tests.rs b/moli-encoding/src/tests.rsindex 2b4863a84..6693d5d54 100644--- a/moli-encoding/src/tests.rs+++ b/moli-encoding/src/tests.rs@@ -26,9 +26,9 @@ fn unexpected_legacy_encoding_detector(#[test]fn content_type_charset_is_selected() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=gbk".to_owned(),+ b"text/html; charset=gbk".to_vec(),)];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);@@ -38,7 +38,7 @@ fn content_type_charset_is_selected() {#[test]fn meta_charset_is_selected_without_header_charset() {- let headers = vec![("Content-Type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(), b"text/html".to_vec())];let mut input = b"<!doctype html><meta charset=\"gbk\"><p>".to_vec();input.extend_from_slice(&gbk_bytes("家居"));let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);@@ -52,7 +52,7 @@ fn meta_charset_is_selected_without_header_charset() {#[test]fn meta_charset_can_be_split_across_chunks() {- let headers = vec![("Content-Type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(), b"text/html".to_vec())];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);assert_eq!(@@ -68,7 +68,7 @@ fn meta_charset_can_be_split_across_chunks() {#[test]fn ascii_prefix_streams_while_charset_sniffing_continues() {- let headers = vec![("Content-Type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(), b"text/html".to_vec())];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);assert_eq!(@@ -82,7 +82,7 @@ fn ascii_prefix_streams_while_charset_sniffing_continues() {#[test]fn later_meta_charset_decodes_unemitted_non_ascii_after_ascii_prefix() {- let headers = vec![("Content-Type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(), b"text/html".to_vec())];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);let mut tail = b"<meta charset=\"gbk\"><p>".to_vec();tail.extend_from_slice(&gbk_bytes("家居"));@@ -94,7 +94,7 @@ fn later_meta_charset_decodes_unemitted_non_ascii_after_ascii_prefix() {#[test]fn meta_charset_after_1024_bytes_still_in_head_is_selected() {- let headers = vec![("Content-Type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(), b"text/html".to_vec())];let mut input = vec![b' '; HTML_META_CHARSET_PRESCAN_LIMIT];input.extend_from_slice(b"<meta charset=\"gbk\"><p>");input.extend_from_slice(&gbk_bytes("家居"));@@ -108,7 +108,7 @@ fn meta_charset_after_1024_bytes_still_in_head_is_selected() {#[test]fn meta_charset_crossing_1024_byte_boundary_is_selected_while_in_head() {- let headers = vec![("Content-Type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(), b"text/html".to_vec())];let partial_meta = b"<meta char";let mut input = vec![b' '; HTML_META_CHARSET_PRESCAN_LIMIT - partial_meta.len()];input.extend_from_slice(partial_meta);@@ -124,7 +124,7 @@ fn meta_charset_crossing_1024_byte_boundary_is_selected_while_in_head() {#[test]fn meta_charset_after_1024_bytes_after_head_is_ignored() {- let headers = vec![("Content-Type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(), b"text/html".to_vec())];let mut input = b"<body>".to_vec();input.extend(vec![b' '; HTML_META_CHARSET_PRESCAN_LIMIT - input.len()]);input.extend_from_slice(b"<meta charset=\"gbk\"><p>");@@ -139,7 +139,7 @@ fn meta_charset_after_1024_bytes_after_head_is_ignored() {#[test]fn meta_charset_starting_before_1024_bytes_after_head_is_selected() {- let headers = vec![("Content-Type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(), b"text/html".to_vec())];let mut input = b"</head>".to_vec();input.extend(vec![b' ';@@ -196,9 +196,9 @@ fn meta_charset_prescan_ignores_script_text_and_requires_pragma_for_content() {#[test]fn gbk_multibyte_can_be_split_across_chunks() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=gbk".to_owned(),+ b"text/html; charset=gbk".to_vec(),)];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);@@ -208,9 +208,9 @@ fn gbk_multibyte_can_be_split_across_chunks() {#[test]fn bom_wins_over_header_charset() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=gbk".to_owned(),+ b"text/html; charset=gbk".to_vec(),)];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);@@ -222,9 +222,9 @@ fn bom_wins_over_header_charset() {#[test]fn unknown_charset_falls_back_to_html_default_on_finish() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=x-unknown".to_owned(),+ b"text/html; charset=x-unknown".to_vec(),)];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);@@ -243,9 +243,9 @@ fn unlabelled_html_document_without_detector_uses_html_default() {#[test]fn injected_legacy_content_detector_receives_url_hint() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=x-unknown".to_owned(),+ b"text/html; charset=x-unknown".to_vec(),)];let mut decoder = HtmlDocumentStreamingDecoder::new_with_legacy_encoding_detector(&headers,@@ -266,9 +266,9 @@ fn injected_legacy_content_detector_receives_url_hint() {#[test]fn declared_encodings_precede_injected_legacy_detector() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=gbk".to_owned(),+ b"text/html; charset=gbk".to_vec(),)];let mut header_decoder = HtmlDocumentStreamingDecoder::new_with_legacy_encoding_detector(&headers,@@ -412,7 +412,7 @@ fn classic_script_decoding_inherits_document_character_set() {&bytes,&[("Content-Type".to_owned(),- "application/javascript".to_owned()+ b"application/javascript".to_vec())],None,Some("shift_jis"),@@ -431,7 +431,7 @@ fn classic_script_header_charset_wins_over_document_character_set() {&bytes,&[("Content-Type".to_owned(),- "application/javascript; charset=windows-1251".to_owned(),+ b"application/javascript; charset=windows-1251".to_vec(),)],None,Some("shift_jis"),@@ -473,7 +473,7 @@ fn classic_script_bom_wins_over_labels() {&bytes,&[("Content-Type".to_owned(),- "application/javascript; charset=gbk".to_owned(),+ b"application/javascript; charset=gbk".to_vec(),)],Some("shift_jis"),Some("gbk"),@@ -590,9 +590,9 @@ fn meta_declared_utf16_does_not_override_a_bom() {#[test]fn transport_utf16_still_wins_over_the_meta_rewrite() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=utf-16le".to_owned(),+ b"text/html; charset=utf-16le".to_vec(),)];let input = utf16le_bytes("<meta charset=\"utf-16\">hi");@@ -616,9 +616,9 @@ fn bom_less_utf16le_xml_declaration_is_detected() {#[test]fn transport_charset_wins_over_utf16_xml_signature() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=windows-1252".to_owned(),+ b"text/html; charset=windows-1252".to_vec(),)];let input = utf16le_bytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<html><head></head><body>hi</body></html>",@@ -697,9 +697,9 @@ fn diverged_utf16_xml_signature_prefix_resumes_ascii_streaming() {#[test]fn transport_charset_does_not_wait_for_a_utf16_xml_signature_prefix() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=windows-1252".to_owned(),+ b"text/html; charset=windows-1252".to_vec(),)];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);@@ -770,9 +770,9 @@ fn meta_and_transport_encodings_precede_ascii_xml_declarations() {let input = br#"<?xml encoding="windows-1251"?><meta charset="windows-1253">"#;assert_eq!(decode_html_document(input, &[]).1, "windows-1253");- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=UTF-8".to_owned(),+ b"text/html; charset=UTF-8".to_vec(),)];assert_eq!(decode_html_document(input, &headers).1, "UTF-8");}@@ -864,9 +864,9 @@ fn header_charset_stays_inside_another_parameters_quoted_string() {charset_from_content_type("text/html; boundary=\"; charset=gbk\""),None);- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; boundary=\"; charset=gbk\"".to_owned(),+ b"text/html; boundary=\"; charset=gbk\"".to_vec(),)];assert_eq!(decode_html_document(b"<p>hi</p>", &headers).1,@@ -889,9 +889,9 @@ fn header_charset_removes_quoting_backslashes() {charset_from_content_type("text/html; charset=\"utf\\-8\"").as_deref(),Some("utf-8"));- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=\"utf\\-8\"".to_owned(),+ b"text/html; charset=\"utf\\-8\"".to_vec(),)];assert_eq!(decode_html_document(b"<p>hi</p>", &headers).1, "UTF-8");}@@ -942,9 +942,9 @@ fn header_charset_matches_chromium_network_tolerances() {fn header_charset_exact_lookup_rejects_non_http_whitespace() {for whitespace in ['\u{000b}', '\u{000c}', '\r', '\n'] {let expected_label = format!("{whitespace}gbk");- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- format!("text/html; charset={whitespace}gbk"),+ format!("text/html; charset={whitespace}gbk").into_bytes(),)];assert_eq!(diff --git a/moli-fetch/src/blocking/cache.rs b/moli-fetch/src/blocking/cache.rsindex 7f231a9d4..34a19cddf 100644--- a/moli-fetch/src/blocking/cache.rs+++ b/moli-fetch/src/blocking/cache.rs@@ -86,7 +86,7 @@ pub(crate) struct CachedStreamingResponseLookup {pub(crate) metadata: HttpCacheEntryMetadata,pub(crate) final_url: String,pub(crate) status: u16,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,pub(crate) body: std::io::BufReader<std::fs::File>,pub(crate) expires_at_unix_ms: Option<u64>,pub(crate) force_validate: bool,@@ -109,7 +109,7 @@ pub(super) fn request_cache_control_requires_validation(pub(crate) fn next_redirect_url_from_parts(final_url: &Url,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirect_count: usize,) -> Result<Option<Url>> {if !matches!(status, 301 | 302 | 303 | 307 | 308) {@@ -119,7 +119,7 @@ pub(crate) fn next_redirect_url_from_parts(let Some(location) = headers.iter().find(|(name, _)| name == "location")- .map(|(_, value)| value.as_str())+ .map(|(_, value)| crate::decode_header_value(value))else {return Ok(None);};@@ -129,8 +129,8 @@ pub(crate) fn next_redirect_url_from_parts(}final_url- .join(location)- .or_else(|_| Url::parse(location))+ .join(&location)+ .or_else(|_| Url::parse(&location)).map(Some).with_context(|| {anyhow!(@@ -144,7 +144,7 @@ pub(crate) fn next_followed_redirect_url_from_parts(request: &Request,final_url: &Url,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirect_count: usize,) -> Result<Option<Url>> {// HTTP fetch checks the network response before HTTP-redirect fetch. This@@ -188,9 +188,9 @@ mod tests {#[test]fn followed_redirect_rejects_non_http_target_before_request_state_changes() -> Result<()> {let current = Url::parse("https://example.test/start")?;- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("location".to_owned(),- "file:///moli-policy-must-not-open".to_owned(),+ b"file:///moli-policy-must-not-open".to_vec(),)];let request = Request::get_with_url(current.clone());diff --git a/moli-fetch/src/blocking/cache/lookup.rs b/moli-fetch/src/blocking/cache/lookup.rsindex 18f4116f5..7bba02dc0 100644--- a/moli-fetch/src/blocking/cache/lookup.rs+++ b/moli-fetch/src/blocking/cache/lookup.rs@@ -94,7 +94,7 @@ pub(crate) fn create_streaming_cache_body_writer_for_response_parts(request_url: &Url,cookie_header: Option<&str>,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Result<Option<HttpCacheBodyWriter>> {let Some((store, key)) =cache_store_and_key_for_request(config, request, request_url, cookie_header)@@ -122,7 +122,7 @@ pub(crate) fn finish_streaming_cached_response(cookie_header: Option<&str>,final_url: &Url,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirected: bool,writer: HttpCacheBodyWriter,) -> Result<()> {diff --git a/moli-fetch/src/blocking/cache/metadata.rs b/moli-fetch/src/blocking/cache/metadata.rsindex ee67bda58..54449825a 100644--- a/moli-fetch/src/blocking/cache/metadata.rs+++ b/moli-fetch/src/blocking/cache/metadata.rs@@ -13,7 +13,7 @@ pub(super) fn cache_metadata_for_response_parts(request_url: &Url,final_url: &Url,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirected: bool,) -> Option<HttpCacheEntryMetadata> {let cache_request_url = normalized_cache_url(request_url);@@ -37,6 +37,6 @@ pub(super) fn cache_metadata_for_response_parts())}-pub(crate) fn response_headers_forbid_cache_storage(headers: &[(String, String)]) -> bool {+pub(crate) fn response_headers_forbid_cache_storage(headers: &[(String, Vec<u8>)]) -> bool {!response_cache_policy(headers).store}diff --git a/moli-fetch/src/blocking/cache/revalidation.rs b/moli-fetch/src/blocking/cache/revalidation.rsindex d188ad528..22961cb67 100644--- a/moli-fetch/src/blocking/cache/revalidation.rs+++ b/moli-fetch/src/blocking/cache/revalidation.rs@@ -11,7 +11,7 @@ use super::{pub(crate) fn validation_headers_for_cached_streaming_response_lookup(lookup: &CachedStreamingResponseLookup,-) -> Vec<(String, String)> {+) -> Vec<(String, Vec<u8>)> {validation_headers_from_headers(&lookup.metadata.headers)}@@ -21,7 +21,7 @@ pub(crate) fn merge_cached_not_modified_streaming_response_lookup(request_url: &Url,cookie_header: Option<&str>,mut cached: CachedStreamingResponseLookup,- not_modified_headers: &[(String, String)],+ not_modified_headers: &[(String, Vec<u8>)],) -> Result<CachedStreamingResponseLookup> {let headers = merge_not_modified_headers(&cached.headers, not_modified_headers);cached.headers = headers.clone();diff --git a/moli-fetch/src/blocking/cache/vary.rs b/moli-fetch/src/blocking/cache/vary.rsindex 5682ac21b..da643af9a 100644--- a/moli-fetch/src/blocking/cache/vary.rs+++ b/moli-fetch/src/blocking/cache/vary.rs@@ -35,7 +35,7 @@ pub(super) fn vary_headers_for_response(config: &FetchConfig,request: &Request,request_url: &Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> Option<Vec<HttpCacheVaryHeader>> {let mut out = Vec::new();for normalized_name in response_vary_header_names(response_headers)? {diff --git a/moli-fetch/src/blocking/collectors.rs b/moli-fetch/src/blocking/collectors.rsindex 08d96f5d6..1db5bfcdc 100644--- a/moli-fetch/src/blocking/collectors.rs+++ b/moli-fetch/src/blocking/collectors.rs@@ -14,7 +14,7 @@ use url::Url;use crate::{FetchCancelHandle, FetchConfig, NegotiatedHttpVersion, NetworkRequestExtraInfo, Request,client_hints::{ClientHintResponseAction, ClientHintResponsePolicy},- headers::{decode_http_header_bytes, parse_http_header_line},+ headers::{decode_http_header_bytes, parse_http_response_header_line},};use crate::RedirectInfo;@@ -50,9 +50,10 @@ pub(crate) struct RequestTransferMetrics {pub(crate) fn transfer_metrics_from_easy<H: Handler>(easy: &Easy2<H>,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> RequestTransferMetrics {- let content_encoding = response_header_value(headers, "content-encoding").map(str::to_owned);+ let content_encoding =+ response_header_value(headers, "content-encoding").map(std::borrow::Cow::into_owned);let content_length = response_header_value(headers, "content-length").and_then(|value| value.parse::<u64>().ok()).filter(|value| *value > 0);@@ -86,11 +87,14 @@ fn duration_to_ms(duration: Duration) -> u64 {duration.as_millis().try_into().unwrap_or(u64::MAX)}-fn response_header_value<'a>(headers: &'a [(String, String)], name: &str) -> Option<&'a str> {+fn response_header_value<'a>(+ headers: &'a [(String, Vec<u8>)],+ name: &str,+) -> Option<std::borrow::Cow<'a, str>> {headers.iter().find(|(header_name, _)| header_name.eq_ignore_ascii_case(name))- .map(|(_, value)| value.as_str())+ .map(|(_, value)| crate::decode_header_value(value))}pub(crate) fn log_request_completion(@@ -121,7 +125,7 @@ pub(crate) fn log_request_completion(#[derive(Debug, Default)]pub(crate) struct ResponseCollector {body: Vec<u8>,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,max_response_size: Option<usize>,response_too_large: bool,cancel_handle: Option<FetchCancelHandle>,@@ -142,7 +146,7 @@ impl ResponseCollector {self.response_too_large = false;}- pub(crate) fn headers(&self) -> &[(String, String)] {+ pub(crate) fn headers(&self) -> &[(String, Vec<u8>)] {&self.headers}@@ -154,7 +158,7 @@ impl ResponseCollector {#[derive(Debug)]pub struct StreamingResponseCollector {cookie_store: SharedBrowserCookieStore,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,current_url: Option<Url>,current_cookie_context: Option<NetworkCookieRequestContext>,status: u16,@@ -206,7 +210,7 @@ impl StreamingCachePlan {fn create_body_writer(&self,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Result<Option<HttpCacheBodyWriter>> {create_streaming_cache_body_writer_for_response_parts(&self.config,@@ -222,7 +226,7 @@ impl StreamingCachePlan {#[derive(Debug)]pub struct RawStreamingResponseCollector {cookie_store: SharedBrowserCookieStore,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,current_url: Option<Url>,current_cookie_context: Option<NetworkCookieRequestContext>,status: u16,@@ -342,7 +346,7 @@ impl StreamingResponseCollector {self.cache_plan = cache_plan;}- pub fn headers(&self) -> &[(String, String)] {+ pub fn headers(&self) -> &[(String, Vec<u8>)] {&self.headers}@@ -700,7 +704,7 @@ impl RawStreamingResponseCollector {self.defer_not_modified_start = defer_not_modified_start;}- pub fn headers(&self) -> &[(String, String)] {+ pub fn headers(&self) -> &[(String, Vec<u8>)] {&self.headers}@@ -959,7 +963,7 @@ impl Handler for ResponseCollector {return true;}- let Some((mut name, value)) = parse_http_header_line(line) else {+ let Some((mut name, value)) = parse_http_response_header_line(data) else {return true;};name.make_ascii_lowercase();@@ -967,7 +971,11 @@ impl Handler for ResponseCollector {if name == "content-length"&& self.max_response_size- .zip(value.parse::<usize>().ok())+ .zip(+ std::str::from_utf8(&value)+ .ok()+ .and_then(|value| value.parse::<usize>().ok()),+ ).is_some_and(|(limit, content_length)| content_length > limit){self.response_too_large = true;@@ -1023,7 +1031,7 @@ impl Handler for StreamingResponseCollector {return true;}- let Some((mut name, value)) = parse_http_header_line(line) else {+ let Some((mut name, value)) = parse_http_response_header_line(data) else {return true;};name.make_ascii_lowercase();@@ -1031,7 +1039,11 @@ impl Handler for StreamingResponseCollector {if name == "content-length"&& self.max_response_size- .zip(value.parse::<usize>().ok())+ .zip(+ std::str::from_utf8(&value)+ .ok()+ .and_then(|value| value.parse::<usize>().ok()),+ ).is_some_and(|(limit, content_length)| content_length > limit){self.response_too_large = true;@@ -1094,7 +1106,7 @@ impl Handler for RawStreamingResponseCollector {return true;}- let Some((mut name, value)) = parse_http_header_line(line) else {+ let Some((mut name, value)) = parse_http_response_header_line(data) else {return true;};name.make_ascii_lowercase();@@ -1102,7 +1114,11 @@ impl Handler for RawStreamingResponseCollector {if name == "content-length"&& self.max_response_size- .zip(value.parse::<usize>().ok())+ .zip(+ std::str::from_utf8(&value)+ .ok()+ .and_then(|value| value.parse::<usize>().ok()),+ ).is_some_and(|(limit, content_length)| content_length > limit){self.response_too_large = true;@@ -1118,7 +1134,8 @@ impl Handler for RawStreamingResponseCollector {}}-fn identity_encoded_content_length(headers: &[(String, String)]) -> Option<usize> {+fn identity_encoded_content_length(headers: &[(String, Vec<u8>)]) -> Option<usize> {+ let headers = crate::headers_to_byte_strings(headers);let cannot_compare_delivered_body_length = headers.iter().any(|(name, value)| {(name.eq_ignore_ascii_case("content-encoding")&& !value.trim().eq_ignore_ascii_case("identity"))diff --git a/moli-fetch/src/blocking/mod.rs b/moli-fetch/src/blocking/mod.rsindex 3be28df80..78f08a6a3 100644--- a/moli-fetch/src/blocking/mod.rs+++ b/moli-fetch/src/blocking/mod.rs@@ -66,7 +66,7 @@ pub(crate) enum RequestHttpVersion {pub struct StreamingHtmlResponseStart {pub final_url: Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub request_cookie_report: Option<StoredCookieQueryReport>,pub cookie_set_reports: Vec<StoredCookieSetReport>,pub redirected: bool,@@ -529,7 +529,7 @@ fn referrer_header_value_for_request(request: &Request, request_url: &Url) -> Oppub(crate) fn store_response_cookies(cookie_store: &SharedBrowserCookieStore,response_url: &Url,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],request_context: &NetworkCookieRequestContext,) -> Result<Vec<StoredCookieSetReport>> {let mut cookie_store = cookie_store.lock();@@ -548,7 +548,7 @@ pub(crate) fn configure_easy(request_url: &Url,cookie_header: Option<&str>,http_version: RequestHttpVersion,- validation_headers: Option<Vec<(String, String)>>,+ validation_headers: Option<Vec<(String, Vec<u8>)>>,) -> Result<Vec<(String, String)>> {ensure_http_network_transport_url(request_url)?;if crate::should_request_be_blocked_due_to_bad_port(request_url) {@@ -703,8 +703,8 @@ pub(crate) fn configure_easy(.context("failed to build request header")?;}if let Some(validation_headers) = validation_headers {- // Validators were read from response headers and are ByteStrings.- let validation_headers = crate::RequestHeaders::from_byte_strings(&validation_headers)?;+ // Preserve cached response validator bytes in the conditional request.+ let validation_headers = crate::RequestHeaders::from_bytes(validation_headers);for (name, value) in validation_headers.iter() {has_content_type_header |= name.eq_ignore_ascii_case("content-type");append_curl_request_header(&mut headers, name, value)diff --git a/moli-fetch/src/client_hints.rs b/moli-fetch/src/client_hints.rsindex 7ef173957..feec0a913 100644--- a/moli-fetch/src/client_hints.rs+++ b/moli-fetch/src/client_hints.rs@@ -138,7 +138,7 @@ impl ClientHintResponsePolicy {pub(crate) fn observe_response(&self,response_url: &Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> ClientHintResponseAction {// Chromium only persists Accept-CH from a main-frame navigation.// Subresource and child-frame responses must not mutate browser-context@@ -262,27 +262,28 @@ fn configured_client_hint_names(config: &FetchConfig, request: &Request) -> BTre}fn parse_client_hint_header(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],header_name: &str,) -> Option<BTreeSet<ClientHint>> {let values = headers.iter().filter(|(name, _)| name.eq_ignore_ascii_case(header_name))- .map(|(_, value)| value.as_str())+ .map(|(_, value)| crate::decode_header_value(value)).collect::<Vec<_>>();if values.is_empty() {return None;}Some(values- .into_iter()+ .iter().flat_map(|value| value.split(',')).filter_map(ClientHint::from_header_name).collect(),)}-fn clear_site_data_clears_client_hints(headers: &[(String, String)]) -> bool {+fn clear_site_data_clears_client_hints(headers: &[(String, Vec<u8>)]) -> bool {+ let headers = crate::headers_to_byte_strings(headers);headers.iter().filter(|(name, _)| name.eq_ignore_ascii_case("clear-site-data"))@@ -316,14 +317,14 @@ mod tests {let restarts = shared_restarts();let first =prepare_client_hint_request(&preferences, &restarts, &config, &request, &request.url);- let headers = vec![+ let headers: Vec<(String, Vec<u8>)> = vec![("Accept-CH".to_owned(),- "Sec-CH-UA-Arch, Sec-CH-UA-Full-Version-List".to_owned(),+ b"Sec-CH-UA-Arch, Sec-CH-UA-Full-Version-List".to_vec(),),("Critical-CH".to_owned(),- "Sec-CH-UA-Arch, Sec-CH-UA-Full-Version-List".to_owned(),+ b"Sec-CH-UA-Arch, Sec-CH-UA-Full-Version-List".to_vec(),),];@@ -363,7 +364,7 @@ mod tests {assert_eq!(first.response_policy.observe_response(&request.url,- &[("Accept-CH".to_owned(), "Sec-CH-UA-Arch".to_owned())],+ &[("Accept-CH".to_owned(), b"Sec-CH-UA-Arch".to_vec())],),ClientHintResponseAction::Continue);@@ -387,7 +388,7 @@ mod tests {);clear.response_policy.observe_response(&request.url,- &[("Clear-Site-Data".to_owned(), "\"clientHints\"".to_owned())],+ &[("Clear-Site-Data".to_owned(), b"\"clientHints\"".to_vec())],);let after_clear = prepare_client_hint_request(&preferences,@@ -413,7 +414,7 @@ mod tests {assert_eq!(prepared.response_policy.observe_response(&request.url,- &[("Accept-CH".to_owned(), "Sec-CH-UA-Arch".to_owned())],+ &[("Accept-CH".to_owned(), b"Sec-CH-UA-Arch".to_vec())],),ClientHintResponseAction::Continue);diff --git a/moli-fetch/src/cors.rs b/moli-fetch/src/cors.rsindex 20cd75348..b77c673f3 100644--- a/moli-fetch/src/cors.rs+++ b/moli-fetch/src/cors.rs@@ -4,7 +4,7 @@ use crate::RequestCredentialsMode;pub fn validate_cors_response_for_origin(origin: &str,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],credentials_mode: RequestCredentialsMode,) -> Result<(), String> {let Some(allow_origin) = response_header_value(response_headers, "access-control-allow-origin")diff --git a/moli-fetch/src/headers.rs b/moli-fetch/src/headers.rsindex 5f1c3827d..c4996834a 100644--- a/moli-fetch/src/headers.rs+++ b/moli-fetch/src/headers.rs@@ -5,11 +5,35 @@ use moli_web_mime::request_header_content_type_essence;// Header strings represent HTTP bytes one-for-one, including obs-text. UTF-8// decoding would either replace bytes or combine a valid multibyte sequence.pub(crate) fn decode_http_header_bytes(data: &[u8]) -> Cow<'_, str> {- if data.is_ascii() {- Cow::Borrowed(std::str::from_utf8(data).expect("ASCII is valid UTF-8"))- } else {- Cow::Owned(data.iter().copied().map(char::from).collect())+ moli_header_field::decode_header_value(data)+}++pub(crate) fn parse_http_response_header_line(data: &[u8]) -> Option<(String, Vec<u8>)> {+ let end = data+ .iter()+ .rposition(|byte| !matches!(byte, b'\r' | b'\n'))+ .map_or(0, |index| index + 1);+ let line = &data[..end];+ let separator = line.iter().position(|byte| *byte == b':')?;+ let name = trim_http_ows(&line[..separator]);+ if name.is_empty() {+ return None;}+ let value = trim_http_ows(&line[separator + 1..]);+ Some((decode_http_header_bytes(name).into_owned(), value.to_vec()))+}++fn trim_http_ows(bytes: &[u8]) -> &[u8] {+ let start = bytes+ .iter()+ .position(|byte| !matches!(byte, b' ' | b'\t'))+ .unwrap_or(bytes.len());+ let bytes = &bytes[start..];+ let end = bytes+ .iter()+ .rposition(|byte| !matches!(byte, b' ' | b'\t'))+ .map_or(0, |index| index + 1);+ &bytes[..end]}pub(crate) fn parse_http_header_line(line: &str) -> Option<(String, String)> {diff --git a/moli-fetch/src/lib.rs b/moli-fetch/src/lib.rsindex 5557f1af0..90c1e6ca8 100644--- a/moli-fetch/src/lib.rs+++ b/moli-fetch/src/lib.rs@@ -54,6 +54,10 @@ pub use moli_curl::websocket::CurlWebSocketConnector;pub use moli_curl::{CurlTlsConfig, validate_http_host_resolve_entries};pub use moli_header_field::HeaderFields as RequestHeaders;pub use moli_header_field::HeaderFields as ResponseHeaders;+pub use moli_header_field::{+ decode_header_value, deserialize_headers, header_value_from_byte_string,+ headers_from_byte_strings, headers_to_byte_strings,+};pub use moli_web_bot_auth::{WebBotAuthProfile, WebBotAuthSigner};pub use network_fetch_result::{NetworkExchangeObservation, NetworkFetchFailureContext, NetworkFetchFailureRequestContext,diff --git a/moli-fetch/src/network_fetch_result.rs b/moli-fetch/src/network_fetch_result.rsindex eab7b76a2..f85f89c5b 100644--- a/moli-fetch/src/network_fetch_result.rs+++ b/moli-fetch/src/network_fetch_result.rs@@ -1,4 +1,6 @@-use crate::headers::{decode_http_header_bytes, parse_http_header_line};+use crate::headers::{+ decode_http_header_bytes, parse_http_header_line, parse_http_response_header_line,+};use std::{fmt, sync::Arc};@@ -58,12 +60,12 @@ impl NetworkRequestObservation {#[derive(Clone, Debug, Eq, PartialEq)]pub struct NetworkResponseObservation {status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,truncated: bool,}impl NetworkResponseObservation {- pub fn new(status: u16, headers: Vec<(String, String)>) -> Self {+ pub fn new(status: u16, headers: Vec<(String, Vec<u8>)>) -> Self {Self {status,headers,@@ -75,7 +77,7 @@ impl NetworkResponseObservation {self.status}- pub fn headers(&self) -> &[(String, String)] {+ pub fn headers(&self) -> &[(String, Vec<u8>)] {&self.headers}@@ -275,7 +277,7 @@ impl NetworkObservationRecorder {response.truncated = true;return;}- if let Some(header) = parse_http_header_line(line) {+ if let Some(header) = parse_http_response_header_line(data) {response.headers.push(header);}}@@ -301,7 +303,7 @@ struct NetworkObservationRecorderState {struct PendingResponseObservation {status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,observed_bytes: usize,truncated: bool,}diff --git a/moli-fetch/src/proxy_connect.rs b/moli-fetch/src/proxy_connect.rsindex d7e9ac23e..96c89aa51 100644--- a/moli-fetch/src/proxy_connect.rs+++ b/moli-fetch/src/proxy_connect.rs@@ -1,11 +1,11 @@-use crate::headers::{decode_http_header_bytes, parse_http_header_line};+use crate::headers::{decode_http_header_bytes, parse_http_response_header_line};const MAX_PROXY_CONNECT_HEADER_BYTES: usize = 256 * 1024;#[derive(Clone, Debug, Eq, PartialEq)]pub(crate) struct ProxyConnectResponse {pub(crate) status: u16,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,}#[derive(Debug, Default)]@@ -13,7 +13,7 @@ pub(crate) struct ProxyConnectResponseRecorder {enabled: bool,collecting: bool,pending_status: Option<u16>,- pending_headers: Vec<(String, String)>,+ pending_headers: Vec<(String, Vec<u8>)>,observed_bytes: usize,completed: Option<ProxyConnectResponse>,}@@ -72,7 +72,7 @@ impl ProxyConnectResponseRecorder {});return;}- if let Some(header) = parse_http_header_line(line) {+ if let Some(header) = parse_http_response_header_line(data) {self.pending_headers.push(header);}}@@ -134,7 +134,7 @@ mod tests {status: 407,headers: vec![("Proxy-Authenticate".to_owned(),- "Basic realm=\"\u{ff}\"".to_owned(),+ b"Basic realm=\"\xff\"".to_vec(),)],}));diff --git a/moli-fetch/src/request.rs b/moli-fetch/src/request.rsindex 4b6c4df56..16cc65e9e 100644--- a/moli-fetch/src/request.rs+++ b/moli-fetch/src/request.rs@@ -848,7 +848,7 @@ impl Request {pub fn validate_cors_response_for_url(&self,response_url: &Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> Result<(), String> {if self.request_mode != RequestMode::Cors|| !matches!(response_url.scheme(), "http" | "https")diff --git a/moli-fetch/src/response.rs b/moli-fetch/src/response.rsindex 05656a27f..49893d2f3 100644--- a/moli-fetch/src/response.rs+++ b/moli-fetch/src/response.rs@@ -41,7 +41,7 @@ impl NegotiatedHttpVersion {pub struct ResponseHead {pub final_url: Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub request_cookie_report: Option<StoredCookieQueryReport>,pub cookie_set_reports: Vec<StoredCookieSetReport>,pub redirected: bool,@@ -255,7 +255,7 @@ impl ResponseBody {pub struct Response {pub final_url: Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,body: ResponseBody,pub request_cookie_report: Option<StoredCookieQueryReport>,pub cookie_set_reports: Vec<StoredCookieSetReport>,@@ -457,7 +457,7 @@ impl Response {pub struct RawResponse {pub final_url: Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,body: ResponseBody,pub request_cookie_report: Option<StoredCookieQueryReport>,pub cookie_set_reports: Vec<StoredCookieSetReport>,@@ -613,7 +613,7 @@ pub struct NetworkRequestExtraInfo {pub struct NetworkResponseExtraInfo {pub request_extra_info: NetworkRequestExtraInfo,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub cookie_set_reports: Vec<StoredCookieSetReport>,}@@ -635,7 +635,7 @@ pub struct RedirectInfo {pub from_url: Url,pub to_url: Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,/// Whether this redirect came from an observable HTTP response header block.////// Cached and browser-internal redirects do not have Network ExtraInfo evendiff --git a/moli-fetch/src/runtime.rs b/moli-fetch/src/runtime.rsindex 4c05dbf3f..1e2968fa2 100644--- a/moli-fetch/src/runtime.rs+++ b/moli-fetch/src/runtime.rs@@ -3337,10 +3337,10 @@ fn https_upgrade_redirect_info(source: crate::RedirectSource::Internal,from_url,headers: vec![- ("location".to_owned(), to_url.to_string()),+ ("location".to_owned(), to_url.to_string().into_bytes()),("non-authoritative-reason".to_owned(),- "HttpsUpgrades".to_owned(),+ b"HttpsUpgrades".to_vec(),),],to_url,@@ -3372,7 +3372,7 @@ fn attach_next_request_extra_info(fn network_response_extra_info(request_extra_info: NetworkRequestExtraInfo,status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,cookie_set_reports: Vec<moli_cookie_jar::StoredCookieSetReport>,) -> NetworkResponseExtraInfo {NetworkResponseExtraInfo {@@ -3392,7 +3392,7 @@ fn critical_client_hint_restart_redirect_info(from_url: url.clone(),to_url: url.clone(),status: 307,- headers: vec![("Location".to_owned(), url.to_string())],+ headers: vec![("Location".to_owned(), url.to_string().into_bytes())],network_extra_info_available: false,request_extra_info: None,response_extra_info: Some(response_extra_info),@@ -4239,7 +4239,7 @@ mod tests {ResponseHead {final_url: final_url.clone(),status: 200,- headers: vec![("content-type".to_owned(), "text/html".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/html".to_vec())],request_cookie_report: Some(request_cookie_report.clone()),cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-fetch/src/streaming_response.rs b/moli-fetch/src/streaming_response.rsindex 10abf7a39..ac68f6e67 100644--- a/moli-fetch/src/streaming_response.rs+++ b/moli-fetch/src/streaming_response.rs@@ -24,7 +24,7 @@ impl fmt::Debug for StreamingResponseLifetimeLease {pub struct StreamingHtmlResponse {pub final_url: Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub request_cookie_report: Option<StoredCookieQueryReport>,pub cookie_set_reports: Vec<StoredCookieSetReport>,pub redirected: bool,@@ -41,7 +41,7 @@ impl StreamingHtmlResponse {pub fn new(final_url: Url,status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,body_chunks: mpsc::UnboundedReceiver<String>,cancel_handle: FetchCancelHandle,completion: oneshot::Receiver<Result<()>>,@@ -163,7 +163,7 @@ impl Drop for StreamingHtmlResponse {pub struct StreamingRawResponse {pub final_url: Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub request_cookie_report: Option<StoredCookieQueryReport>,pub cookie_set_reports: Vec<StoredCookieSetReport>,pub redirected: bool,@@ -181,7 +181,7 @@ impl StreamingRawResponse {pub fn new(final_url: Url,status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,request_cookie_report: Option<StoredCookieQueryReport>,cookie_set_reports: Vec<StoredCookieSetReport>,redirected: bool,@@ -372,7 +372,7 @@ mod tests {ResponseHead {final_url: Url::parse("http://example.test/final").expect("test URL"),status: 203,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-fetch/src/tests/cookie_context.rs b/moli-fetch/src/tests/cookie_context.rsindex 4919eea64..eebc897b4 100644--- a/moli-fetch/src/tests/cookie_context.rs+++ b/moli-fetch/src/tests/cookie_context.rs@@ -147,11 +147,11 @@ fn request_cookie_header_respects_explicit_top_level_lax_navigation_context() {&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),),],);@@ -181,15 +181,15 @@ fn request_cookie_header_respects_explicit_cross_site_context_without_lax_upgrad&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),),("set-cookie".to_owned(),- "none=1; Path=/app; Secure; SameSite=None".to_owned(),+ b"none=1; Path=/app; Secure; SameSite=None".to_vec(),),],);@@ -219,15 +219,15 @@ fn request_with_initiator_url_marks_cross_site_subresource_requests() {&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),),("set-cookie".to_owned(),- "none=1; Path=/app; Secure; SameSite=None".to_owned(),+ b"none=1; Path=/app; Secure; SameSite=None".to_vec(),),],);@@ -256,7 +256,7 @@ fn request_with_initiator_url_treats_same_scheme_subdomains_as_same_site() {&response_url,&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),)],);}@@ -284,7 +284,7 @@ fn request_with_initiator_url_treats_same_scheme_sibling_subdomains_as_same_site&response_url,&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),)],);}@@ -321,11 +321,11 @@ fn request_with_initiator_url_respects_public_suffix_boundaries() {&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),),],);@@ -362,7 +362,7 @@ fn request_with_initiator_url_treats_multi_label_registrable_domains_as_same_sit&response_url,&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),)],);}@@ -411,15 +411,15 @@ fn request_with_site_for_cookies_url_uses_explicit_browser_context_for_same_site&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),),("set-cookie".to_owned(),- "none=1; Path=/app; Secure; SameSite=None".to_owned(),+ b"none=1; Path=/app; Secure; SameSite=None".to_vec(),),],);@@ -460,11 +460,11 @@ fn request_with_top_frame_origin_url_falls_back_when_site_for_cookies_is_absent(&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),),],);@@ -520,15 +520,15 @@ fn request_with_cross_scheme_initiator_uses_schemeful_cross_site_semantics() {&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),),("set-cookie".to_owned(),- "none=1; Path=/app; Secure; SameSite=None".to_owned(),+ b"none=1; Path=/app; Secure; SameSite=None".to_vec(),),],);@@ -564,15 +564,15 @@ fn request_effective_cookie_context_recomputes_same_site_for_redirect_targets()&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),),("set-cookie".to_owned(),- "none=1; Path=/app; Secure; SameSite=None".to_owned(),+ b"none=1; Path=/app; Secure; SameSite=None".to_vec(),),],);@@ -605,7 +605,7 @@ fn request_effective_cookie_context_marks_cross_site_redirect_downgrade_in_repor&response_url,&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),)],);@@ -764,15 +764,15 @@ fn redirect_chain_cookie_context_preserves_cross_site_downgrade_across_later_sam&[("set-cookie".to_owned(),- "strict=1; Path=/; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/; Secure; SameSite=Lax".to_vec(),),("set-cookie".to_owned(),- "none=1; Path=/; Secure; SameSite=None".to_owned(),+ b"none=1; Path=/; Secure; SameSite=None".to_vec(),),],);@@ -810,11 +810,11 @@ fn top_level_request_with_initiator_url_uses_cross_site_lax_navigation_semantics&[("set-cookie".to_owned(),- "strict=1; Path=/app; Secure; SameSite=Strict".to_owned(),+ b"strict=1; Path=/app; Secure; SameSite=Strict".to_vec(),),("set-cookie".to_owned(),- "lax=1; Path=/app; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/app; Secure; SameSite=Lax".to_vec(),),],);diff --git a/moli-fetch/src/tests/cookie_store.rs b/moli-fetch/src/tests/cookie_store.rsindex 7ee78e7e3..661a41004 100644--- a/moli-fetch/src/tests/cookie_store.rs+++ b/moli-fetch/src/tests/cookie_store.rs@@ -15,7 +15,7 @@ fn host_only_cookie_uses_default_path_and_path_boundary_matching() {let response_url = Url::parse("http://example.com/scoped/index.html").unwrap();jar.store_response_headers(&response_url,- &[("set-cookie".to_owned(), "scope=1; HttpOnly".to_owned())],+ &[("set-cookie".to_owned(), b"scope=1; HttpOnly".to_vec())],);assert_eq!(@@ -41,14 +41,14 @@ fn cookie_replacement_uses_name_domain_and_path_key() {&response_url,&[("set-cookie".to_owned(),- "theme=light; Path=/account".to_owned(),+ b"theme=light; Path=/account".to_vec(),)],);jar.store_response_headers(&response_url,&[("set-cookie".to_owned(),- "theme=dark; Path=/account".to_owned(),+ b"theme=dark; Path=/account".to_vec(),)],);@@ -67,7 +67,7 @@ fn invalid_domain_cookie_is_ignored() {&response_url,&[("set-cookie".to_owned(),- "session=bad; Domain=other.com; Path=/".to_owned(),+ b"session=bad; Domain=other.com; Path=/".to_vec(),)],);@@ -86,7 +86,7 @@ fn secure_cookie_only_matches_https_requests() {&response_url,&[("set-cookie".to_owned(),- "session=secure; Path=/; Secure".to_owned(),+ b"session=secure; Path=/; Secure".to_vec(),)],);@@ -107,13 +107,13 @@ fn max_age_zero_removes_existing_cookie_immediately() {jar.store_response_headers(&response_url,- &[("set-cookie".to_owned(), "flash=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"flash=1; Path=/".to_vec())],);jar.store_response_headers(&response_url,&[("set-cookie".to_owned(),- "flash=gone; Path=/; Max-Age=0".to_owned(),+ b"flash=gone; Path=/; Max-Age=0".to_vec(),)],);@@ -130,7 +130,7 @@ fn host_only_cookie_does_not_match_subdomains() {jar.store_response_headers(&response_url,- &[("set-cookie".to_owned(), "hostonly=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"hostonly=1; Path=/".to_vec())],);assert_eq!(@@ -148,7 +148,7 @@ fn domain_cookie_matches_subdomains_and_normalizes_leading_dot() {&response_url,&[("set-cookie".to_owned(),- "shared=1; Domain=.example.com; Path=/".to_owned(),+ b"shared=1; Domain=.example.com; Path=/".to_vec(),)],);@@ -167,7 +167,7 @@ fn invalid_cookie_path_falls_back_to_default_request_path() {&response_url,&[("set-cookie".to_owned(),- "fallback=1; Path=relative".to_owned(),+ b"fallback=1; Path=relative".to_vec(),)],);@@ -188,13 +188,13 @@ fn expires_in_past_removes_cookie_immediately() {jar.store_response_headers(&response_url,- &[("set-cookie".to_owned(), "session=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/".to_vec())],);jar.store_response_headers(&response_url,&[("set-cookie".to_owned(),- "session=gone; Path=/; Expires=Wed, 21 Oct 2015 07:28:00 GMT".to_owned(),+ b"session=gone; Path=/; Expires=Wed, 21 Oct 2015 07:28:00 GMT".to_vec(),)],);@@ -211,13 +211,13 @@ fn cookies_with_longer_paths_are_sent_first_and_can_coexist() {jar.store_response_headers(&response_url,- &[("set-cookie".to_owned(), "mode=base; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"mode=base; Path=/app".to_vec())],);jar.store_response_headers(&response_url,&[("set-cookie".to_owned(),- "mode=deep; Path=/app/admin".to_owned(),+ b"mode=deep; Path=/app/admin".to_vec(),)],);@@ -239,7 +239,7 @@ fn request_cookie_header_reads_from_canonical_cookie_core() {&response_url,&[("set-cookie".to_owned(),- "sid=server; Path=/app; Secure".to_owned(),+ b"sid=server; Path=/app; Secure".to_vec(),)],);}@@ -1247,7 +1247,7 @@ fn request_cookie_header_includes_document_cookie_mutations() {&response_url,&[("set-cookie".to_owned(),- "sid=server; Path=/app; Secure".to_owned(),+ b"sid=server; Path=/app; Secure".to_vec(),)],);jar.set_document_cookie(&response_url, "sid=client; Path=/app");diff --git a/moli-fetch/src/tests/header_bytes.rs b/moli-fetch/src/tests/header_bytes.rsindex 0dd2b364b..a0a5aecba 100644--- a/moli-fetch/src/tests/header_bytes.rs+++ b/moli-fetch/src/tests/header_bytes.rs@@ -146,15 +146,12 @@ async fn http_header_bytes_survive_all_transports_and_observation() -> Result<()assert_eq!(body, [0, 255, 128], "{mode}");}let expected = [- ("x-bytes".to_owned(), value.clone()),- ("x-edges".to_owned(), "\u{a0}value\u{85}".to_owned()),- (- "x-utf8".to_owned(),- "\u{c3}\u{bf}\u{e4}\u{b8}\u{ad}".to_owned(),- ),- ("x-empty".to_owned(), String::new()),- ("x-repeat".to_owned(), "first".to_owned()),- ("x-repeat".to_owned(), "second".to_owned()),+ ("x-bytes".to_owned(), bytes.clone()),+ ("x-edges".to_owned(), b"\xa0value\x85".to_vec()),+ ("x-utf8".to_owned(), b"\xc3\xbf\xe4\xb8\xad".to_vec()),+ ("x-empty".to_owned(), Vec::new()),+ ("x-repeat".to_owned(), b"first".to_vec()),+ ("x-repeat".to_owned(), b"second".to_vec()),];assert_eq!(head.headers@@ -237,7 +234,7 @@ async fn http_header_bytes_survive_redirect_handle_reuse() -> Result<()> {assert!(head.redirected);assert_eq!(head.final_url.path(), "/final");assert_eq!(body, [0, 255, 128]);- assert!(head.headers.contains(&("x-bytes".into(), "\u{ff}".into())));+ assert!(head.headers.contains(&("x-bytes".into(), b"\xff".to_vec())));let requests = server.await??;assert_eq!(requests.len(), 2);for request in requests {@@ -276,7 +273,7 @@ async fn http_header_bytes_survive_disk_cache_reopen() -> Result<()> {assert_eq!(head.from_cache, index != 0, "{first_mode} to {mode}");assert!(head.headers- .contains(&("x-bytes".into(), "\u{a0}\u{c3}\u{bf}\u{85}".into()))+ .contains(&("x-bytes".into(), b"\xa0\xc3\xbf\x85".to_vec())));assert!(client.shutdown().is_clean());}diff --git a/moli-fetch/src/tests/mod.rs b/moli-fetch/src/tests/mod.rsindex 573a6d09a..bd94fb4b6 100644--- a/moli-fetch/src/tests/mod.rs+++ b/moli-fetch/src/tests/mod.rs@@ -65,7 +65,7 @@ fn sample_response_head() -> ResponseHead {ResponseHead {final_url: Url::parse("http://example.test/final").unwrap(),status: 203,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -595,7 +595,7 @@ async fn streaming_response_collector_ignores_interim_headers_before_final_startstarted.headers,vec![("content-type".to_owned(),- "text/html; charset=utf-8".to_owned()+ b"text/html; charset=utf-8".to_vec())]);Ok(())@@ -1024,10 +1024,9 @@ async fn fetch_raw_preserves_binary_body_bytes() -> Result<()> {assert_eq!(response.status, 200);assert!(- response- .headers- .iter()- .any(|(name, value)| { name == "content-type" && value == "application/octet-stream" })+ response.headers.iter().any(|(name, value)| {+ name == "content-type" && value == b"application/octet-stream"+ }));assert_eq!(response.body_bytes(), BODY);@@ -1079,7 +1078,7 @@ async fn fetch_raw_stream_yields_headers_before_delayed_body_and_preserves_bytesassert!(response.redirect_chain.is_empty());assert!(response.cookie_set_reports.is_empty());assert!(response.headers.iter().any(|(name, value)| {- name == "content-disposition" && value == "attachment; filename=\"streamed.bin\""+ name == "content-disposition" && value == b"attachment; filename=\"streamed.bin\""}));let mut body = Vec::new();@@ -1172,7 +1171,7 @@ async fn manual_http_redirect_to_file_remains_observable_without_being_followed(assert_eq!(response.status, 302);assert!(response.headers.iter().any(|(name, value)| {- name.eq_ignore_ascii_case("location") && value == "file:///moli-policy-must-not-open"+ name.eq_ignore_ascii_case("location") && value == b"file:///moli-policy-must-not-open"}));assert_eq!(server.hits(), 1);server.shutdown();@@ -1205,7 +1204,7 @@ async fn fetch_raw_stream_manual_redirect_returns_redirect_response() -> Result<assert!(response.redirect_chain.is_empty());assert!(response.headers.iter().any(|(name, value)| {- name.eq_ignore_ascii_case("location") && value == "/final.bin"+ name.eq_ignore_ascii_case("location") && value == b"/final.bin"}));@@ -2965,8 +2964,8 @@ fn critical_client_hints_restart_navigation_before_exposing_the_first_response().headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("location"))- .map(|(_, value)| value.as_str()),- Some(restart.to_url.as_str())+ .map(|(_, value)| value.as_slice()),+ Some(restart.to_url.as_str().as_bytes()));assert!(!restart.redirect_has_extra_info);assert!(restart.cookie_set_reports.is_empty());@@ -3997,7 +3996,7 @@ fn network_metadata_captures_transport_generated_request_headers() {.expect("raw response observation");assert_eq!(response.status(), 200);assert_eq!(- header_value(response.headers(), "Cache-Control"),+ moli_web_mime::response_header_value(response.headers(), "Cache-Control").as_deref(),Some("no-store"));@@ -4860,8 +4859,8 @@ fn fetch_client_cache_preserves_content_length_when_merging_304() {.headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("content-length"))- .map(|(_, value)| value.as_str()),- Some("5"),+ .map(|(_, value)| value.as_slice()),+ Some(b"5".as_slice()),"304 Content-Length must not replace the cached 200 Content-Length");@@ -4901,8 +4900,8 @@ fn fetch_client_cache_skips_connection_nominated_headers_when_merging_304() {.headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("x-transient"))- .map(|(_, value)| value.as_str()),- Some("cached-value"),+ .map(|(_, value)| value.as_slice()),+ Some(b"cached-value".as_slice()),"304 Connection-nominated fields must not replace cached metadata");@@ -5710,7 +5709,7 @@ fn assert_https_upgrade_redirect(redirect_chain: &[crate::RedirectInfo]) {assert_eq!(redirect.to_url.scheme(), "https");assert!(redirect.headers.iter().any(|(name, value)| {- name == "non-authoritative-reason" && value == "HttpsUpgrades"+ name == "non-authoritative-reason" && value == b"HttpsUpgrades"}));}diff --git a/moli-fetch/src/tests/request_security.rs b/moli-fetch/src/tests/request_security.rsindex 788610d4d..24158fbda 100644--- a/moli-fetch/src/tests/request_security.rs+++ b/moli-fetch/src/tests/request_security.rs@@ -43,7 +43,7 @@ fn synthetic_redirect(from: &Url, to: &Url) -> RedirectInfo {from_url: from.clone(),to_url: to.clone(),status: 302,- headers: vec![("Location".to_owned(), to.to_string())],+ headers: vec![("Location".to_owned(), to.as_str().as_bytes().to_vec())],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,diff --git a/moli-fetch/src/tests/tls_credentials.rs b/moli-fetch/src/tests/tls_credentials.rsindex 9f1477139..bc947e7a3 100644--- a/moli-fetch/src/tests/tls_credentials.rs+++ b/moli-fetch/src/tests/tls_credentials.rs@@ -500,7 +500,10 @@ async fn tls_client_certificate_preserves_service_worker_redirect_taint() -> Resfrom_url: cross_origin.clone(),to_url: server.url.clone(),status: 302,- headers: vec![("Location".to_owned(), server.url.to_string())],+ headers: vec![(+ "Location".to_owned(),+ server.url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,diff --git a/moli-header-field/Cargo.toml b/moli-header-field/Cargo.tomlindex f305e3016..78fc514e8 100644--- a/moli-header-field/Cargo.toml+++ b/moli-header-field/Cargo.toml@@ -5,7 +5,11 @@ version = "0.1.0"edition = "2024"[dependencies]+serde = { version = "1", features = ["derive"] }anyhow = "1.0.100"+[dev-dependencies]+serde_json = "1"+[lints]workspace = truediff --git a/moli-header-field/src/fields.rs b/moli-header-field/src/fields.rsindex 8cecdab8d..519f2bd7d 100644--- a/moli-header-field/src/fields.rs+++ b/moli-header-field/src/fields.rs@@ -1,5 +1,65 @@use anyhow::{Context, Result};+/// Decode HTTP bytes isomorphically, without treating valid UTF-8 sequences specially.+pub fn decode_header_value(value: &[u8]) -> std::borrow::Cow<'_, str> {+ if value.is_ascii() {+ std::borrow::Cow::Borrowed(std::str::from_utf8(value).expect("ASCII is valid UTF-8"))+ } else {+ std::borrow::Cow::Owned(value.iter().copied().map(char::from).collect())+ }+}++/// Project a raw header list onto a WebIDL ByteString or protocol text boundary.+pub fn headers_to_byte_strings(headers: &[(String, Vec<u8>)]) -> Vec<(String, String)> {+ headers+ .iter()+ .map(|(name, value)| (name.clone(), decode_header_value(value).into_owned()))+ .collect()+}++/// Recover raw bytes from a WebIDL ByteString header list.+pub fn headers_from_byte_strings(headers: &[(String, String)]) -> Result<Vec<(String, Vec<u8>)>> {+ headers+ .iter()+ .map(|(name, value)| Ok((name.clone(), header_value_from_byte_string(value)?)))+ .collect()+}++/// Recover HTTP value bytes from an isomorphic string, without UTF-8 encoding.+pub fn header_value_from_byte_string(value: &str) -> Result<Vec<u8>> {+ value+ .chars()+ .map(|ch| u8::try_from(u32::from(ch)))+ .collect::<std::result::Result<Vec<_>, _>>()+ .context("HTTP header ByteString contains a non-byte character")+}++/// Read persisted raw headers, including the legacy isomorphic string representation.+pub fn deserialize_headers<'de, D>(deserializer: D) -> Result<Vec<(String, Vec<u8>)>, D::Error>+where+ D: serde::Deserializer<'de>,+{+ use serde::Deserialize;+ #[derive(Deserialize)]+ #[serde(untagged)]+ enum Value {+ Bytes(Vec<u8>),+ ByteString(String),+ }+ Vec::<(String, Value)>::deserialize(deserializer)?+ .into_iter()+ .map(|(name, value)| {+ let bytes = match value {+ Value::Bytes(bytes) => bytes,+ Value::ByteString(value) => {+ header_value_from_byte_string(&value).map_err(serde::de::Error::custom)?+ }+ };+ Ok((name, bytes))+ })+ .collect()+}+/// Ordered HTTP field names and encoded values, including duplicate fields.////// Ordinary Rust strings use UTF-8. WebIDL ByteStrings must enter through@@ -33,31 +93,12 @@ impl HeaderFields {}pub fn from_byte_strings(headers: &[(String, String)]) -> Result<Self> {- headers- .iter()- .map(|(name, value)| {- let bytes = value- .chars()- .map(|ch| u8::try_from(u32::from(ch)))- .collect::<std::result::Result<Vec<_>, _>>()- .context("HTTP header ByteString contains a non-byte character")?;- Ok((name.clone(), bytes))- })- .collect::<Result<Vec<_>>>()- .map(Self)+ headers_from_byte_strings(headers).map(Self)}/// A lossless string projection for Fetch and network observation surfaces.pub fn to_byte_strings(&self) -> Vec<(String, String)> {- self.0- .iter()- .map(|(name, value)| {- (- name.clone(),- value.iter().copied().map(char::from).collect(),- )- })- .collect()+ headers_to_byte_strings(&self.0)}}@@ -103,6 +144,29 @@ impl std::ops::DerefMut for HeaderFields {mod tests {use super::*;+ #[test]+ fn persisted_headers_read_legacy_byte_strings_and_write_raw_bytes() {+ #[derive(Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq)]+ struct Record {+ #[serde(deserialize_with = "deserialize_headers")]+ headers: Vec<(String, Vec<u8>)>,+ }+ let legacy = r#"{"headers":[["X-Bytes","ÿ"],["X-Bytes","ÿ"],["X-Empty",""]]}"#;+ let record: Record = serde_json::from_str(legacy).unwrap();+ assert_eq!(+ record.headers,+ vec![+ ("X-Bytes".into(), vec![0xff]),+ ("X-Bytes".into(), vec![0xc3, 0xbf]),+ ("X-Empty".into(), vec![]),+ ]+ );+ let encoded = serde_json::to_value(&record).unwrap();+ assert_eq!(encoded["headers"][0][1], serde_json::json!([255]));+ assert_eq!(serde_json::from_value::<Record>(encoded).unwrap(), record);+ assert!(serde_json::from_str::<Record>(r#"{"headers":[["X-Invalid","中"]]}"#).is_err());+ }+#[test]fn string_encodings_are_explicit() {let headers = vec![("X-Test".into(), "é".into())];diff --git a/moli-header-field/src/lib.rs b/moli-header-field/src/lib.rsindex b3e7db5ca..115a1a45a 100644--- a/moli-header-field/src/lib.rs+++ b/moli-header-field/src/lib.rs@@ -14,7 +14,10 @@ mod fields;mod parameters;mod tokenizer;-pub use fields::HeaderFields;+pub use fields::{+ HeaderFields, decode_header_value, deserialize_headers, header_value_from_byte_string,+ headers_from_byte_strings, headers_to_byte_strings,+};pub use parameters::{split_outside_quoted_strings, unquote_parameter_value};pub use tokenizer::{HeaderFieldTokenMode, HeaderFieldTokenizer};diff --git a/moli-http-cache/src/metadata.rs b/moli-http-cache/src/metadata.rsindex d72f43f44..998b6de69 100644--- a/moli-http-cache/src/metadata.rs+++ b/moli-http-cache/src/metadata.rs@@ -11,7 +11,7 @@ use typed_num::Num;use crate::{path_safety::safe_body_file_name, time::unique_suffix};pub(crate) const META_FILE: &str = "meta.json";-pub(crate) type HttpCacheFormatVersion = Num<3>;+pub(crate) type HttpCacheFormatVersion = Num<4>;/// Request header value captured for a `Vary` response header.#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]@@ -27,7 +27,7 @@ pub struct HttpCacheEntryMetadata {pub request_url: String,pub final_url: String,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub stored_at_unix_ms: u64,pub last_used_at_unix_ms: u64,pub expires_at_unix_ms: Option<u64>,@@ -41,7 +41,7 @@ impl HttpCacheEntryMetadata {request_url: String,final_url: String,status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,stored_at_unix_ms: u64,expires_at_unix_ms: Option<u64>,vary_headers: Vec<HttpCacheVaryHeader>,diff --git a/moli-http-cache/src/policy.rs b/moli-http-cache/src/policy.rsindex bcf027e08..dd1afb240 100644--- a/moli-http-cache/src/policy.rs+++ b/moli-http-cache/src/policy.rs@@ -11,7 +11,7 @@ pub struct HttpCacheResponsePolicy {/// Parses the subset of HTTP response cache policy currently enforced by/// Moli's conservative disk cache.-pub fn response_cache_policy(headers: &[(String, String)]) -> HttpCacheResponsePolicy {+pub fn response_cache_policy(headers: &[(String, Vec<u8>)]) -> HttpCacheResponsePolicy {let mut store = true;let mut requires_validation = false;let mut max_age_seconds = None;@@ -20,11 +20,12 @@ pub fn response_cache_policy(headers: &[(String, String)]) -> HttpCacheResponsePlet mut age_seconds = 0u64;for (name, value) in headers {+ let value = moli_header_field::decode_header_value(value);if name.eq_ignore_ascii_case("cache-control") {// A quoted directive argument may contain `,`, as in// `private="Set-Cookie, X-Auth"`, so splitting on every comma// would read the argument's own text as further directives.- for directive in split_outside_quoted_strings(value, ',')+ for directive in split_outside_quoted_strings(&value, ',').into_iter().map(str::trim){@@ -56,12 +57,12 @@ pub fn response_cache_policy(headers: &[(String, String)]) -> HttpCacheResponsePstore = false;}} else if name.eq_ignore_ascii_case("expires")- && let Ok(expires_at) = parse_http_date(value)+ && let Ok(expires_at) = parse_http_date(&value)&& let Ok(duration) = expires_at.duration_since(std::time::UNIX_EPOCH){expires_header_unix_ms = Some(duration.as_millis() as u64);} else if name.eq_ignore_ascii_case("date")- && let Ok(date) = parse_http_date(value)+ && let Ok(date) = parse_http_date(&value)&& let Ok(duration) = date.duration_since(std::time::UNIX_EPOCH){date_unix_ms = Some(duration.as_millis() as u64);@@ -98,7 +99,7 @@ pub fn cacheable_response_parts_policy(request_url: &Url,final_url: &Url,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirected: bool,) -> Option<HttpCacheResponsePolicy> {if !cacheable_response_status(status)@@ -132,7 +133,7 @@ fn cached_response_is_stale_at(}pub fn cached_response_is_fresh_immutable(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],expires_at_unix_ms: Option<u64>,) -> bool {cached_response_is_fresh_immutable_at(unix_now_ms(), headers, expires_at_unix_ms)@@ -140,9 +141,10 @@ pub fn cached_response_is_fresh_immutable(fn cached_response_is_fresh_immutable_at(now_ms: u64,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],expires_at_unix_ms: Option<u64>,) -> bool {+ let headers = moli_header_field::headers_to_byte_strings(headers);expires_at_unix_ms.is_some_and(|expires_at| now_ms < expires_at)&& headers.iter()@@ -222,9 +224,9 @@ mod tests {#[test]fn freshness_requires_expiration_to_be_strictly_after_now() {- let immutable_headers = vec![(+ let immutable_headers: Vec<(String, Vec<u8>)> = vec![("cache-control".to_owned(),- "max-age=60, immutable".to_owned(),+ b"max-age=60, immutable".to_vec(),)];assert!(!cached_response_is_stale_at(99, Some(100), false));@@ -262,9 +264,9 @@ mod tests {#[test]fn response_policy_ignores_directives_inside_a_quoted_argument() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Cache-Control".to_owned(),- "max-age=600, community=\"x, no-store, y\"".to_owned(),+ b"max-age=600, community=\"x, no-store, y\"".to_vec(),)];assert!(response_cache_policy(&headers).store);@@ -278,12 +280,13 @@ mod tests {"max-age=0, no-store","no-store, max-age=600",] {- let headers = vec![("Cache-Control".to_owned(), value.to_owned())];+ let headers: Vec<(String, Vec<u8>)> =+ vec![("Cache-Control".to_owned(), value.as_bytes().to_vec())];assert!(!response_cache_policy(&headers).store, "value={value}");}- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Cache-Control".to_owned(),- "private=\"Set-Cookie\"".to_owned(),+ b"private=\"Set-Cookie\"".to_vec(),)];assert!(!response_cache_policy(&headers).store);}@@ -299,10 +302,8 @@ mod tests {#[test]fn a_trailing_backslash_does_not_manufacture_a_freshness_lifetime() {// `31536000\` is malformed and must not parse as one year.- let headers = vec![(- "Cache-Control".to_owned(),- "max-age=\"31536000\\".to_owned(),- )];+ let headers: Vec<(String, Vec<u8>)> =+ vec![("Cache-Control".to_owned(), b"max-age=\"31536000\\".to_vec())];assert_eq!(response_cache_policy(&headers).expires_at_unix_ms, None);}diff --git a/moli-http-cache/src/revalidation.rs b/moli-http-cache/src/revalidation.rsindex 62de3707e..f87ac1f7b 100644--- a/moli-http-cache/src/revalidation.rs+++ b/moli-http-cache/src/revalidation.rs@@ -1,7 +1,7 @@/// Builds conditional request headers from cached response validators.pub fn validation_headers_from_headers(- record_headers: &[(String, String)],-) -> Vec<(String, String)> {+ record_headers: &[(String, Vec<u8>)],+) -> Vec<(String, Vec<u8>)> {let mut headers = Vec::new();if let Some((_, etag)) = record_headers.iter().find(|(name, _)| name == "etag") {headers.push(("If-None-Match".to_owned(), etag.clone()));@@ -18,9 +18,9 @@ pub fn validation_headers_from_headers(/// Merges 304 response metadata into cached headers while preserving the/// cached representation body.pub fn merge_not_modified_headers(- cached_headers: &[(String, String)],- not_modified_headers: &[(String, String)],-) -> Vec<(String, String)> {+ cached_headers: &[(String, Vec<u8>)],+ not_modified_headers: &[(String, Vec<u8>)],+) -> Vec<(String, Vec<u8>)> {let mut headers = cached_headers.to_vec();let connection_nominated_headers = connection_nominated_header_names(not_modified_headers);for (name, value) in not_modified_headers {@@ -58,7 +58,8 @@ fn should_skip_not_modified_header(name: &str, connection_nominated_headers: &[S)}-fn connection_nominated_header_names(headers: &[(String, String)]) -> Vec<String> {+fn connection_nominated_header_names(headers: &[(String, Vec<u8>)]) -> Vec<String> {+ let headers = moli_header_field::headers_to_byte_strings(headers);// Connection can name extra hop-by-hop fields; a 304 must not promote// those transient fields into cached representation metadata.headersdiff --git a/moli-http-cache/src/tests.rs b/moli-http-cache/src/tests.rsindex 71af8715f..461a4a042 100644--- a/moli-http-cache/src/tests.rs+++ b/moli-http-cache/src/tests.rs@@ -23,7 +23,7 @@ fn temp_root(name: &str) -> PathBuf {fn test_metadata(url: &str,status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,stored_at_unix_ms: u64,expires_at_unix_ms: Option<u64>,) -> HttpCacheEntryMetadata {@@ -87,11 +87,11 @@ fn request_pragma_validation_only_honors_no_cache() {#[test]fn response_vary_header_names_merges_all_header_fields() {- let headers = vec![- ("Vary".to_owned(), "Accept-Encoding, User-Agent".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Vary".to_owned(), b"Accept-Encoding, User-Agent".to_vec()),("vary".to_owned(),- "accept-encoding, Accept-Language".to_owned(),+ b"accept-encoding, Accept-Language".to_vec(),),];@@ -107,7 +107,7 @@ fn response_vary_header_names_merges_all_header_fields() {#[test]fn response_vary_header_names_rejects_wildcard() {- let headers = vec![("Vary".to_owned(), "Accept-Encoding, *".to_owned())];+ let headers: Vec<(String, Vec<u8>)> = vec![("Vary".to_owned(), b"Accept-Encoding, *".to_vec())];assert_eq!(response_vary_header_names(&headers), None);}@@ -128,7 +128,7 @@ fn cacheable_response_parts_policy_rejects_unsafe_response_parts() -> Result<()>&request_url,&request_url,200,- &[("set-cookie".to_owned(), "sid=1".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1".to_vec())],false).is_none()@@ -138,7 +138,7 @@ fn cacheable_response_parts_policy_rejects_unsafe_response_parts() -> Result<()>&request_url,&request_url,200,- &[("cache-control".to_owned(), "no-store".to_owned())],+ &[("cache-control".to_owned(), b"no-store".to_vec())],false).is_none()@@ -149,21 +149,21 @@ fn cacheable_response_parts_policy_rejects_unsafe_response_parts() -> Result<()>#[test]fn validation_headers_use_cached_validators() {- let headers = vec![- ("etag".to_owned(), "\"v1\"".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("etag".to_owned(), b"\"v1\"".to_vec()),("last-modified".to_owned(),- "Wed, 21 Oct 2015 07:28:00 GMT".to_owned(),+ b"Wed, 21 Oct 2015 07:28:00 GMT".to_vec(),),];assert_eq!(validation_headers_from_headers(&headers),vec![- ("If-None-Match".to_owned(), "\"v1\"".to_owned()),+ ("If-None-Match".to_owned(), b"\"v1\"".to_vec()),("If-Modified-Since".to_owned(),- "Wed, 21 Oct 2015 07:28:00 GMT".to_owned()+ b"Wed, 21 Oct 2015 07:28:00 GMT".to_vec())]);@@ -172,23 +172,23 @@ fn validation_headers_use_cached_validators() {#[test]fn not_modified_merge_skips_hop_by_hop_and_connection_nominated_headers() {let cached = vec![- ("cache-control".to_owned(), "max-age=60".to_owned()),- ("x-old".to_owned(), "old".to_owned()),+ ("cache-control".to_owned(), b"max-age=60".to_vec()),+ ("x-old".to_owned(), b"old".to_vec()),];let not_modified = vec![- ("cache-control".to_owned(), "max-age=120".to_owned()),- ("connection".to_owned(), "x-transient".to_owned()),- ("x-transient".to_owned(), "drop".to_owned()),- ("content-length".to_owned(), "0".to_owned()),- ("etag".to_owned(), "\"v2\"".to_owned()),+ ("cache-control".to_owned(), b"max-age=120".to_vec()),+ ("connection".to_owned(), b"x-transient".to_vec()),+ ("x-transient".to_owned(), b"drop".to_vec()),+ ("content-length".to_owned(), b"0".to_vec()),+ ("etag".to_owned(), b"\"v2\"".to_vec()),];assert_eq!(merge_not_modified_headers(&cached, ¬_modified),vec![- ("cache-control".to_owned(), "max-age=120".to_owned()),- ("x-old".to_owned(), "old".to_owned()),- ("etag".to_owned(), "\"v2\"".to_owned())+ ("cache-control".to_owned(), b"max-age=120".to_vec()),+ ("x-old".to_owned(), b"old".to_vec()),+ ("etag".to_owned(), b"\"v2\"".to_vec())]);}@@ -198,6 +198,12 @@ fn streaming_writer_publishes_metadata_after_body() -> Result<()> {let root = temp_root("publish");let store = HttpCacheStore::new(&root);let key = HttpCacheStore::key_for_url("http://example.test/cache");+ let headers = vec![+ ("cache-control".to_owned(), b"max-age=60".to_vec()),+ ("x-bytes".to_owned(), b"\xff\x80\xa0".to_vec()),+ ("x-bytes".to_owned(), b"\xc3\xbf".to_vec()),+ ("x-empty".to_owned(), Vec::new()),+ ];let mut writer = store.create_body_writer(&key)?;writer.write_all(b"hello ")?;@@ -205,13 +211,14 @@ fn streaming_writer_publishes_metadata_after_body() -> Result<()> {writer.finish(test_metadata("http://example.test/cache",200,- vec![("cache-control".to_owned(), "max-age=60".to_owned())],+ headers.clone(),1,Some(2),))?;let cached = load_test_entry(&store, &key)?.expect("entry should be readable");assert_eq!(cached.metadata.status, 200);+ assert_eq!(cached.metadata.headers, headers);assert_eq!(cached.body, b"hello cache");let _ = fs::remove_dir_all(root);@@ -389,8 +396,8 @@ fn refresh_loaded_entry_metadata_preserves_cached_body() -> Result<()> {"http://example.test/cache",200,vec![- ("cache-control".to_owned(), "max-age=0".to_owned()),- ("etag".to_owned(), "\"v1\"".to_owned()),+ ("cache-control".to_owned(), b"max-age=0".to_vec()),+ ("etag".to_owned(), b"\"v1\"".to_vec()),],1,Some(2),@@ -400,8 +407,8 @@ fn refresh_loaded_entry_metadata_preserves_cached_body() -> Result<()> {let mut loaded = store.load_reader(&key)?.expect("entry should be readable");loaded.metadata.headers = vec![- ("cache-control".to_owned(), "max-age=60".to_owned()),- ("etag".to_owned(), "\"v1\"".to_owned()),+ ("cache-control".to_owned(), b"max-age=60".to_vec()),+ ("etag".to_owned(), b"\"v1\"".to_vec()),];loaded.metadata.stored_at_unix_ms = 3;loaded.metadata.last_used_at_unix_ms = 3;@@ -413,8 +420,8 @@ fn refresh_loaded_entry_metadata_preserves_cached_body() -> Result<()> {assert_eq!(cached.metadata.headers,vec![- ("cache-control".to_owned(), "max-age=60".to_owned()),- ("etag".to_owned(), "\"v1\"".to_owned()),+ ("cache-control".to_owned(), b"max-age=60".to_vec()),+ ("etag".to_owned(), b"\"v1\"".to_vec()),]);assert_eq!(cached.metadata.expires_at_unix_ms, Some(63));diff --git a/moli-http-cache/src/vary.rs b/moli-http-cache/src/vary.rsindex 555657bf7..379ce631e 100644--- a/moli-http-cache/src/vary.rs+++ b/moli-http-cache/src/vary.rs@@ -3,7 +3,8 @@ use rustc_hash::FxHashSet;/// Parses all Vary response header fields into normalized field names.////// Returns `None` for `Vary: *`, which cannot be safely matched by this cache.-pub fn response_vary_header_names(headers: &[(String, String)]) -> Option<Vec<String>> {+pub fn response_vary_header_names(headers: &[(String, Vec<u8>)]) -> Option<Vec<String>> {+ let headers = moli_header_field::headers_to_byte_strings(headers);let mut seen = FxHashSet::default();let mut out = Vec::new();for raw_name in headersdiff --git a/moli-page-types/src/lib.rs b/moli-page-types/src/lib.rsindex a94496da8..035c47e11 100644--- a/moli-page-types/src/lib.rs+++ b/moli-page-types/src/lib.rs@@ -253,7 +253,7 @@ pub struct NavigationRedirect {pub from_url: Url,pub to_url: Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub network_extra_info_available: bool,pub request_extra_info: Option<NetworkRequestExtraInfo>,pub response_extra_info: Option<NetworkResponseExtraInfo>,@@ -308,7 +308,7 @@ impl From<NavigationRedirect> for RedirectInfo {pub struct NavigationResponse {pub final_url: Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,body: ResponseBody,pub request_cookie_report: Option<StoredCookieQueryReport>,pub cookie_set_reports: Vec<StoredCookieSetReport>,@@ -446,7 +446,7 @@ impl NavigationResponse {pub fn from_text_body(final_url: Url,status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,body: String,) -> Self {Self::from_head_and_text_body(@@ -468,7 +468,7 @@ impl NavigationResponse {pub fn with_status_headers_from(source: &Self,status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,) -> Self {let mut head = source.head();head.status = status;@@ -1121,7 +1121,7 @@ pub struct SubresourceResponseStarted {final_url: Url,status: u16,status_text: Option<String>,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,cookie_set_reports: Vec<StoredCookieSetReport>,from_cache: bool,network_request_headers: Option<Vec<(String, String)>>,@@ -1282,7 +1282,7 @@ impl SubresourceResponseStarted {redirect_chain: Vec<NavigationRedirect>,final_url: Url,status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,cookie_set_reports: Vec<StoredCookieSetReport>,) -> Self {Self {@@ -1345,7 +1345,7 @@ impl SubresourceResponseStarted {self.status_text.as_deref()}- pub fn response_headers(&self) -> &[(String, String)] {+ pub fn response_headers(&self) -> &[(String, Vec<u8>)] {&self.response_headers}@@ -1966,7 +1966,7 @@ pub struct SubresourceJsonPathRegex {}fn json_path_equals(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body: &str,expectation: &SubresourceJsonPathEquals,) -> bool {@@ -1976,7 +1976,7 @@ fn json_path_equals(}fn json_path_matches_regex(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body: &str,expectation: &SubresourceJsonPathRegex,) -> bool {@@ -1986,7 +1986,7 @@ fn json_path_matches_regex(}fn json_path_satisfies(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body: &str,path: &[String],predicate: impl FnOnce(&Value) -> bool,@@ -1994,7 +1994,7 @@ fn json_path_satisfies(let Some(content_type) = header_value(headers, "content-type") else {return false;};- if !is_json_module_mime(content_type) {+ if !is_json_module_mime(&content_type) {return false;}@@ -2038,11 +2038,14 @@ fn json_value_matches_regex(value: &Value, regex: &Regex) -> bool {}}-fn header_value<'a>(headers: &'a [(String, String)], name: &str) -> Option<&'a str> {+fn header_value<'a>(+ headers: &'a [(String, Vec<u8>)],+ name: &str,+) -> Option<std::borrow::Cow<'a, str>> {headers.iter().find(|(header_name, _)| header_name.eq_ignore_ascii_case(name))- .map(|(_, value)| value.as_str())+ .map(|(_, value)| moli_fetch::decode_header_value(value))}impl SubresourceNetworkRecord {@@ -2132,7 +2135,7 @@ impl SubresourceNetworkRecord {redirect_chain: Vec<NavigationRedirect>,final_url: Url,status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,cookie_set_reports: Vec<StoredCookieSetReport>,) -> Self {@@ -2166,7 +2169,7 @@ impl SubresourceNetworkRecord {redirect_chain: Vec<NavigationRedirect>,final_url: Url,status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: SubresourceResponseBody,cookie_set_reports: Vec<StoredCookieSetReport>,) -> Self {@@ -2413,7 +2416,7 @@ pub struct PendingSubresourceResponseInfo {pub request_cookie_report: Option<StoredCookieQueryReport>,pub network_request_headers: Option<Vec<(String, String)>>,pub response_status: u16,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,/// Exact response bytes plus the lossy compatibility text view needed while/// a response-stage Fetch pause is held.pub response_body: SubresourceResponseBody,@@ -2434,7 +2437,7 @@ pub struct PendingSubresourceAuthInfo {pub intercept_response: bool,pub response_final_url: Url,pub response_status: u16,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,pub response_body: SubresourceResponseBody,pub response_from_cache: bool,}@@ -2470,19 +2473,19 @@ pub struct SubresourceAuthCredentials {}pub fn extract_subresource_auth_challenge(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Option<SubresourceAuthChallenge> {let mut first_challenge = None;for (source, value) in headers.iter().filter_map(|(name, value)| {if name.eq_ignore_ascii_case("www-authenticate") {- Some(("Server", value.as_str()))+ Some(("Server", moli_fetch::decode_header_value(value)))} else if name.eq_ignore_ascii_case("proxy-authenticate") {- Some(("Proxy", value.as_str()))+ Some(("Proxy", moli_fetch::decode_header_value(value)))} else {None}}) {- for candidate in parse_auth_challenge_candidates(value) {+ for candidate in parse_auth_challenge_candidates(&value) {let challenge = SubresourceAuthChallenge {source: source.to_owned(),scheme: candidate.scheme,@@ -2733,7 +2736,7 @@ pub enum SubresourceNetworkOutcome {final_url: Url,status: u16,status_text: Option<String>,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: SubresourceResponseBody,},Failure {@@ -3285,7 +3288,7 @@ pub struct ChildFrameDocumentNetworkSnapshot {pub final_url: String,pub status: u16,#[serde(default)]- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,#[serde(default)]pub encoded_data_length: usize,/// Exact in-process response body source for protocol consumers.@@ -3869,7 +3872,7 @@ mod tests {Vec::new(),test_url("/image.png"),200,- vec![("content-type".to_owned(), "image/png".to_owned())],+ vec![("content-type".to_owned(), b"image/png".to_vec())],Vec::new(),);let body = SubresourceBodyFinished::ready(@@ -4046,7 +4049,7 @@ mod tests {ResponseHead {final_url: test_url("/image.png"),status: 200,- headers: vec![("Content-Type".to_owned(), "image/png".to_owned())],+ headers: vec![("Content-Type".to_owned(), b"image/png".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -4208,7 +4211,7 @@ mod tests {Vec::new(),Url::parse("https://example.test/api").unwrap(),200,- vec![("content-type".to_owned(), "text/plain".to_owned())],+ vec![("content-type".to_owned(), b"text/plain".to_vec())],body,Vec::new(),);@@ -4278,7 +4281,7 @@ mod tests {Vec::new(),Url::parse("https://example.test/api").unwrap(),200,- vec![("content-type".to_owned(), "text/plain".to_owned())],+ vec![("content-type".to_owned(), b"text/plain".to_vec())],SubresourceResponseBody::from_bytes(b"order #42 ready".to_vec()),Vec::new(),);@@ -4325,7 +4328,7 @@ mod tests {assert!(json_path_equals(&[("content-type".to_owned(),- "application/manifest+json;charset=utf-8".to_owned(),+ b"application/manifest+json;charset=utf-8".to_vec(),)],r#"{"ok":true}"#,&expectation,@@ -4333,13 +4336,13 @@ mod tests {assert!(json_path_equals(&[("content-type".to_owned(),- "application/json; charset = utf-8".to_owned(),+ b"application/json; charset = utf-8".to_vec(),)],r#"{"ok":true}"#,&expectation,));assert!(!json_path_equals(- &[("content-type".to_owned(), "text/json".to_owned())],+ &[("content-type".to_owned(), b"text/json".to_vec())],r#"{"ok":true}"#,&expectation,));@@ -4351,13 +4354,13 @@ mod tests {assert!(json_path_matches_regex(&[("content-type".to_owned(),- "application/json; charset=utf-8".to_owned(),+ b"application/json; charset=utf-8".to_vec(),)],r#"{"data":{"url":"/item/42"}}"#,®ex_expectation,));assert!(!json_path_matches_regex(- &[("content-type".to_owned(), "application/json".to_owned())],+ &[("content-type".to_owned(), b"application/json".to_vec())],r#"{"data":{"url":"/orders/42"}}"#,®ex_expectation,));@@ -4476,11 +4479,11 @@ mod tests {let challenge = extract_subresource_auth_challenge(&[("www-authenticate".to_owned(),- "Bearer realm=\"token-area\"".to_owned(),+ b"Bearer realm=\"token-area\"".to_vec(),),("www-authenticate".to_owned(),- "Basic realm=\"basic-area\"".to_owned(),+ b"Basic realm=\"basic-area\"".to_vec(),),]).expect("auth challenge");@@ -4494,7 +4497,7 @@ mod tests {fn auth_challenge_parser_prefers_supported_scheme_from_combined_header() {let challenge = extract_subresource_auth_challenge(&[("www-authenticate".to_owned(),- "Bearer realm=\"token-area\", Basic realm=\"basic-area\"".to_owned(),+ b"Bearer realm=\"token-area\", Basic realm=\"basic-area\"".to_vec(),)]).expect("auth challenge");@@ -4507,7 +4510,7 @@ mod tests {fn auth_challenge_parser_preserves_quoted_commas_and_escaped_quotes() {let challenge = extract_subresource_auth_challenge(&[("www-authenticate".to_owned(),- r#"Digest realm="area, with \"quote\"", nonce="deadbeef", qop="auth""#.to_owned(),+ br#"Digest realm="area, with \"quote\"", nonce="deadbeef", qop="auth""#.to_vec(),)]).expect("auth challenge");@@ -4520,7 +4523,7 @@ mod tests {fn auth_challenge_parser_recognizes_proxy_and_falls_back_to_unsupported() {let challenge = extract_subresource_auth_challenge(&[("proxy-authenticate".to_owned(),- "Bearer realm=\"proxy-token\"".to_owned(),+ b"Bearer realm=\"proxy-token\"".to_vec(),)]).expect("proxy auth challenge");diff --git a/moli-page-types/src/renderer_transport_memory.rs b/moli-page-types/src/renderer_transport_memory.rsindex 9454b067e..8b0fb0a02 100644--- a/moli-page-types/src/renderer_transport_memory.rs+++ b/moli-page-types/src/renderer_transport_memory.rs@@ -251,15 +251,15 @@ fn request_headers_charge(headers: &moli_fetch::RequestHeaders) -> usize {)}-fn headers_charge(headers: &[(String, String)]) -> usize {+fn headers_charge<V: AsRef<[u8]>>(headers: &[(String, V)]) -> usize {headers.iter().fold(headers.len()- .saturating_mul(std::mem::size_of::<(String, String)>()),+ .saturating_mul(std::mem::size_of::<(String, V)>()),|total, (name, value)| {total.saturating_add(string_charge(name))- .saturating_add(string_charge(value))+ .saturating_add(value.as_ref().len().saturating_mul(2))},)}diff --git a/moli-protocol-webdriver-bidi/src/commands.rs b/moli-protocol-webdriver-bidi/src/commands.rsindex f1d0a56c8..04fad4340 100644--- a/moli-protocol-webdriver-bidi/src/commands.rs+++ b/moli-protocol-webdriver-bidi/src/commands.rs@@ -1049,7 +1049,7 @@ fn bidi_network_continue_response_command(context: context.command_context(None),request_id: DevToolsRequestId::from(request),response_code: optional_network_status_code(&command.params)?,- response_headers: response_headers.map(|headers| headers.to_byte_strings()),+ response_headers: response_headers.map(|headers| headers.into_iter().collect()),response_phrase: optional_string(&command.params, "reasonPhrase")?.map(str::to_owned),auth_credentials: optional_network_auth_credentials(&command.params)?,})@@ -1142,7 +1142,7 @@ fn bidi_network_provide_response_command(context: context.command_context(None),request_id: DevToolsRequestId::from(request),response_code: optional_network_status_code(&command.params)?.unwrap_or(200),- response_headers: headers.to_byte_strings(),+ response_headers: headers.into_iter().collect(),body: optional_network_bytes(&command.params, "body")?,response_phrase: optional_string(&command.params, "reasonPhrase")?.map(str::to_owned),})diff --git a/moli-protocol-webdriver-bidi/src/network.rs b/moli-protocol-webdriver-bidi/src/network.rsindex ae7990b6c..aeeb55c7d 100644--- a/moli-protocol-webdriver-bidi/src/network.rs+++ b/moli-protocol-webdriver-bidi/src/network.rs@@ -507,18 +507,23 @@ fn network_request_event_cdp_params(event: &NetworkRequestEvent, method: &str) -}}-fn json_object_from_header_pairs(headers: &[(String, String)]) -> serde_json::Map<String, Value> {+fn json_object_from_header_pairs(headers: &[(String, Vec<u8>)]) -> serde_json::Map<String, Value> {headers.iter()- .map(|(name, value)| (name.clone(), json!(value)))+ .map(|(name, value)| {+ (+ name.clone(),+ json!(moli_header_field::decode_header_value(value)),+ )+ }).collect()}-fn response_header_value(headers: &[(String, String)], name: &str) -> Option<String> {+fn response_header_value(headers: &[(String, Vec<u8>)], name: &str) -> Option<String> {headers.iter().find(|(header_name, _)| header_name.eq_ignore_ascii_case(name))- .map(|(_, value)| value.clone())+ .map(|(_, value)| moli_header_field::decode_header_value(value).into_owned())}fn response_protocol_for_url(url: &str) -> String {diff --git a/moli-protocol-webdriver-bidi/src/tests.rs b/moli-protocol-webdriver-bidi/src/tests.rsindex 602f52616..ced7fcad4 100644--- a/moli-protocol-webdriver-bidi/src/tests.rs+++ b/moli-protocol-webdriver-bidi/src/tests.rs@@ -9093,14 +9093,10 @@ fn bidi_cookie_overrides_preserve_opaque_and_utf8_bytes() {let headers = match shared {DevToolsCommand::ContinueInterceptedRequest(command) => command.headers.unwrap(),DevToolsCommand::ContinueInterceptedResponse(command) => {- moli_header_field::HeaderFields::from_byte_strings(- &command.response_headers.unwrap(),- )- .unwrap()+ moli_header_field::HeaderFields::from_bytes(command.response_headers.unwrap())}DevToolsCommand::FulfillInterceptedRequest(command) => {- moli_header_field::HeaderFields::from_byte_strings(&command.response_headers)- .unwrap()+ moli_header_field::HeaderFields::from_bytes(command.response_headers)}_ => panic!("unexpected cookie dispatch"),};@@ -9215,11 +9211,8 @@ fn maps_network_response_controls_to_shared_fetch_commands() {assert_eq!(command.response_headers,Some(vec![- ("X-Response".to_owned(), "ok".to_owned()),- (- "Set-Cookie".to_owned(),- "rid=1; Path=/; HttpOnly".to_owned()- ),+ ("X-Response".to_owned(), b"ok".to_vec()),+ ("Set-Cookie".to_owned(), b"rid=1; Path=/; HttpOnly".to_vec()),]));diff --git a/moli-protocol/src/conn/browser_context/page_owner.rs b/moli-protocol/src/conn/browser_context/page_owner.rsindex 62e782a0e..751720d4b 100644--- a/moli-protocol/src/conn/browser_context/page_owner.rs+++ b/moli-protocol/src/conn/browser_context/page_owner.rs@@ -541,7 +541,7 @@ impl CdpConnection {frame_id: String,loader_id: String,url: url::Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,from_cache: bool,body: crate::conn::CapturedBody,) -> bool {@@ -564,7 +564,7 @@ impl CdpConnection {frame_id: String,loader_id: String,url: url::Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,from_cache: bool,body: Option<crate::conn::CapturedBody>,) -> bool {diff --git a/moli-protocol/src/conn/browser_context/target_session_owner.rs b/moli-protocol/src/conn/browser_context/target_session_owner.rsindex 349025927..7caf312c4 100644--- a/moli-protocol/src/conn/browser_context/target_session_owner.rs+++ b/moli-protocol/src/conn/browser_context/target_session_owner.rs@@ -212,7 +212,7 @@ impl TargetNavigationLoadInputs {pub(crate) fn store_response_cookie_reports(&self,response_url: &Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> Vec<StoredCookieSetReport> {let mut cookie_store = self.storage_handles.page_handles.cookie_store.lock();cookie_store.store_response_headers_with_reports(response_url, response_headers)diff --git a/moli-protocol/src/conn/downloads.rs b/moli-protocol/src/conn/downloads.rsindex 6728c3696..b27baf96e 100644--- a/moli-protocol/src/conn/downloads.rs+++ b/moli-protocol/src/conn/downloads.rs@@ -180,7 +180,7 @@ struct PreparedDownloadActivation {struct PreparedNavigationDownload {frame_id: String,response_url: Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: CompletedDownloadBody,download_root: String,guid: String,@@ -1347,23 +1347,30 @@ fn partial_artifact_path(artifact_path: &Path) -> PathBuf {artifact_path.with_file_name(format!("{file_name}.crdownload"))}-fn content_length_from_headers(headers: &[(String, String)]) -> Option<u64> {+fn content_length_from_headers(headers: &[(String, Vec<u8>)]) -> Option<u64> {headers.iter().find(|(name, _)| header_name_is(name, &HeaderName::from_static("content-length")))- .and_then(|(_, value)| value.trim().parse::<u64>().ok())+ .and_then(|(_, value)| {+ moli_fetch::decode_header_value(value)+ .trim()+ .parse::<u64>()+ .ok()+ })}-pub(crate) fn response_headers_indicate_download(headers: &[(String, String)]) -> bool {+pub(crate) fn response_headers_indicate_download(headers: &[(String, Vec<u8>)]) -> bool {response_headers_indicate_attachment_download(headers)}-fn filename_from_headers(headers: &[(String, String)]) -> Option<String> {+fn filename_from_headers(headers: &[(String, Vec<u8>)]) -> Option<String> {for (name, value) in headers {if !header_name_is(name, &HeaderName::from_static("content-disposition")) {continue;}- if let Some(filename) = filename_from_content_disposition(value) {+ if let Some(filename) =+ filename_from_content_disposition(&moli_fetch::decode_header_value(value))+ {return Some(filename);}}@@ -1915,11 +1922,11 @@ mod tests {#[test]fn content_length_from_headers_parses_case_insensitive_header_name() {assert_eq!(- content_length_from_headers(&[("Content-Length".to_owned(), "42".to_owned())]),+ content_length_from_headers(&[("Content-Length".to_owned(), b"42".to_vec())]),Some(42));assert_eq!(- content_length_from_headers(&[("content-length".to_owned(), "bad".to_owned())]),+ content_length_from_headers(&[("content-length".to_owned(), b"bad".to_vec())]),None);}@@ -1978,11 +1985,11 @@ mod tests {fn response_headers_indicate_download_uses_web_mime_attachment_helper() {assert!(response_headers_indicate_download(&[("Content-Disposition".to_owned(),- "attachment; filename=\"report.txt\"".to_owned(),+ b"attachment; filename=\"report.txt\"".to_vec(),)]));assert!(!response_headers_indicate_download(&[("Content-Disposition".to_owned(),- "inline; filename=\"report.txt\"".to_owned(),+ b"inline; filename=\"report.txt\"".to_vec(),)]));}diff --git a/moli-protocol/src/conn/fetch_support.rs b/moli-protocol/src/conn/fetch_support.rsindex 88a2366bd..9bc66e029 100644--- a/moli-protocol/src/conn/fetch_support.rs+++ b/moli-protocol/src/conn/fetch_support.rs@@ -488,7 +488,7 @@ impl PendingFetchAuthNavigation {status: 401,headers: vec![("WWW-Authenticate".to_owned(),- "Basic realm=\"test\"".to_owned(),+ b"Basic realm=\"test\"".to_vec(),)],request_cookie_report: None,cookie_set_reports: Vec::new(),@@ -1157,7 +1157,7 @@ impl PausedDocumentTransfer {self,conn: &mut CdpConnection,response_code: Option<u16>,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,) -> Result<(Option<DocumentNavigationToken>,@@ -1189,7 +1189,7 @@ impl PausedDocumentTransfer {self,conn: &mut CdpConnection,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,synthetic_body: CapturedBody,) -> (Option<DocumentNavigationToken>,@@ -1327,7 +1327,7 @@ impl ActiveDocumentBodyStreamState {self,conn: &mut CdpConnection,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,synthetic_body: CapturedBody,) -> (Option<DocumentNavigationToken>,@@ -1515,7 +1515,7 @@ impl DocumentBodySource {conn: &mut CdpConnection,navigation: &NavigationDispatchState,response_code: Option<u16>,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,) -> anyhow::Result<NavigationLoadOutcome> {let has_response_override = response_code.is_some() || !response_headers.is_empty();match self {@@ -1973,7 +1973,7 @@ pub struct PendingSubresourceFetchResponseRequest {pub request_body: Option<String>,pub request_cookie_report: Option<StoredCookieQueryReport>,pub response_status: u16,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,pub response_head_overridden: bool,pub response_body_taken_as_stream: bool,/// Exact paused response body for `Fetch.getResponseBody` and IO streams.@@ -1998,7 +1998,7 @@ impl PendingSubresourceFetchResponseRequest {pub fn apply_response_head_override(&mut self,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,) {self.response_status = response_status;self.response_headers = response_headers;@@ -2213,7 +2213,7 @@ impl CdpConnection {&mut self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: moli_core::page::RendererSyntheticResponseBody,) -> Result<(), String> {self.fulfill_pending_subresource_fetch_for_session_owner_async(@@ -2231,7 +2231,7 @@ impl CdpConnection {session_id: Option<&str>,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: moli_core::page::RendererSyntheticResponseBody,) -> Result<(), String> {let page = self@@ -2252,7 +2252,7 @@ impl CdpConnection {&mut self,internal_id: u64,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> Result<(), String> {self.continue_pending_subresource_response_for_session_owner_async(None,@@ -2268,7 +2268,7 @@ impl CdpConnection {session_id: Option<&str>,internal_id: u64,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> Result<(), String> {let owner = CommandOwnerScope::capture(self, session_id);self.continue_pending_subresource_response_for_owner_async(@@ -2285,7 +2285,7 @@ impl CdpConnection {owner: &CommandOwnerScope,internal_id: u64,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> Result<(), String> {let page = self.runtime_session_owner_slot_mut_for_owner(owner)?@@ -2343,7 +2343,7 @@ impl CdpConnection {&mut self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: moli_core::page::RendererSyntheticResponseBody,) -> Result<(), String> {self.fulfill_pending_subresource_response_for_session_owner_async(@@ -2361,7 +2361,7 @@ impl CdpConnection {session_id: Option<&str>,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: moli_core::page::RendererSyntheticResponseBody,) -> Result<(), String> {let page = selfdiff --git a/moli-protocol/src/conn/page_state/fetch_state.rs b/moli-protocol/src/conn/page_state/fetch_state.rsindex 32d41936f..4846c8244 100644--- a/moli-protocol/src/conn/page_state/fetch_state.rs+++ b/moli-protocol/src/conn/page_state/fetch_state.rs@@ -384,7 +384,7 @@ mod tests {ResponseHead {final_url: url.clone(),status: 200,- headers: vec![("content-type".to_owned(), "text/html".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/html".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-protocol/src/conn/runtime_load.rs b/moli-protocol/src/conn/runtime_load.rsindex 83f36a44e..9bba2b073 100644--- a/moli-protocol/src/conn/runtime_load.rs+++ b/moli-protocol/src/conn/runtime_load.rs@@ -102,7 +102,7 @@ async fn prepare_browser_owned_error_page_navigation_with_engine_async(status: 200,headers: vec![("content-type".to_owned(),- "text/html; charset=utf-8".to_owned(),+ b"text/html; charset=utf-8".to_vec(),)],request_cookie_report: None,cookie_set_reports: Vec::new(),@@ -156,7 +156,7 @@ async fn prepare_network_error_page_navigation_with_engine_async(.map(NavigationLoadOutcome::response_commit_ready)}-fn response_headers_indicate_xml_document(headers: &[(String, String)]) -> bool {+fn response_headers_indicate_xml_document(headers: &[(String, Vec<u8>)]) -> bool {moli_web_mime::response_document_content_type(headers).is_some_and(|mime| moli_web_mime::is_dom_parser_xml_mime(&mime))}@@ -299,7 +299,7 @@ pub struct ResponseCommitReady {request_method: String,request_headers: moli_fetch::RequestHeaders,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_from_cache: bool,timing_started: Option<std::time::Instant>,main_document_commit: Option<Arc<RendererMainDocumentCommit>>,@@ -506,7 +506,7 @@ pub struct PausedResponsePreparedDocument {request_method: String,request_headers: moli_fetch::RequestHeaders,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_from_cache: bool,negotiated_http_version: Option<moli_fetch::NegotiatedHttpVersion>,network_observation_journal: NetworkObservationJournal,@@ -732,7 +732,7 @@ pub(crate) struct BackgroundStreamingResponseNavigationLoadJob {response: StreamingRawResponse,network_observation_journal: NetworkObservationJournal,response_code: Option<u16>,- response_headers_override: Vec<(String, String)>,+ response_headers_override: Vec<(String, Vec<u8>)>,body_progress_source: MainDocumentBodyProgressSource,shared_resource_runtime: Option<moli_core::network::BrowserResourceRuntime>,}@@ -771,7 +771,7 @@ impl BackgroundNavigationBodyCompletionSink {body: anyhow::Result<CapturedBody>,body_progress_source: MainDocumentBodyProgressSource,final_url: Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_from_cache: bool,) {let _ = self.sender.send(@@ -1074,7 +1074,7 @@ struct DecodedDataUrlNavigationResponse {struct InlineHtmlNavigationSource {document_url: Url,html: String,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,}pub(crate) fn decode_data_url_response(@@ -1100,7 +1100,11 @@ fn decoded_data_url_navigation_response(ResponseHead {final_url: requested_url.clone(),status: 200,- headers: vec![("Content-Type".to_owned(), decoded.content_type)],+ headers: vec![(+ "Content-Type".to_owned(),+ moli_fetch::header_value_from_byte_string(&decoded.content_type)+ .expect("serialized MIME types contain ByteStrings"),+ )],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -1165,7 +1169,11 @@ fn inline_html_navigation_source(.map(|document_url| InlineHtmlNavigationSource {document_url,html,- response_headers: vec![("Content-Type".into(), content_type)],+ response_headers: vec![(+ "Content-Type".into(),+ moli_fetch::header_value_from_byte_string(&content_type)+ .expect("serialized MIME types contain ByteStrings"),+ )],}).context("failed to parse data url")}))@@ -1271,7 +1279,7 @@ async fn build_navigation_from_streaming_raw_response_with_engine_async(mut response: StreamingRawResponse,network_observation_journal: NetworkObservationJournal,response_code: Option<u16>,- response_headers_override: Vec<(String, String)>,+ response_headers_override: Vec<(String, Vec<u8>)>,body_progress_source: MainDocumentBodyProgressSource,body_completion_sink: Option<BackgroundNavigationBodyCompletionSink>,reserved_service_worker_client: Option<moli_core::runtime::RendererReservedServiceWorkerClient>,@@ -2511,7 +2519,7 @@ impl CdpConnection {response: StreamingRawResponse,network_observation_journal: NetworkObservationJournal,response_code: Option<u16>,- response_headers_override: Vec<(String, String)>,+ response_headers_override: Vec<(String, Vec<u8>)>,body_progress_source: MainDocumentBodyProgressSource,) -> BackgroundStreamingResponseNavigationLoadJob {let load_inputs = self.navigation_load_inputs_for_navigation(navigation);@@ -2749,7 +2757,7 @@ impl CdpConnection {request_method: String,request_headers: moli_fetch::RequestHeaders,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,) -> anyhow::Result<LoadedNavigation> {let load_inputs = self.navigation_load_inputs_for_session_owner(None);@@ -2777,7 +2785,7 @@ impl CdpConnection {request_method: String,request_headers: moli_fetch::RequestHeaders,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,) -> anyhow::Result<LoadedNavigation> {let owner = CommandOwnerScope::capture(self, session_id);@@ -2837,7 +2845,7 @@ impl CdpConnection {request_method: String,request_headers: moli_fetch::RequestHeaders,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,initial_request_cookie_report: Option<StoredCookieQueryReport>,) -> anyhow::Result<LoadedNavigation> {@@ -2861,7 +2869,7 @@ impl CdpConnection {navigation: &NavigationDispatchState,final_url: Url,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: CapturedBody,initial_request_cookie_report: Option<StoredCookieQueryReport>,network_observation_journal: NetworkObservationJournal,@@ -2895,7 +2903,7 @@ impl CdpConnection {request_method: String,request_headers: moli_fetch::RequestHeaders,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: CapturedBody,initial_request_cookie_report: Option<StoredCookieQueryReport>,network_observation_journal: NetworkObservationJournal,@@ -2935,7 +2943,7 @@ impl CdpConnection {request_method: String,request_headers: moli_fetch::RequestHeaders,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: String,captured_response_body: Option<CapturedBody>,initial_request_cookie_report: Option<StoredCookieQueryReport>,@@ -3586,7 +3594,7 @@ impl CdpConnection {navigation: &NavigationDispatchState,response: NetworkFetchResult<StreamingRawResponse>,response_code: Option<u16>,- response_headers_override: Vec<(String, String)>,+ response_headers_override: Vec<(String, Vec<u8>)>,body_progress_source: MainDocumentBodyProgressSource,) -> anyhow::Result<NavigationLoadOutcome> {let load_inputs = self.navigation_load_inputs_for_navigation(navigation);@@ -3614,7 +3622,7 @@ impl CdpConnection {request_headers: moli_fetch::RequestHeaders,response: NetworkFetchResult<StreamingRawResponse>,response_code: Option<u16>,- response_headers_override: Vec<(String, String)>,+ response_headers_override: Vec<(String, Vec<u8>)>,body_progress_source: MainDocumentBodyProgressSource,) -> anyhow::Result<NavigationLoadOutcome> {let (response, network_observation_journal) =@@ -4123,7 +4131,7 @@ mod tests {assert_eq!(source.html, "<main>hello</main>");assert_eq!(source.response_headers,- vec![("Content-Type".to_owned(), "text/html".to_owned())]+ vec![("Content-Type".to_owned(), b"text/html".to_vec())]);}@@ -4172,7 +4180,7 @@ mod tests {assert_eq!(navigation_response.response.status, 200);assert_eq!(navigation_response.response.headers,- vec![("Content-Type".to_owned(), "image/png".to_owned())]+ vec![("Content-Type".to_owned(), b"image/png".to_vec())]);assert_eq!(navigation_response.response.body_bytes(), &[0, 255, b'a']);assert!(navigation_response.response.request_cookie_report.is_none());diff --git a/moli-protocol/src/conn/state/browser_context.rs b/moli-protocol/src/conn/state/browser_context.rsindex f4e17235c..952bc8520 100644--- a/moli-protocol/src/conn/state/browser_context.rs+++ b/moli-protocol/src/conn/state/browser_context.rs@@ -1401,7 +1401,7 @@ impl BrowserContext {pub(crate) fn store_response_cookie_headers_for_test(&self,response_url: &url::Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) {self.with_cookie_store_mut(|store| {store.store_response_headers(response_url, response_headers);diff --git a/moli-protocol/src/conn/state/navigation_outcome.rs b/moli-protocol/src/conn/state/navigation_outcome.rsindex 4bf694ccd..052152fff 100644--- a/moli-protocol/src/conn/state/navigation_outcome.rs+++ b/moli-protocol/src/conn/state/navigation_outcome.rs@@ -158,13 +158,13 @@ pub(crate) enum CompletedDownloadBody {#[derive(Debug)]pub(crate) struct CompletedDownloadBodyArtifact {body: CompletedDownloadBody,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,}impl CompletedDownloadBodyArtifact {pub(crate) fn from_body(body: CompletedDownloadBody,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,) -> Self {Self {body,@@ -172,7 +172,7 @@ impl CompletedDownloadBodyArtifact {}}- pub(crate) fn into_parts(self) -> (CompletedDownloadBody, Vec<(String, String)>) {+ pub(crate) fn into_parts(self) -> (CompletedDownloadBody, Vec<(String, Vec<u8>)>) {(self.body, self.response_headers)}}@@ -187,7 +187,7 @@ pub struct LoadedNavigation {pub request_method: String,pub request_headers: moli_fetch::RequestHeaders,pub response_status: u16,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,pub response_from_cache: bool,pub initial_runtime_realms: Vec<RendererRuntimeRealmInfo>,pub renderer_output_predecessor: Option<moli_core::RendererOutputFence>,diff --git a/moli-protocol/src/conn/state/page_resource.rs b/moli-protocol/src/conn/state/page_resource.rsindex 836f67122..fe71f5a3a 100644--- a/moli-protocol/src/conn/state/page_resource.rs+++ b/moli-protocol/src/conn/state/page_resource.rs@@ -8,7 +8,7 @@ use crate::conn::CapturedBody;pub(crate) struct MainDocumentResourceSnapshot {pub(crate) frame_id: String,pub(crate) url: Url,- pub(crate) response_headers: Vec<(String, String)>,+ pub(crate) response_headers: Vec<(String, Vec<u8>)>,pub(crate) from_cache: bool,pub(crate) body: Option<CapturedBody>,}@@ -17,7 +17,7 @@ pub(crate) struct MainDocumentResourceSnapshot {struct MainDocumentResourceEntry {frame_id: String,url: Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,from_cache: bool,body: Option<CapturedBody>,}@@ -46,7 +46,7 @@ impl TargetPageResourceStore {frame_id: String,loader_id: String,url: Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,from_cache: bool,body: CapturedBody,) {@@ -76,7 +76,7 @@ impl TargetPageResourceStore {frame_id: String,loader_id: String,url: Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,from_cache: bool,body: Option<CapturedBody>,) {@@ -143,7 +143,7 @@ mod tests {"FRAME".to_owned(),"LOADER-2".to_owned(),Url::parse("https://example.test/final").unwrap(),- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],true,body("source"),);@@ -152,7 +152,7 @@ mod tests {"FRAME".to_owned(),"LOADER-2".to_owned(),Url::parse("https://example.test/final").unwrap(),- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],true,None,);@@ -211,7 +211,8 @@ mod tests {fn body_that_finishes_after_commit_fills_the_committed_loader() {let mut store = TargetPageResourceStore::default();let url = Url::parse("https://example.test/streamed").unwrap();- let headers = vec![("content-type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> =+ vec![("content-type".to_owned(), b"text/html".to_vec())];store.commit_main_document("FRAME".to_owned(),"LOADER".to_owned(),diff --git a/moli-protocol/src/conn/state/tests.rs b/moli-protocol/src/conn/state/tests.rsindex a8d760499..38a98bbbb 100644--- a/moli-protocol/src/conn/state/tests.rs+++ b/moli-protocol/src/conn/state/tests.rs@@ -1419,13 +1419,13 @@ fn browser_context_clears_origin_site_data_through_partition_owner() {context.store_response_cookie_headers_for_test(&origin,- &[("set-cookie".to_owned(), "host=1; Path=/; Secure".to_owned())],+ &[("set-cookie".to_owned(), b"host=1; Path=/; Secure".to_vec())],);context.store_response_cookie_headers_for_test(&Url::parse("https://cdn.example.com/page").unwrap(),&[("set-cookie".to_owned(),- "sibling=1; Path=/; Secure".to_owned(),+ b"sibling=1; Path=/; Secure".to_vec(),)],);assert_eq!(context.snapshot_cookies().len(), 2);diff --git a/moli-protocol/src/conn/tests/cookie_surfaces/boundary.rs b/moli-protocol/src/conn/tests/cookie_surfaces/boundary.rsindex 71dbfd7d5..f1742f426 100644--- a/moli-protocol/src/conn/tests/cookie_surfaces/boundary.rs+++ b/moli-protocol/src/conn/tests/cookie_surfaces/boundary.rs@@ -220,16 +220,16 @@ fn browser_context_preview_cookie_boundary_operation_with_site_target_projects_tbc.store_response_cookie_headers_for_test(&Url::parse("https://app.example.com/app/index.html").unwrap(),&[- ("set-cookie".to_owned(), "session=1; Path=/app".to_owned()),+ ("set-cookie".to_owned(), b"session=1; Path=/app".to_vec()),("set-cookie".to_owned(),- "persist=1; Path=/app; Max-Age=3600".to_owned(),+ b"persist=1; Path=/app; Max-Age=3600".to_vec(),),],);bc.store_response_cookie_headers_for_test(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "other=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"other=1; Path=/app".to_vec())],);let preview = bcdiff --git a/moli-protocol/src/conn/tests/resource_runtime.rs b/moli-protocol/src/conn/tests/resource_runtime.rsindex 246497c3d..4141f8cfc 100644--- a/moli-protocol/src/conn/tests/resource_runtime.rs+++ b/moli-protocol/src/conn/tests/resource_runtime.rs@@ -131,7 +131,7 @@ async fn buffered_navigation_for_inactive_session_retains_its_target_engine() {&navigation,requested_url,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],crate::conn::CapturedBody::from_string("<main>target</main>".to_owned()),None,moli_fetch::NetworkObservationJournal::default(),@@ -356,7 +356,7 @@ fn browser_context_request_cookie_report_reads_storage_partition_cookie_handle()&request_url,&[("set-cookie".to_owned(),- "sid=partition; Path=/app".to_owned(),+ b"sid=partition; Path=/app".to_vec(),)],);}@@ -384,7 +384,7 @@ fn browser_context_cookie_snapshot_and_delete_use_storage_partition_cookie_handl&request_url,&[("set-cookie".to_owned(),- "sid=partition; Path=/app".to_owned(),+ b"sid=partition; Path=/app".to_vec(),)],);}@@ -441,7 +441,7 @@ fn navigation_load_inputs_own_cookie_request_and_response_reports() {&response_url,&[("set-cookie".to_owned(),- "sid=load-input; Path=/app".to_owned(),+ b"sid=load-input; Path=/app".to_vec(),)],);assert_eq!(set_reports.len(), 1);@@ -596,7 +596,7 @@ async fn build_loaded_navigation_from_buffered_response_updates_request_cookie_a&requested_url,&[("set-cookie".to_owned(),- "sid=1; Path=/app; Secure".to_owned(),+ b"sid=1; Path=/app; Secure".to_vec(),)],);let before = bc@@ -649,7 +649,7 @@ async fn rebuild_buffered_response_preserving_request_report_avoids_second_acces&requested_url,&[("set-cookie".to_owned(),- "sid=1; Path=/app; Secure".to_owned(),+ b"sid=1; Path=/app; Secure".to_vec(),)],);conn.install_browser_context_fixture_for_test(bc);@@ -3614,7 +3614,7 @@ async fn data_image_navigation_loads_from_synthetic_response_without_curl() {assert_eq!(navigation.response_status, 200);assert_eq!(navigation.response_headers,- vec![("Content-Type".to_owned(), "image/png".to_owned())]+ vec![("Content-Type".to_owned(), b"image/png".to_vec())]);assert!(navigation.pending_download.is_none());@@ -3625,7 +3625,7 @@ async fn data_image_navigation_loads_from_synthetic_response_without_curl() {assert_eq!(network_events.response_status, 200);assert_eq!(network_events.response_headers,- vec![("Content-Type".to_owned(), "image/png".to_owned())]+ vec![("Content-Type".to_owned(), b"image/png".to_vec())]);assert!(network_events.response_cookie_reports.is_empty());assert!(network_events.redirect_chain.is_empty());diff --git a/moli-protocol/src/conn/tests/site_data.rs b/moli-protocol/src/conn/tests/site_data.rsindex 18163c38e..ebcc11af5 100644--- a/moli-protocol/src/conn/tests/site_data.rs+++ b/moli-protocol/src/conn/tests/site_data.rs@@ -7,15 +7,15 @@ fn browser_context_cookie_sites_and_clear_for_sites_use_site_keys() {let mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "a=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"a=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://cdn.example.com/assets/index.html").unwrap(),- &[("set-cookie".to_owned(), "b=1; Path=/assets".to_owned())],+ &[("set-cookie".to_owned(), b"b=1; Path=/assets".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "c=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"c=1; Path=/app".to_vec())],);}@@ -34,20 +34,20 @@ fn browser_context_clear_cookies_for_sites_report_projects_replaced_and_remaininlet mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://cdn.example.com/assets/index.html").unwrap(),&[("set-cookie".to_owned(),- "persistent=1; Path=/assets; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/assets; Max-Age=3600".to_vec(),)],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -71,17 +71,17 @@ fn browser_context_cookie_site_data_summarizes_counts_by_site() {let mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "a=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"a=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://cdn.example.com/assets/index.html").unwrap(),- &[("set-cookie".to_owned(), "b=1; Path=/assets".to_owned())],+ &[("set-cookie".to_owned(), b"b=1; Path=/assets".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[- ("set-cookie".to_owned(), "c=1; Path=/app".to_owned()),- ("set-cookie".to_owned(), "d=1; Path=/app".to_owned()),+ ("set-cookie".to_owned(), b"c=1; Path=/app".to_vec()),+ ("set-cookie".to_owned(), b"d=1; Path=/app".to_vec()),],);}@@ -102,13 +102,13 @@ fn browser_context_preview_clear_cookies_for_sites_reports_targeted_removal_withlet mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -145,13 +145,13 @@ fn browser_context_preview_clear_cookies_for_sites_with_persistent_scope_keeps_slet mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "persist=1; Path=/app; Max-Age=3600".to_owned(),+ b"persist=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -182,13 +182,13 @@ fn browser_context_preview_clear_cookie_store_defaults_to_all_scope() {let mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "persist=1; Path=/app; Max-Age=3600".to_owned(),+ b"persist=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -273,13 +273,13 @@ fn browser_context_preview_clear_cookie_storage_with_site_target_projects_targetlet mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -372,18 +372,18 @@ fn connection_clear_cookie_storage_with_site_target_projects_targeted_report() {.lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://cdn.example.com/assets/index.html").unwrap(),&[("set-cookie".to_owned(),- "persist=1; Path=/assets; Max-Age=3600".to_owned(),+ b"persist=1; Path=/assets; Max-Age=3600".to_vec(),)],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "other=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"other=1; Path=/app".to_vec())],);}@@ -417,13 +417,13 @@ fn browser_context_preview_cookie_site_data_operation_clear_projects_generic_ownlet mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -450,13 +450,13 @@ fn browser_context_cookie_storage_state_snapshot_distinguishes_live_and_persistelet mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "persistent=1; Path=/app; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -489,20 +489,20 @@ fn browser_context_cookie_storage_state_snapshot_for_sites_filters_views() {let mut store = bc.cookie_store_for_test().lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://cdn.example.com/assets/index.html").unwrap(),&[("set-cookie".to_owned(),- "persistent=1; Path=/assets; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/assets; Max-Age=3600".to_vec(),)],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -567,13 +567,13 @@ fn connection_clear_cookies_for_sites_report_projects_targeted_state() {let mut store = cookie_store.lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -636,7 +636,7 @@ async fn connection_preview_clear_cookies_for_sites_does_not_invalidate_live_doc&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -672,11 +672,11 @@ fn connection_cookie_sites_reflect_active_browser_store() {let mut store = cookie_store.lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "a=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"a=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "b=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"b=1; Path=/app".to_vec())],);}@@ -695,15 +695,15 @@ fn connection_cookie_site_data_reflects_active_browser_store() {let mut store = cookie_store.lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "a=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"a=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://cdn.example.com/assets/index.html").unwrap(),- &[("set-cookie".to_owned(), "b=1; Path=/assets".to_owned())],+ &[("set-cookie".to_owned(), b"b=1; Path=/assets".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "c=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"c=1; Path=/app".to_vec())],);}@@ -725,13 +725,13 @@ fn connection_cookie_storage_state_snapshot_reflects_active_browser_store() {let mut store = cookie_store.lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "persistent=1; Path=/app; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/app; Max-Age=3600".to_vec(),)],);}@@ -752,20 +752,20 @@ fn connection_cookie_storage_state_snapshot_for_sites_filters_active_store() {let mut store = cookie_store.lock();store.store_response_headers(&Url::parse("https://app.example.com/app/index.html").unwrap(),- &[("set-cookie".to_owned(), "session=1; Path=/app".to_owned())],+ &[("set-cookie".to_owned(), b"session=1; Path=/app".to_vec())],);store.store_response_headers(&Url::parse("https://cdn.example.com/assets/index.html").unwrap(),&[("set-cookie".to_owned(),- "persistent=1; Path=/assets; Max-Age=3600".to_owned(),+ b"persistent=1; Path=/assets; Max-Age=3600".to_vec(),)],);store.store_response_headers(&Url::parse("https://foo.co.uk/app/index.html").unwrap(),&[("set-cookie".to_owned(),- "other=1; Path=/app; Max-Age=3600".to_owned(),+ b"other=1; Path=/app; Max-Age=3600".to_vec(),)],);}diff --git a/moli-protocol/src/devtools_runtime.rs b/moli-protocol/src/devtools_runtime.rsindex 7af70abe6..b94feadbd 100644--- a/moli-protocol/src/devtools_runtime.rs+++ b/moli-protocol/src/devtools_runtime.rs@@ -1321,7 +1321,7 @@ pub struct DevToolsContinueInterceptedResponseCommand {pub context: DevToolsCommandContext,pub request_id: DevToolsRequestId,pub response_code: Option<u16>,- pub response_headers: Option<Vec<(String, String)>>,+ pub response_headers: Option<Vec<(String, Vec<u8>)>>,pub response_phrase: Option<String>,pub auth_credentials: Option<DevToolsAuthCredentials>,}@@ -1360,7 +1360,7 @@ pub struct DevToolsFulfillInterceptedRequestCommand {pub context: DevToolsCommandContext,pub request_id: DevToolsRequestId,pub response_code: u16,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,pub body: Option<Vec<u8>>,pub response_phrase: Option<String>,}@@ -2189,7 +2189,7 @@ pub struct NetworkRedirectResponseEvent {pub url: String,pub status: u16,pub status_text: Option<String>,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,pub encoded_data_length: usize,pub from_cache: bool,pub response_protocol: Option<String>,@@ -2404,7 +2404,7 @@ pub struct NetworkRequestEvent {pub wall_time: Option<f64>,pub status: Option<u16>,pub status_text: Option<String>,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,pub response_mime_type: Option<String>,pub response_protocol: Option<String>,pub encoded_data_length: Option<usize>,diff --git a/moli-protocol/src/domains/activity/main_document.rs b/moli-protocol/src/domains/activity/main_document.rsindex b37be62f7..96ea8ee1c 100644--- a/moli-protocol/src/domains/activity/main_document.rs+++ b/moli-protocol/src/domains/activity/main_document.rs@@ -1093,7 +1093,7 @@ mod tests {200,vec![("Content-Type".to_owned(),- "application/octet-stream".to_owned(),+ b"application/octet-stream".to_vec(),)],Vec::new(),Vec::new(),diff --git a/moli-protocol/src/domains/command_output.rs b/moli-protocol/src/domains/command_output.rsindex 728925719..dec5db6b2 100644--- a/moli-protocol/src/domains/command_output.rs+++ b/moli-protocol/src/domains/command_output.rs@@ -1091,10 +1091,13 @@ fn network_request_event_from_cdp_params(params: &Value, request_id: &str) -> Ne.or_else(|| params.get("responseStatusText")).and_then(Value::as_str).map(str::to_owned),- response_headers: cdp_header_pairs_from_object(params.pointer("/response/headers"))- .into_iter()- .chain(fetch_header_pairs_from_array(params.get("responseHeaders")))- .collect(),+ response_headers: moli_fetch::headers_from_byte_strings(+ &cdp_header_pairs_from_object(params.pointer("/response/headers"))+ .into_iter()+ .chain(fetch_header_pairs_from_array(params.get("responseHeaders")))+ .collect::<Vec<_>>(),+ )+ .expect("response event headers contain ByteStrings"),response_mime_type: params.pointer("/response/mimeType").and_then(Value::as_str)@@ -1147,7 +1150,10 @@ fn redirect_response_event_from_cdp_params(params: &Value) -> Option<NetworkRedi.get("statusText").and_then(Value::as_str).map(str::to_owned),- response_headers: cdp_header_pairs_from_object(response.get("headers")),+ response_headers: moli_fetch::headers_from_byte_strings(&cdp_header_pairs_from_object(+ response.get("headers"),+ ))+ .expect("response event headers contain ByteStrings"),encoded_data_length: response.get("encodedDataLength").and_then(Value::as_u64)@@ -3195,7 +3201,7 @@ mod tests {&& redirect.from_cache&& redirect.response_headers == vec![("Location".to_owned(),- "/api".to_owned()+ b"/api".to_vec())]})));@@ -3238,7 +3244,7 @@ mod tests {&& event.has_extra_info&& event.response_headers == vec![("Content-Type".to_owned(),- "application/json".to_owned()+ b"application/json".to_vec())]));}@@ -3303,7 +3309,7 @@ mod tests {if event.status == Some(401)&& event.response_headers == vec![("WWW-Authenticate".to_owned(),- "Basic realm=\"private\"".to_owned()+ b"Basic realm=\"private\"".to_vec())]));}diff --git a/moli-protocol/src/domains/fetch/commands.rs b/moli-protocol/src/domains/fetch/commands.rsindex 05ec3da59..64118705a 100644--- a/moli-protocol/src/domains/fetch/commands.rs+++ b/moli-protocol/src/domains/fetch/commands.rs@@ -818,13 +818,13 @@ pub(super) enum PendingFulfillRequestState {Navigation {pending: Box<crate::conn::PendingFetchNavigation>,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,decoded_body: Option<RendererSyntheticResponseBody>,},ResponseTransfer {transfer: Box<crate::conn::PausedDocumentTransfer>,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,decoded_body: Option<RendererSyntheticResponseBody>,},}@@ -895,7 +895,7 @@ fn build_cdp_fulfill_intercepted_request_command(cmd: &Cmd<'_>,request_id: String,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,body: Option<Vec<u8>>,response_phrase: Option<String>,) -> DevToolsFulfillInterceptedRequestCommand {@@ -1438,7 +1438,7 @@ pub(super) enum PendingContinueResponseState {request_id: String,transfer: Box<crate::conn::PausedDocumentTransfer>,response_code: Option<u16>,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,},SubresourceResponse {pending: Box<crate::conn::PendingSubresourceFetchResponseRequest>,@@ -1503,7 +1503,7 @@ fn build_cdp_continue_intercepted_response_command(cmd: &Cmd<'_>,request_id: &str,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,response_phrase: Option<String>,) -> DevToolsContinueInterceptedResponseCommand {let (browser_context_id, target_id) =@@ -1760,7 +1760,7 @@ async fn continue_response_transfer_inline(request_id: String,transfer: crate::conn::PausedDocumentTransfer,response_code: Option<u16>,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,) {match transfer.continue_response_async(conn, response_code, response_headers)@@ -1864,7 +1864,7 @@ fn continue_streaming_document_response_in_background(sender: tokio::sync::mpsc::UnboundedSender<page::BackgroundNavigationCompletion>,pending: PendingStreamingDocumentResponseNavigation,response_code: Option<u16>,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,) {let PendingStreamingDocumentResponseNavigation {document_navigation_token,@@ -2008,7 +2008,7 @@ mod protocol_neutral_tests {&cmd,"interception-job-1",Some(204),- Some(vec![("x-test".to_owned(), "1".to_owned())]),+ Some(vec![("x-test".to_owned(), b"1".to_vec())]),Some("No Content".to_owned()),);@@ -2023,7 +2023,7 @@ mod protocol_neutral_tests {assert_eq!(command.response_code, Some(204));assert_eq!(command.response_headers,- Some(vec![("x-test".to_owned(), "1".to_owned())])+ Some(vec![("x-test".to_owned(), b"1".to_vec())]));assert_eq!(command.response_phrase.as_deref(), Some("No Content"));}@@ -2247,7 +2247,7 @@ mod protocol_neutral_tests {request_body: None,request_cookie_report: None,response_status: 200,- response_headers: vec![("content-type".to_owned(), "application/json".to_owned())],+ response_headers: vec![("content-type".to_owned(), b"application/json".to_vec())],response_head_overridden: false,response_body_taken_as_stream: false,response_body: CapturedBody::from_bytes(br#"{"ok":true}"#.to_vec()),@@ -2514,7 +2514,7 @@ mod protocol_neutral_tests {&cmd,"interception-job-3".to_owned(),204,- vec![("x-test".to_owned(), "yes".to_owned())],+ vec![("x-test".to_owned(), b"yes".to_vec())],Some(vec![1, 2, 3]),Some("No Content".to_owned()),);@@ -2530,7 +2530,7 @@ mod protocol_neutral_tests {assert_eq!(command.response_code, 204);assert_eq!(command.response_headers,- vec![("x-test".to_owned(), "yes".to_owned())]+ vec![("x-test".to_owned(), b"yes".to_vec())]);assert_eq!(command.body, Some(vec![1, 2, 3]));assert_eq!(command.response_phrase.as_deref(), Some("No Content"));diff --git a/moli-protocol/src/domains/fetch/helpers.rs b/moli-protocol/src/domains/fetch/helpers.rsindex bf9d429d8..9fe86045b 100644--- a/moli-protocol/src/domains/fetch/helpers.rs+++ b/moli-protocol/src/domains/fetch/helpers.rs@@ -27,12 +27,11 @@ pub(crate) fn decode_base64_to_string(body: &str) -> Result<String, ()> {String::from_utf8(decoded).map_err(|_| ())}-// The existing response consumers use WebIDL ByteString projections. Encode CDP-// Unicode as UTF-8 and decode binary input losslessly at this adapter boundary.+// CDP Unicode input uses UTF-8; binary input remains raw HTTP bytes.pub(super) fn response_headers_from_params(response_headers: Option<Vec<HeaderEntry>>,binary_response_headers: Option<&str>,-) -> Result<Vec<(String, String)>, ()> {+) -> Result<Vec<(String, Vec<u8>)>, ()> {Ok(response_headers_with_presence_from_params(response_headers, binary_response_headers)?.unwrap_or_default(),@@ -42,9 +41,9 @@ pub(super) fn response_headers_from_params(pub(super) fn response_headers_with_presence_from_params(response_headers: Option<Vec<HeaderEntry>>,binary_response_headers: Option<&str>,-) -> Result<Option<Vec<(String, String)>>, ()> {+) -> Result<Option<Vec<(String, Vec<u8>)>>, ()> {if let Some(encoded) = binary_response_headers {- parse_binary_response_headers(encoded).map(|headers| Some(headers.to_byte_strings()))+ parse_binary_response_headers(encoded).map(|headers| Some(headers.into_iter().collect()))} else {Ok(response_headers.map(|headers| {moli_fetch::ResponseHeaders::from_utf8(@@ -53,7 +52,8 @@ pub(super) fn response_headers_with_presence_from_params(.map(|header| (header.name, header.value)).collect(),)- .to_byte_strings()+ .into_iter()+ .collect()}))}}@@ -305,7 +305,7 @@ pub(crate) fn navigation_response_stage_request_paused_event(final_url: &url::Url,request_cookie_report: Option<&StoredCookieQueryReport>,response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> BackgroundProtocolEvent {let (payload, event) = navigation_response_stage_request_paused_parts(fetch_request_id,@@ -327,7 +327,7 @@ fn navigation_response_stage_request_paused_parts(final_url: &url::Url,request_cookie_report: Option<&StoredCookieQueryReport>,response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> (Value, AutomationEvent) {let network_event = NetworkRequestEvent {target_id: DevToolsTargetId::from(navigation.frame_id.as_str()),@@ -430,7 +430,7 @@ fn pending_subresource_response_stage_request_paused_parts((payload, AutomationEvent::RequestPaused(network_event))}-pub(crate) fn extract_auth_challenge(headers: &[(String, String)]) -> Option<FetchAuthChallenge> {+pub(crate) fn extract_auth_challenge(headers: &[(String, Vec<u8>)]) -> Option<FetchAuthChallenge> {extract_subresource_auth_challenge(headers).map(|challenge| FetchAuthChallenge {origin: String::new(),source: challenge.source,diff --git a/moli-protocol/src/domains/fetch/navigation.rs b/moli-protocol/src/domains/fetch/navigation.rsindex 9c79f017d..687a913a8 100644--- a/moli-protocol/src/domains/fetch/navigation.rs+++ b/moli-protocol/src/domains/fetch/navigation.rs@@ -631,7 +631,11 @@ fn pause_data_url_response_stage_navigation_into_buffer(ResponseHead {final_url: pending.navigation.requested_url.clone(),status: 200,- headers: vec![("Content-Type".to_owned(), content_type)],+ headers: vec![(+ "Content-Type".to_owned(),+ moli_fetch::header_value_from_byte_string(&content_type)+ .expect("serialized MIME types contain ByteStrings"),+ )],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -999,12 +1003,12 @@ mod tests {fn response_stage_navigation_download_detection_uses_web_mime_attachment_helper() {assert!(response_headers_indicate_attachment_download(&[("Content-Disposition".to_owned(),- "attachment; filename=report.html".to_owned(),+ b"attachment; filename=report.html".to_vec(),)]));assert!(!response_headers_indicate_attachment_download(&[("Content-Disposition".to_owned(),- "inline; filename=attachment.html".to_owned(),+ b"inline; filename=attachment.html".to_vec(),)]));}}diff --git a/moli-protocol/src/domains/fetch/tests/basics.rs b/moli-protocol/src/domains/fetch/tests/basics.rsindex a49f8bf8b..9a35061a9 100644--- a/moli-protocol/src/domains/fetch/tests/basics.rs+++ b/moli-protocol/src/domains/fetch/tests/basics.rs@@ -1477,7 +1477,7 @@ async fn continue_with_auth_unsupported_challenge_preserves_pending_auth_navigatfn extract_auth_challenge_normalizes_scheme_and_allows_missing_realm() {let challenge = extract_auth_challenge(&[("www-authenticate".to_owned(),- "BASIC charset=\"UTF-8\"".to_owned(),+ b"BASIC charset=\"UTF-8\"".to_vec(),)]).expect("auth challenge");assert_eq!(challenge.source, "Server");@@ -1488,7 +1488,7 @@ fn extract_auth_challenge_normalizes_scheme_and_allows_missing_realm() {#[test]fn extract_auth_challenge_returns_none_without_www_authenticate_header() {assert!(- extract_auth_challenge(&[("content-type".to_owned(), "text/plain".to_owned(),)]).is_none()+ extract_auth_challenge(&[("content-type".to_owned(), b"text/plain".to_vec(),)]).is_none());}@@ -1496,7 +1496,7 @@ fn extract_auth_challenge_returns_none_without_www_authenticate_header() {fn extract_auth_challenge_recognizes_proxy_authenticate_header() {let challenge = extract_auth_challenge(&[("proxy-authenticate".to_owned(),- "Basic realm=\"proxy-area\"".to_owned(),+ b"Basic realm=\"proxy-area\"".to_vec(),)]).expect("proxy auth challenge");assert_eq!(challenge.source, "Proxy");@@ -1509,11 +1509,11 @@ fn extract_auth_challenge_prefers_supported_scheme_from_later_header() {let challenge = extract_auth_challenge(&[("www-authenticate".to_owned(),- "Bearer realm=\"token-area\"".to_owned(),+ b"Bearer realm=\"token-area\"".to_vec(),),("www-authenticate".to_owned(),- "Basic realm=\"basic-area\"".to_owned(),+ b"Basic realm=\"basic-area\"".to_vec(),),]).expect("auth challenge");@@ -1556,7 +1556,7 @@ fn request_auth_for_challenge_accepts_negotiate_and_ntlm_credentials() {fn extract_auth_challenge_prefers_supported_scheme_from_combined_header_value() {let challenge = extract_auth_challenge(&[("www-authenticate".to_owned(),- "Bearer realm=\"token-area\", Basic realm=\"basic-area\"".to_owned(),+ b"Bearer realm=\"token-area\", Basic realm=\"basic-area\"".to_vec(),)]).expect("auth challenge");assert_eq!(challenge.source, "Server");@@ -1568,7 +1568,7 @@ fn extract_auth_challenge_prefers_supported_scheme_from_combined_header_value()fn extract_auth_challenge_preserves_quoted_commas_in_realm() {let challenge = extract_auth_challenge(&[("www-authenticate".to_owned(),- r#"Bearer realm="token-area", Basic realm="basic, area""#.to_owned(),+ br#"Bearer realm="token-area", Basic realm="basic, area""#.to_vec(),)]).expect("auth challenge");assert_eq!(challenge.source, "Server");diff --git a/moli-protocol/src/domains/fetch/tests/navigation_auth.rs b/moli-protocol/src/domains/fetch/tests/navigation_auth.rsindex a740b27b9..f7b82d20e 100644--- a/moli-protocol/src/domains/fetch/tests/navigation_auth.rs+++ b/moli-protocol/src/domains/fetch/tests/navigation_auth.rs@@ -609,7 +609,7 @@ async fn navigation_auth_required_includes_synthesized_cookie_header() {&Url::parse(&url).unwrap(),&[("set-cookie".to_owned(),- "sid=nav-auth; Path=/auth".to_owned(),+ b"sid=nav-auth; Path=/auth".to_vec(),)],);}diff --git a/moli-protocol/src/domains/fetch/tests/navigation_control.rs b/moli-protocol/src/domains/fetch/tests/navigation_control.rsindex 5f92d4643..2b3008f72 100644--- a/moli-protocol/src/domains/fetch/tests/navigation_control.rs+++ b/moli-protocol/src/domains/fetch/tests/navigation_control.rs@@ -9,8 +9,8 @@ fn parse_binary_response_headers_decodes_nul_separated_header_block() {assert_eq!(headers,vec![- ("x-bin".to_owned(), "yes".to_owned()),- ("x-two".to_owned(), "2".to_owned())+ ("x-bin".to_owned(), b"yes".to_vec()),+ ("x-two".to_owned(), b"2".to_vec())]);}@@ -550,7 +550,7 @@ async fn response_stage_document_pattern_pauses_main_document_after_response() {let mut jar = bc.cookie_store_for_test().lock();jar.store_response_headers(&Url::parse(&url).unwrap(),- &[("set-cookie".to_owned(), "sid=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/".to_vec())],);}ctx.conn.install_browser_context_fixture_for_test(bc);diff --git a/moli-protocol/src/domains/fetch/tests/navigation_response_stage.rs b/moli-protocol/src/domains/fetch/tests/navigation_response_stage.rsindex 9acabdbe8..8c986f6b5 100644--- a/moli-protocol/src/domains/fetch/tests/navigation_response_stage.rs+++ b/moli-protocol/src/domains/fetch/tests/navigation_response_stage.rs@@ -1384,7 +1384,7 @@ async fn continue_response_can_override_status_and_headers() {assert!(page.headers().iter()- .any(|(name, value)| name == "x-override" && value == "yes")+ .any(|(name, value)| name == "x-override" && value == b"yes"));server.abort();@@ -1538,7 +1538,7 @@ async fn continue_response_header_override_keeps_streaming_parser_body() {assert!(page.headers().iter()- .any(|(name, value)| name == "x-override" && value == "streaming")+ .any(|(name, value)| name == "x-override" && value == b"streaming"));assert!(script_requested.load(Ordering::SeqCst),@@ -1577,7 +1577,7 @@ async fn response_stage_navigation_request_paused_includes_synthesized_cookie_helet mut jar = bc.cookie_store_for_test().lock();jar.store_response_headers(&Url::parse(&url).unwrap(),- &[("set-cookie".to_owned(), "sid=nav; Path=/page".to_owned())],+ &[("set-cookie".to_owned(), b"sid=nav; Path=/page".to_vec())],);}ctx.conn.install_browser_context_fixture_for_test(bc);@@ -1727,12 +1727,12 @@ async fn continue_response_with_binary_response_headers_overrides_headers() {assert!(page.headers().iter()- .any(|(name, value)| name == "x-bin" && value == "yes")+ .any(|(name, value)| name == "x-bin" && value == b"yes"));assert!(page.headers().iter()- .any(|(name, value)| name == "x-two" && value == "2")+ .any(|(name, value)| name == "x-two" && value == b"2"));server.abort();diff --git a/moli-protocol/src/domains/fetch/tests/navigation_subresource.rs b/moli-protocol/src/domains/fetch/tests/navigation_subresource.rsindex 5c454b114..df378364c 100644--- a/moli-protocol/src/domains/fetch/tests/navigation_subresource.rs+++ b/moli-protocol/src/domains/fetch/tests/navigation_subresource.rs@@ -79,10 +79,7 @@ async fn request_stage_navigation_request_paused_includes_synthesized_cookie_healet mut jar = bc.cookie_store_for_test().lock();jar.store_response_headers(&Url::parse(&url).unwrap(),- &[(- "set-cookie".to_owned(),- "sid=req-nav; Path=/page".to_owned(),- )],+ &[("set-cookie".to_owned(), b"sid=req-nav; Path=/page".to_vec())],);}ctx.conn.install_browser_context_fixture_for_test(bc);diff --git a/moli-protocol/src/domains/network/activity.rs b/moli-protocol/src/domains/network/activity.rsindex 1bc4c887e..8080d8eda 100644--- a/moli-protocol/src/domains/network/activity.rs+++ b/moli-protocol/src/domains/network/activity.rs@@ -626,7 +626,7 @@ mod tests {request_cookie_report: None,network_request_headers: None,response_status: 200,- response_headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ response_headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],response_body: SubresourceResponseBody::from_bytes(b"prepared".to_vec()),from_cache: false,});diff --git a/moli-protocol/src/domains/network/agent.rs b/moli-protocol/src/domains/network/agent.rsindex 3ff67a9ed..92e1d120b 100644--- a/moli-protocol/src/domains/network/agent.rs+++ b/moli-protocol/src/domains/network/agent.rs@@ -2081,7 +2081,7 @@ mod tests {Vec::new(),url,101,- vec![("Upgrade".to_owned(), "websocket".to_owned())],+ vec![("Upgrade".to_owned(), b"websocket".to_vec())],String::new(),Vec::new(),)diff --git a/moli-protocol/src/domains/network/events.rs b/moli-protocol/src/domains/network/events.rsindex 7fb17c7d3..9701312e9 100644--- a/moli-protocol/src/domains/network/events.rs+++ b/moli-protocol/src/domains/network/events.rs@@ -272,7 +272,7 @@ pub(crate) fn emit_request_will_be_sent(redirect_response: Option<(&Url,u16,- &[(String, String)],+ &[(String, Vec<u8>)],bool,Option<moli_fetch::NegotiatedHttpVersion>,)>,@@ -413,7 +413,7 @@ pub(crate) fn emit_response_received_extra_info(out: &mut impl CdpNetworkAutomationEventSink,session_id: Option<&str>,request_id: &str,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],status: u16,cookie_set_reports: &[StoredCookieSetReport],) {@@ -434,7 +434,7 @@ pub(crate) fn emit_redirect_response_received_extra_info(out: &mut impl CdpNetworkAutomationEventSink,session_id: Option<&str>,request_id: &str,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],status: u16,cookie_set_reports: &[StoredCookieSetReport],) {@@ -461,7 +461,7 @@ pub(crate) fn emit_response_received(final_url: &Url,status: u16,status_text: Option<&str>,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],cookie_set_reports: &[StoredCookieSetReport],encoded_data_length: usize,from_cache: bool,@@ -505,7 +505,7 @@ pub(crate) fn emit_response_received_without_extra_info_event(final_url: &Url,status: u16,status_text: Option<&str>,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],encoded_data_length: usize,from_cache: bool,negotiated_http_version: Option<moli_fetch::NegotiatedHttpVersion>,@@ -546,7 +546,7 @@ fn emit_response_received_with_extra_info_delivery(final_url: &Url,status: u16,status_text: Option<&str>,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],cookie_set_reports: &[StoredCookieSetReport],encoded_data_length: usize,from_cache: bool,@@ -1009,7 +1009,7 @@ pub fn fetch_request_paused_params(network_event: &NetworkRequestEvent) -> Valuenetwork_event.response_headers.iter()- .map(|(name, value)| json!({ "name": name, "value": value }))+ .map(|(name, value)| json!({ "name": name, "value": moli_fetch::decode_header_value(value) })).collect(),);if let Some(status_text) = network_event.status_text.as_ref() {@@ -1081,7 +1081,7 @@ pub(crate) fn emit_websocket_will_send_handshake_request(session_id,request_id,timestamp,- headers_as_json_object(request_headers),+ request_headers_as_json_object(request_headers, None),);}@@ -1091,7 +1091,7 @@ pub(crate) fn emit_websocket_handshake_response_received(request_id: &str,timestamp: f64,status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) {out.push_websocket_handshake_response_received(session_id,@@ -1157,11 +1157,11 @@ pub(crate) fn emit_websocket_closed(}pub(crate) fn headers_as_json_object(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> serde_json::Map<String, Value> {headers.iter()- .map(|(name, value)| (name.clone(), json!(value)))+ .map(|(name, value)| (name.clone(), json!(moli_fetch::decode_header_value(value)))).collect()}@@ -1204,7 +1204,7 @@ pub(crate) fn request_headers_as_json_object(pub(crate) fn build_response_payload(url: &Url,status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],encoded_data_length: usize,) -> Value {build_response_payload_with_status_text(@@ -1221,7 +1221,7 @@ pub(crate) fn build_response_payload_with_status_text(url: &Url,status: u16,status_text: Option<&str>,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],encoded_data_length: usize,from_cache: bool,) -> Value {@@ -1320,8 +1320,8 @@ mod tests {&Url::parse("https://example.test/").unwrap(),200,&[- ("Content-Type".to_owned(), "text/html".to_owned()),- ("Bad Header".to_owned(), "ignored".to_owned()),+ ("Content-Type".to_owned(), b"text/html".to_vec()),+ ("Bad Header".to_owned(), b"ignored".to_vec()),],0,);@@ -1417,8 +1417,8 @@ mod tests {201,None,&[- ("content-type".to_owned(), "application/json".to_owned()),- ("x-test".to_owned(), "1".to_owned()),+ ("content-type".to_owned(), b"application/json".to_vec()),+ ("x-test".to_owned(), b"1".to_vec()),],&[],128,diff --git a/moli-protocol/src/domains/network/main_document_progress/emit.rs b/moli-protocol/src/domains/network/main_document_progress/emit.rsindex 43d8bac88..3e7508506 100644--- a/moli-protocol/src/domains/network/main_document_progress/emit.rs+++ b/moli-protocol/src/domains/network/main_document_progress/emit.rs@@ -155,7 +155,7 @@ pub(super) fn emit_main_document_request_will_be_sent(&Url,u16,Option<&str>,- &[(String, String)],+ &[(String, Vec<u8>)],bool,Option<moli_fetch::NegotiatedHttpVersion>,)>,@@ -252,7 +252,7 @@ pub(super) fn emit_response_received_extra_info(output: &mut MainDocumentProgressOutputTarget<'_>,session_id: Option<&str>,request_id: &str,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],status: u16,cookie_set_reports: &[StoredCookieSetReport],) {@@ -278,10 +278,10 @@ pub(super) fn emit_main_document_response_received(timestamp: f64,final_url: &Url,status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],cookie_set_reports: &[StoredCookieSetReport],extra_info_status: u16,- extra_info_headers: &[(String, String)],+ extra_info_headers: &[(String, Vec<u8>)],_network_extra_info_available: bool,emit_extra_info: bool,encoded_data_length: usize,diff --git a/moli-protocol/src/domains/network/main_document_progress/mod.rs b/moli-protocol/src/domains/network/main_document_progress/mod.rsindex f2f14e723..7764c9120 100644--- a/moli-protocol/src/domains/network/main_document_progress/mod.rs+++ b/moli-protocol/src/domains/network/main_document_progress/mod.rs@@ -35,7 +35,7 @@ pub(crate) struct MaterializedLoadedDocumentProgress {pub(crate) pending_download: Option<RendererPendingDownloadActivation>,pub(crate) page_creation_artifacts: RendererPageCreationArtifacts,pub(crate) final_url: Url,- pub(crate) response_headers: Vec<(String, String)>,+ pub(crate) response_headers: Vec<(String, Vec<u8>)>,pub(crate) response_from_cache: bool,pub(crate) main_document_body: Option<CapturedBody>,pub(crate) initial_runtime_realms: Vec<RendererRuntimeRealmInfo>,@@ -224,14 +224,14 @@ impl CompletedDownloadProgressTransfer {fn completed_download_body_len_hint(body: &CompletedDownloadProgressBody,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> usize {match body {CompletedDownloadProgressBody::Buffered(body) => body.len(),CompletedDownloadProgressBody::Streaming(_) => response_headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("content-length"))- .and_then(|(_, value)| value.trim().parse().ok())+ .and_then(|(_, value)| moli_fetch::decode_header_value(value).trim().parse().ok()).unwrap_or_default(),}}@@ -584,7 +584,7 @@ impl MainDocumentBodyProgressSource {redirect_chain: &[RedirectInfo],final_url: &Url,response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],response_cookie_reports: &[StoredCookieSetReport],network_observation_journal: &NetworkObservationJournal,network_extra_info_available: bool,@@ -635,7 +635,7 @@ impl MainDocumentBodyProgressSource {out: &mut Vec<BackgroundProtocolEvent>,final_url: &Url,response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],response_from_cache: bool,) {let Some(live_source) = self.live_source.as_ref() else {@@ -733,7 +733,7 @@ impl MainDocumentBodyProgressSource {final_request_cookie_report: Option<&StoredCookieQueryReport>,redirect_chain: &[RedirectInfo],response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],response_cookie_reports: &[StoredCookieSetReport],network_observation_journal: &NetworkObservationJournal,network_extra_info_available: bool,@@ -804,7 +804,7 @@ pub(crate) struct CompletedMainDocumentNetworkEvents {pub(crate) request_headers: Vec<(String, String)>,pub(crate) final_request_cookie_report: Option<StoredCookieQueryReport>,pub(crate) response_status: u16,- pub(crate) response_headers: Vec<(String, String)>,+ pub(crate) response_headers: Vec<(String, Vec<u8>)>,pub(crate) response_cookie_reports: Vec<StoredCookieSetReport>,pub(crate) redirect_chain: Vec<NavigationRedirect>,pub(crate) network_extra_info_available: bool,@@ -820,7 +820,7 @@ impl CompletedMainDocumentNetworkEvents {request_headers: Vec<(String, String)>,final_request_cookie_report: Option<StoredCookieQueryReport>,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_cookie_reports: Vec<StoredCookieSetReport>,redirect_chain: Vec<NavigationRedirect>,network_extra_info_available: bool,@@ -1108,7 +1108,7 @@ impl MainDocumentLiveNetworkProgressSource {&self,final_url: &Url,response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],response_cookie_reports: &[StoredCookieSetReport],network_observation_journal: &NetworkObservationJournal,redirect_count: usize,@@ -1142,7 +1142,7 @@ impl MainDocumentLiveNetworkProgressSource {&self,final_url: &Url,response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],network_extra_info_available: bool,response_from_cache: bool,negotiated_http_version: Option<NegotiatedHttpVersion>,@@ -1166,10 +1166,10 @@ impl MainDocumentLiveNetworkProgressSource {&self,final_url: &Url,response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],response_cookie_reports: &[StoredCookieSetReport],extra_info_status: u16,- extra_info_headers: Vec<(String, String)>,+ extra_info_headers: Vec<(String, Vec<u8>)>,network_extra_info_available: bool,emit_extra_info: bool,response_from_cache: bool,@@ -1200,7 +1200,7 @@ impl MainDocumentLiveNetworkProgressSource {&self,output: &mut MainDocumentProgressOutputTarget<'_>,response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],response_cookie_reports: &[StoredCookieSetReport],) {self.send_progress_events_into_output(@@ -1843,7 +1843,7 @@ enum MainDocumentNavigationProgressEvent {},ResponseReceivedExtraInfo {target: MainDocumentProgressEventTarget,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,status: u16,cookie_set_reports: Vec<StoredCookieSetReport>,},@@ -1851,10 +1851,10 @@ enum MainDocumentNavigationProgressEvent {target: MainDocumentProgressEventTarget,final_url: Url,status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,cookie_set_reports: Vec<StoredCookieSetReport>,extra_info_status: u16,- extra_info_headers: Vec<(String, String)>,+ extra_info_headers: Vec<(String, Vec<u8>)>,network_extra_info_available: bool,emit_extra_info: bool,encoded_data_length: usize,@@ -1876,7 +1876,7 @@ pub(crate) struct MainDocumentRedirectResponse {pub(crate) url: Url,pub(crate) status: u16,pub(crate) status_text: Option<String>,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,pub(crate) from_cache: bool,pub(crate) negotiated_http_version: Option<NegotiatedHttpVersion>,}@@ -1928,7 +1928,7 @@ fn navigation_exchange_group(let ends_redirect_hop = exchange.response().is_some_and(|response| {matches!(response.status(), 301 | 302 | 303 | 307 | 308)|| response.headers().iter().any(|(name, value)| {- name.eq_ignore_ascii_case("critical-ch") && !value.trim().is_empty()+ name.eq_ignore_ascii_case("critical-ch") && !value.trim_ascii().is_empty()})});if !ends_redirect_hop || current_hop >= redirect_count {@@ -1960,8 +1960,8 @@ fn observed_response_metadata(redirect_count: usize,hop_index: usize,fallback_status: u16,- fallback_headers: &[(String, String)],-) -> (u16, Vec<(String, String)>) {+ fallback_headers: &[(String, Vec<u8>)],+) -> (u16, Vec<(String, Vec<u8>)>) {navigation_exchange_group(journal, redirect_count, hop_index).and_then(|group| group.last()).and_then(NetworkExchangeObservation::response)diff --git a/moli-protocol/src/domains/network/main_document_progress/tests.rs b/moli-protocol/src/domains/network/main_document_progress/tests.rsindex 0e9922e88..d5e79a961 100644--- a/moli-protocol/src/domains/network/main_document_progress/tests.rs+++ b/moli-protocol/src/domains/network/main_document_progress/tests.rs@@ -24,7 +24,7 @@ fn completed_events() -> CompletedMainDocumentNetworkEvents {vec![("Accept".to_owned(), "text/html".to_owned())],None,200,- vec![("Content-Type".to_owned(), "text/html".to_owned())],+ vec![("Content-Type".to_owned(), b"text/html".to_vec())],Vec::new(),Vec::new(),false,@@ -41,7 +41,10 @@ fn observation_journal(.map(|(request_headers, status, response_headers)| {NetworkExchangeObservation::new(NetworkRequestObservation::new(request_headers),- Some(NetworkResponseObservation::new(status, response_headers)),+ Some(NetworkResponseObservation::new(+ status,+ moli_fetch::headers_from_byte_strings(&response_headers).unwrap(),+ )),)}).collect(),@@ -126,7 +129,10 @@ fn failed_redirect_transport_emits_completed_hop_and_final_request_extra_info()from_url: Url::parse("http://example.test/start").unwrap(),to_url: final_url.clone(),status: 302,- headers: vec![("Location".to_owned(), final_url.to_string())],+ headers: vec![(+ "Location".to_owned(),+ final_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: true,request_extra_info: None,response_extra_info: None,@@ -144,7 +150,7 @@ fn failed_redirect_transport_emits_completed_hop_and_final_request_extra_info())]),Some(NetworkResponseObservation::new(302,- vec![("X-Response-Hop".to_owned(), "redirect".to_owned())],+ vec![("X-Response-Hop".to_owned(), b"redirect".to_vec())],)),),NetworkExchangeObservation::new(@@ -255,10 +261,10 @@ fn response_progress_batch_for_output_target() -> MainDocumentProgressEventBatch},final_url: Url::parse("http://example.test/target").unwrap(),status: 200,- headers: vec![("Content-Type".to_owned(), "text/html".to_owned())],+ headers: vec![("Content-Type".to_owned(), b"text/html".to_vec())],cookie_set_reports: Vec::new(),extra_info_status: 200,- extra_info_headers: vec![("Content-Type".to_owned(), "text/html".to_owned())],+ extra_info_headers: vec![("Content-Type".to_owned(), b"text/html".to_vec())],network_extra_info_available: false,emit_extra_info: false,encoded_data_length: 29,@@ -409,7 +415,10 @@ fn live_progress_source_serializes_through_progress_emissions() {from_url: Url::parse("http://example.test/start").unwrap(),to_url: final_url.clone(),status: 302,- headers: vec![("Location".to_owned(), final_url.to_string())],+ headers: vec![(+ "Location".to_owned(),+ final_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: true,request_extra_info: None,response_extra_info: None,@@ -444,7 +453,7 @@ fn live_progress_source_serializes_through_progress_emissions() {source.emit_response_received(&final_url,200,- &[("Content-Type".to_owned(), "text/html".to_owned())],+ &[("Content-Type".to_owned(), b"text/html".to_vec())],&[],&journal,1,@@ -696,7 +705,7 @@ fn completed_body_revalidation_keeps_raw_304_extra_info() {let mut events = completed_events();events.network_extra_info_available = true;events.response_status = 200;- events.response_headers = vec![("X-Merged-Response".to_owned(), "cached".to_owned())];+ events.response_headers = vec![("X-Merged-Response".to_owned(), b"cached".to_vec())];events = events.with_network_observation_journal(observation_journal(vec![(vec![("If-None-Match".to_owned(), "\"v1\"".to_owned())],304,@@ -763,7 +772,10 @@ fn completed_body_http_redirect_emits_correlated_no_cookie_extra_info() {from_url: Url::parse("http://example.test/start").unwrap(),to_url: final_url.clone(),status: 302,- headers: vec![("location".to_owned(), final_url.to_string())],+ headers: vec![(+ "location".to_owned(),+ final_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: true,request_extra_info: None,response_extra_info: None,@@ -859,7 +871,10 @@ fn completed_body_redirect_without_transport_extra_info_keeps_flag_false() {from_url: Url::parse("http://example.test/start").unwrap(),to_url: final_url.clone(),status: 302,- headers: vec![("location".to_owned(), final_url.to_string())],+ headers: vec![(+ "location".to_owned(),+ final_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,@@ -928,7 +943,10 @@ fn critical_client_hint_restart_keeps_discarded_response_extra_info_separate_frofrom_url: navigation_url.clone(),to_url: navigation_url.clone(),status: 307,- headers: vec![("Location".to_owned(), navigation_url.to_string())],+ headers: vec![(+ "Location".to_owned(),+ navigation_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,@@ -1005,7 +1023,10 @@ fn completed_body_uses_negotiated_protocol_for_redirect_and_final_response() {from_url: Url::parse("https://example.test/start").unwrap(),to_url: final_url.clone(),status: 302,- headers: vec![("location".to_owned(), final_url.to_string())],+ headers: vec![(+ "location".to_owned(),+ final_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,@@ -1083,7 +1104,10 @@ fn cached_completed_body_redirect_emits_cache_event_before_next_request() {from_url: Url::parse("http://example.test/start").unwrap(),to_url: final_url.clone(),status: 302,- headers: vec![("location".to_owned(), final_url.to_string())],+ headers: vec![(+ "location".to_owned(),+ final_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,diff --git a/moli-protocol/src/domains/network/output_queue.rs b/moli-protocol/src/domains/network/output_queue.rsindex 770a585b4..90e6199a4 100644--- a/moli-protocol/src/domains/network/output_queue.rs+++ b/moli-protocol/src/domains/network/output_queue.rs@@ -1517,7 +1517,7 @@ pub(crate) struct TargetSubresourceResponseStartedOutput {final_url: Url,status: u16,status_text: Option<String>,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,cookie_set_reports: Vec<StoredCookieSetReport>,from_cache: bool,network_request_headers: Option<Vec<(String, String)>>,@@ -1585,7 +1585,7 @@ impl TargetSubresourceResponseStartedOutput {self.status_text.as_deref()}- pub(crate) fn response_headers(&self) -> &[(String, String)] {+ pub(crate) fn response_headers(&self) -> &[(String, Vec<u8>)] {&self.response_headers}@@ -2135,7 +2135,7 @@ pub(crate) enum TargetSubresourceMetadataOutcome {final_url: Url,status: u16,status_text: Option<String>,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body_len: usize,},Failure {@@ -2176,7 +2176,7 @@ pub(crate) struct TargetSubresourceRedirectOutput {pub(crate) from_url: Url,pub(crate) to_url: Url,pub(crate) status: u16,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,pub(crate) request_cookie_report: Option<StoredCookieQueryReport>,pub(crate) cookie_set_reports: Vec<StoredCookieSetReport>,pub(crate) from_cache: bool,@@ -2349,7 +2349,7 @@ impl TargetWebSocketHandshakeDeliveryOutput {#[derive(Clone, Debug, Eq, PartialEq)]pub(crate) struct TargetWebSocketHandshakeResponseOutput {status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,}impl TargetWebSocketHandshakeResponseOutput {@@ -2357,7 +2357,7 @@ impl TargetWebSocketHandshakeResponseOutput {self.status}- pub(crate) fn response_headers(&self) -> &[(String, String)] {+ pub(crate) fn response_headers(&self) -> &[(String, Vec<u8>)] {&self.response_headers}}@@ -3278,7 +3278,7 @@ mod tests {Vec::new(),url,101,- vec![("Upgrade".to_owned(), "websocket".to_owned())],+ vec![("Upgrade".to_owned(), b"websocket".to_vec())],String::new(),Vec::new(),)@@ -3405,7 +3405,7 @@ mod tests {Vec::new(),request_url,200,- vec![("content-type".to_owned(), "image/png".to_owned())],+ vec![("content-type".to_owned(), b"image/png".to_vec())],Vec::new(),).with_from_cache(true);@@ -3720,7 +3720,10 @@ mod tests {from_url: start_url.clone(),to_url: final_url.clone(),status: 307,- headers: vec![("location".to_owned(), final_url.to_string())],+ headers: vec![(+ "location".to_owned(),+ final_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,@@ -3827,7 +3830,7 @@ mod tests {url: &str,request_headers: Vec<(String, String)>,status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,) -> TargetSubresourceMetadataOutput {expected_subresource_metadata_with_delivery_order(index,@@ -3847,7 +3850,7 @@ mod tests {url: &str,request_headers: Vec<(String, String)>,status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,) -> TargetSubresourceMetadataOutput {let url = Url::parse(url).expect("test URL should parse");TargetSubresourceMetadataOutput {@@ -3921,7 +3924,7 @@ mod tests {"wss://example.com/socket",vec![("Sec-WebSocket-Version".to_owned(), "13".to_owned())],101,- vec![("Upgrade".to_owned(), "websocket".to_owned())],+ vec![("Upgrade".to_owned(), b"websocket".to_vec())],),expected_subresource_metadata_with_delivery_order(2,@@ -3990,7 +3993,7 @@ mod tests {"wss://example.com/socket",vec![("Sec-WebSocket-Version".to_owned(), "13".to_owned())],101,- vec![("Upgrade".to_owned(), "websocket".to_owned())],+ vec![("Upgrade".to_owned(), b"websocket".to_vec())],),expected_subresource_metadata_with_delivery_order(2,@@ -4186,7 +4189,7 @@ mod tests {"wss://example.com/socket",vec![("Sec-WebSocket-Version".to_owned(), "13".to_owned())],101,- vec![("Upgrade".to_owned(), "websocket".to_owned())],+ vec![("Upgrade".to_owned(), b"websocket".to_vec())],),]);@@ -4233,7 +4236,7 @@ mod tests {"wss://example.com/socket",vec![("Sec-WebSocket-Version".to_owned(), "13".to_owned())],101,- vec![("Upgrade".to_owned(), "websocket".to_owned())],+ vec![("Upgrade".to_owned(), b"websocket".to_vec())],),],"syncing only new websocket events should not rescan records or duplicate handshake state"@@ -4433,7 +4436,7 @@ mod tests {assert_eq!(response.status(), 101);assert_eq!(response.response_headers(),- &[("Upgrade".to_owned(), "websocket".to_owned())]+ &[("Upgrade".to_owned(), b"websocket".to_vec())]);}diff --git a/moli-protocol/src/domains/network/tests/navigation.rs b/moli-protocol/src/domains/network/tests/navigation.rsindex 674324338..d261082db 100644--- a/moli-protocol/src/domains/network/tests/navigation.rs+++ b/moli-protocol/src/domains/network/tests/navigation.rs@@ -511,7 +511,7 @@ async fn main_document_navigation_events_include_synthesized_cookie_header() {let mut jar = bc.cookie_store_for_test().lock();jar.store_response_headers(&Url::parse(&page_url).unwrap(),- &[("set-cookie".to_owned(), "sid=1; Path=/page".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/page".to_vec())],);}ctx.conn.install_browser_context_fixture_for_test(bc);@@ -607,7 +607,7 @@ async fn main_document_navigation_deduplicates_manual_cookie_header_when_store_slet mut jar = bc.cookie_store_for_test().lock();jar.store_response_headers(&Url::parse(&page_url).unwrap(),- &[("set-cookie".to_owned(), "sid=store; Path=/page".to_owned())],+ &[("set-cookie".to_owned(), b"sid=store; Path=/page".to_vec())],);}ctx.conn.install_browser_context_fixture_for_test(bc);@@ -707,7 +707,7 @@ async fn main_document_navigation_redirect_emits_second_request_with_redirect_re&Url::parse(&final_url).unwrap(),&[("set-cookie".to_owned(),- "strict=1; Path=/; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; SameSite=Strict".to_vec(),)],);}@@ -1155,7 +1155,7 @@ async fn main_document_multi_hop_redirect_preserves_cookie_downgrade_report() {&Url::parse(&final_url).unwrap(),&[("set-cookie".to_owned(),- "strict=1; Path=/; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; SameSite=Strict".to_vec(),)],);}diff --git a/moli-protocol/src/domains/network/tests/response_body.rs b/moli-protocol/src/domains/network/tests/response_body.rsindex f31eee160..4c31aba9f 100644--- a/moli-protocol/src/domains/network/tests/response_body.rs+++ b/moli-protocol/src/domains/network/tests/response_body.rs@@ -359,7 +359,7 @@ async fn get_response_body_returns_partial_body_after_staged_loading_failed() {Vec::new(),request_url.clone(),200,- vec![("content-type".to_owned(), "text/plain".to_owned())],+ vec![("content-type".to_owned(), b"text/plain".to_vec())],Vec::new(),);let body = SubresourceBodyFinished::failed_with_partial_body(diff --git a/moli-protocol/src/domains/network/tests/subresource.rs b/moli-protocol/src/domains/network/tests/subresource.rsindex 8141c3883..1a1fa164c 100644--- a/moli-protocol/src/domains/network/tests/subresource.rs+++ b/moli-protocol/src/domains/network/tests/subresource.rs@@ -1309,7 +1309,7 @@ fetch('/api')let mut jar = bc.cookie_store_for_test().lock();jar.store_response_headers(&Url::parse(&api_url).unwrap(),- &[("set-cookie".to_owned(), "sid=1; Path=/api".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/api".to_vec())],);}ctx.conn.install_browser_context_fixture_for_test(bc);@@ -3101,7 +3101,7 @@ fetch('{start_url}', {{ credentials: 'include' }})&Url::parse(&final_url).unwrap(),&[("set-cookie".to_owned(),- "strict=1; Path=/; SameSite=Strict".to_owned(),+ b"strict=1; Path=/; SameSite=Strict".to_vec(),)],);}@@ -3338,7 +3338,7 @@ fetch('{target_url}', {{ credentials: 'include' }})let mut jar = bc.cookie_store_for_test().lock();jar.store_response_headers(&Url::parse("http://127.0.0.1:8443/").unwrap(),- &[("set-cookie".to_owned(), "sid=1; Path=/".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/".to_vec())],);}ctx.conn.install_browser_context_fixture_for_test(bc);@@ -3431,7 +3431,7 @@ fetch('{target_url}')let mut jar = bc.cookie_store_for_test().lock();jar.store_response_headers(&Url::parse(&format!("http://localhost:{}/", addr.port())).unwrap(),- &[("set-cookie".to_owned(), "sid=1; Path=/; Secure".to_owned())],+ &[("set-cookie".to_owned(), b"sid=1; Path=/; Secure".to_vec())],);}ctx.conn.install_browser_context_fixture_for_test(bc);diff --git a/moli-protocol/src/domains/page.rs b/moli-protocol/src/domains/page.rsindex c8aaf4912..a4a9979d3 100644--- a/moli-protocol/src/domains/page.rs+++ b/moli-protocol/src/domains/page.rs@@ -4123,7 +4123,7 @@ mod producer_tests {request_headers: vec![("Accept".to_owned(), "text/html".to_owned())],final_url: "https://example.test/child".to_owned(),status: 200,- response_headers: vec![("Content-Type".to_owned(), "text/html".to_owned())],+ response_headers: vec![("Content-Type".to_owned(), b"text/html".to_vec())],encoded_data_length: 3,response_body: Some(SubresourceResponseBody::from_bytes(vec![0x00, 0xff, b'a',@@ -4261,7 +4261,7 @@ mod producer_tests {request_headers: Vec::new(),final_url: "https://example.test/retired-child".to_owned(),status: 200,- response_headers: vec![("Content-Type".to_owned(), "text/html".to_owned())],+ response_headers: vec![("Content-Type".to_owned(), b"text/html".to_vec())],encoded_data_length: 21,response_body: Some(SubresourceResponseBody::from_bytes(b"historical child body".to_vec(),@@ -4369,7 +4369,7 @@ mod producer_tests {request_headers: Vec::new(),final_url: "https://example.test/legacy-child".to_owned(),status: 200,- response_headers: vec![("Content-Type".to_owned(), "text/html".to_owned())],+ response_headers: vec![("Content-Type".to_owned(), b"text/html".to_vec())],encoded_data_length: 0,response_body: None,from_cache: false,diff --git a/moli-protocol/src/domains/page/navigation.rs b/moli-protocol/src/domains/page/navigation.rsindex b7ff9a6b9..03607573b 100644--- a/moli-protocol/src/domains/page/navigation.rs+++ b/moli-protocol/src/domains/page/navigation.rs@@ -440,7 +440,7 @@ pub struct BackgroundMainDocumentBodyCompletion {synthetic: bool,body_progress_source: network::MainDocumentBodyProgressSource,final_url: Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_from_cache: bool,}@@ -452,7 +452,7 @@ impl BackgroundMainDocumentBodyCompletion {synthetic: bool,body_progress_source: network::MainDocumentBodyProgressSource,final_url: Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_from_cache: bool,) -> Self {Self {@@ -595,7 +595,7 @@ impl BackgroundNavigationCompletion {synthetic: bool,body_progress_source: network::MainDocumentBodyProgressSource,final_url: Url,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_from_cache: bool,) -> Self {Self::MainDocumentBody(Box::new(BackgroundMainDocumentBodyCompletion::new(diff --git a/moli-protocol/src/domains/page/resource_search.rs b/moli-protocol/src/domains/page/resource_search.rsindex 3e6347c53..7d87eaf53 100644--- a/moli-protocol/src/domains/page/resource_search.rs+++ b/moli-protocol/src/domains/page/resource_search.rs@@ -372,7 +372,7 @@ fn subresource_url_matches(record: &SubresourceNetworkRecord, requested_url: &stfn decode_resource_content(bytes: &[u8],- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],kind: ResourceContentKind,) -> String {let mime = effective_response_mime_essence(headers, None).unwrap_or_default();@@ -436,9 +436,9 @@ mod tests {#[test]fn html_resource_decoding_observes_declared_charset() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("content-type".to_owned(),- "text/html; charset=windows-1252".to_owned(),+ b"text/html; charset=windows-1252".to_vec(),)];assert_eq!(decode_resource_content(b"<p>\x80</p>", &headers, ResourceContentKind::MainDocument,),@@ -448,9 +448,9 @@ mod tests {#[test]fn stylesheet_resource_rejects_invalid_response_charset_whitespace() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("content-type".to_owned(),- "text/css; charset=\nshift_jis".to_owned(),+ b"text/css; charset=\nshift_jis".to_vec(),)];assert_eq!(@@ -470,7 +470,7 @@ mod tests {&[0, 255],&[("content-type".to_owned(),- "application/octet-stream".to_owned(),+ b"application/octet-stream".to_vec(),)],ResourceContentKind::Subresource(SubresourceResourceType::Image),),diff --git a/moli-protocol/src/domains/page/resource_tree.rs b/moli-protocol/src/domains/page/resource_tree.rsindex 4db54cace..0915e8118 100644--- a/moli-protocol/src/domains/page/resource_tree.rs+++ b/moli-protocol/src/domains/page/resource_tree.rs@@ -152,7 +152,7 @@ mod tests {Vec::new(),Url::parse(final_url).unwrap(),200,- vec![("Content-Type".to_owned(), content_type.to_owned())],+ vec![("Content-Type".to_owned(), content_type.as_bytes().to_vec())],body.to_owned(),Vec::new(),)diff --git a/moli-protocol/src/domains/runtime/tests/evaluate.rs b/moli-protocol/src/domains/runtime/tests/evaluate.rsindex c2924a689..06c4ec907 100644--- a/moli-protocol/src/domains/runtime/tests/evaluate.rs+++ b/moli-protocol/src/domains/runtime/tests/evaluate.rs@@ -2487,7 +2487,7 @@ async fn page_navigate_network_failure_commits_error_document() {false,crate::domains::network::MainDocumentBodyProgressSource::default(),url::Url::parse("https://stale.example.test/old-body").unwrap(),- vec![("content-type".to_owned(), "text/plain".to_owned())],+ vec![("content-type".to_owned(), b"text/plain".to_vec())],false,);let (stale_completion_messages, stale_completion_scheduler_events) = ctxdiff --git a/moli-protocol/src/domains/storage/tests.rs b/moli-protocol/src/domains/storage/tests.rsindex dc9f72839..d9cecc2c9 100644--- a/moli-protocol/src/domains/storage/tests.rs+++ b/moli-protocol/src/domains/storage/tests.rs@@ -1293,7 +1293,7 @@ fn cookie_query_report_json_projects_specific_same_site_warning_taxonomy() {&url,&[("set-cookie".to_owned(),- "lax=1; Path=/foo; Secure; SameSite=Lax".to_owned(),+ b"lax=1; Path=/foo; Secure; SameSite=Lax".to_vec(),)],);@@ -1352,7 +1352,7 @@ fn associated_cookies_json_projects_path_mismatch_to_cdp_not_on_path() {&response_url,&[("set-cookie".to_owned(),- "sid=1; Path=/private; Secure".to_owned(),+ b"sid=1; Path=/private; Secure".to_vec(),)],);diff --git a/moli-protocol/src/domains/target/worker_target.rs b/moli-protocol/src/domains/target/worker_target.rsindex 21a4dffa1..9d62ad617 100644--- a/moli-protocol/src/domains/target/worker_target.rs+++ b/moli-protocol/src/domains/target/worker_target.rs@@ -3862,7 +3862,7 @@ mod tests {let mut response = moli_core::page::NavigationResponse::from_text_body(Url::parse(url).unwrap(),status,- vec![("content-type".to_owned(), "text/javascript".to_owned())],+ vec![("content-type".to_owned(), b"text/javascript".to_vec())],"postMessage('ready')".to_owned(),);if transport {@@ -6433,7 +6433,7 @@ mod tests {final_url: "https://example.test/api".to_owned(),status: 201,status_text: "Created".to_owned(),- response_headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ response_headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],body_len: 2,},};@@ -6479,7 +6479,7 @@ mod tests {final_url: "https://example.test/api".to_owned(),status: 201,status_text: "Created".to_owned(),- response_headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ response_headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],body_len: 2,},},diff --git a/moli-renderer-v8/src/app_manifest.rs b/moli-renderer-v8/src/app_manifest.rsindex e263cda92..4f20c891b 100644--- a/moli-renderer-v8/src/app_manifest.rs+++ b/moli-renderer-v8/src/app_manifest.rs@@ -345,7 +345,7 @@ impl RendererPreparedAppManifestLoad {}}-fn decode_manifest_source(body: &[u8], headers: &[(String, String)]) -> String {+fn decode_manifest_source(body: &[u8], headers: &[(String, Vec<u8>)]) -> String {let content_type = moli_web_mime::response_content_type(headers);let charset = content_type.as_deref()@@ -965,7 +965,7 @@ mod tests {b"{\"name\":\"caf\xe9\"}",&[("content-type".to_owned(),- "application/manifest+json; charset=windows-1252".to_owned(),+ b"application/manifest+json; charset=windows-1252".to_vec(),)],);assert_eq!(source, "{\"name\":\"caf\u{e9}\"}");diff --git a/moli-renderer-v8/src/content_security_policy.rs b/moli-renderer-v8/src/content_security_policy.rsindex f12198cfb..466289fda 100644--- a/moli-renderer-v8/src/content_security_policy.rs+++ b/moli-renderer-v8/src/content_security_policy.rs@@ -279,20 +279,21 @@ fn security_policy_violation_event_declaration<'s>(})}-pub(crate) fn content_security_policy_headers(headers: &[(String, String)]) -> Vec<String> {+pub(crate) fn content_security_policy_headers(headers: &[(String, Vec<u8>)]) -> Vec<String> {content_security_policy_header_values(headers, "content-security-policy")}pub(crate) fn content_security_policy_report_only_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Vec<String> {content_security_policy_header_values(headers, "content-security-policy-report-only")}fn content_security_policy_header_values(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],header_name: &str,) -> Vec<String> {+ let headers = moli_fetch::headers_to_byte_strings(headers);// Each HTTP field can contain several independently enforced policies.// Commas are CSP list delimiters even inside quotes in directive values;// the quoted-string rules used by Reporting-Endpoints do not apply here.@@ -394,7 +395,7 @@ pub(crate) fn content_security_policy_report_uri_endpoints(}pub(crate) fn content_security_policy_reporting_endpoints_from_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],protected_url: &Url,) -> ContentSecurityPolicyReportingEndpoints {let mut endpoints = ContentSecurityPolicyReportingEndpoints::default();@@ -402,7 +403,11 @@ pub(crate) fn content_security_policy_reporting_endpoints_from_headers(.iter().filter(|(name, _)| name.eq_ignore_ascii_case("reporting-endpoints")){- parse_reporting_endpoints_header(value, protected_url, &mut endpoints);+ parse_reporting_endpoints_header(+ &moli_fetch::decode_header_value(value),+ protected_url,+ &mut endpoints,+ );}endpoints}@@ -2120,16 +2125,16 @@ mod tests {#[test]fn content_security_policy_headers_collect_enforce_headers_only() {- let headers = vec![+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Security-Policy-Report-Only".to_owned(),- "worker-src 'none'".to_owned(),+ b"worker-src 'none'".to_vec(),),("content-security-policy".to_owned(),- " worker-src 'self' ".to_owned(),+ b" worker-src 'self' ".to_vec(),),- ("Content-Security-Policy".to_owned(), String::new()),+ ("Content-Security-Policy".to_owned(), Vec::new()),];assert_eq!(@@ -2144,18 +2149,18 @@ mod tests {#[test]fn csp_headers_preserve_policy_order_and_disposition() {- let headers = vec![+ let headers: Vec<(String, Vec<u8>)> = vec![("CONTENT-SECURITY-POLICY".to_owned(),- " , img-src *; report-uri /first, img-src 'none'; report-uri /second, ".to_owned(),+ b" , img-src *; report-uri /first, img-src 'none'; report-uri /second, ".to_vec(),),("Content-Security-Policy-Report-Only".to_owned(),- "script-src * , script-src 'none'".to_owned(),+ b"script-src * , script-src 'none'".to_vec(),),("content-security-policy".to_owned(),- "worker-src 'self'".to_owned(),+ b"worker-src 'self'".to_vec(),),];assert_eq!(@@ -2229,7 +2234,7 @@ mod tests {] {let policies = content_security_policy_headers(&[("Content-Security-Policy".to_owned(),- value.to_owned(),+ value.as_bytes().to_vec(),)]);assert_eq!(content_security_policy_allows_url(@@ -2246,11 +2251,11 @@ mod tests {#[test]fn csp_header_lists_keep_report_only_violations_with_their_policy() {- let headers = vec![- ("Content-Security-Policy".to_owned(), "img-src *".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Content-Security-Policy".to_owned(), b"img-src *".to_vec()),("Content-Security-Policy-Report-Only".to_owned(),- "img-src *; report-uri /allowed, img-src 'none'; report-uri /blocked".to_owned(),+ b"img-src *; report-uri /allowed, img-src 'none'; report-uri /blocked".to_vec(),),];let protected = protected_url();@@ -2287,19 +2292,19 @@ mod tests {"content-security-policy","content-security-policy-report-only",] {- let collect = |value: &str| {- content_security_policy_header_values(&[(name.to_owned(), value.to_owned())], name)+ let collect = |value: &[u8]| {+ content_security_policy_header_values(&[(name.to_owned(), value.to_vec())], name)};- assert!(collect(", ; ; , \t , img-src 'none'\u{00a0},").is_empty());+ assert!(collect(b", ; ; , \t , img-src 'none'\xa0,").is_empty());assert_eq!(- collect("\t\n\r\u{000c} img-src 'none' , \t"),+ collect(b"\t\n\r\x0c img-src 'none' , \t"),["img-src 'none'"]);assert_eq!(- collect("img-src *\u{000b}, img-src 'none'"),+ collect(b"img-src *\x0b, img-src 'none'"),["img-src *\u{000b}", "img-src 'none'"]);- let policies = collect("img-src *\u{000b}");+ let policies = collect(b"img-src *\x0b");assert!(!content_security_policy_allows_url(&policies,&protected_url(),@@ -3583,11 +3588,11 @@ mod tests {&[("Reporting-Endpoints".to_owned(),- "default=\"/reports\", csp=\"https://reports.test/csp\"".to_owned(),+ b"default=\"/reports\", csp=\"https://reports.test/csp\"".to_vec(),),("reporting-endpoints".to_owned(),- "default=\"/override\", ignored=ftp://reports.test/nope".to_owned(),+ b"default=\"/override\", ignored=ftp://reports.test/nope".to_vec(),),],&protected_url(),@@ -3609,7 +3614,7 @@ mod tests {let reporting_endpoints = content_security_policy_reporting_endpoints_from_headers(&[("Reporting-Endpoints".to_owned(),- "primary=\"/reports/primary\", secondary=\"/reports/secondary\"".to_owned(),+ b"primary=\"/reports/primary\", secondary=\"/reports/secondary\"".to_vec(),)],&protected_url(),);diff --git a/moli-renderer-v8/src/context_bootstrap/performance_runtime.rs b/moli-renderer-v8/src/context_bootstrap/performance_runtime.rsindex b9c381d10..fc9db31c0 100644--- a/moli-renderer-v8/src/context_bootstrap/performance_runtime.rs+++ b/moli-renderer-v8/src/context_bootstrap/performance_runtime.rs@@ -291,7 +291,7 @@ impl ResourcePerformanceEntry {initiator_type: &'static str,start_unix_millis: Option<f64>,response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],body_size: f64,) -> Self {let header_size = response_headersdiff --git a/moli-renderer-v8/src/context_bootstrap/window_runtime/navigator.rs b/moli-renderer-v8/src/context_bootstrap/window_runtime/navigator.rsindex b2f6d5627..4994605c6 100644--- a/moli-renderer-v8/src/context_bootstrap/window_runtime/navigator.rs+++ b/moli-renderer-v8/src/context_bootstrap/window_runtime/navigator.rs@@ -1905,7 +1905,7 @@ struct StorageBucketCachePutPendingData<'scope> {response_redirected: bool,response_status: u16,response_status_text: String,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,}fn storage_bucket_cache_put_pending_data<'s>(@@ -1961,7 +1961,7 @@ fn storage_bucket_cache_put_pending_data<'s>(let response_headers_json =data_private_string(scope, data, STORAGE_BUCKET_CACHE_PUT_RESPONSE_HEADERS_SLOT)?;let response_headers =- serde_json::from_str::<Vec<(String, String)>>(&response_headers_json).unwrap_or_default();+ serde_json::from_str::<Vec<(String, Vec<u8>)>>(&response_headers_json).unwrap_or_default();let bucket = StorageBucketHandle {identity: StorageBucketIdentity::new(&bucket_origin, &bucket_name, bucket_id),indexed_db_storage_key: bucket_storage_key,@@ -2949,7 +2949,10 @@ fn build_storage_bucket_cached_response_object<'s>();let status_text = v8_string(scope, &response.status_text)?;init.set_string_property(scope, "statusText", status_text.into());- let headers = headers_entries_to_init_array(scope, &response.headers);+ let headers = headers_entries_to_init_array(+ scope,+ &moli_fetch::headers_to_byte_strings(&response.headers),+ );init.set_string_property(scope, "headers", headers.into());let global = scope.get_current_context().global(scope);let constructor = globaldiff --git a/moli-renderer-v8/src/context_bootstrap/worker_host/constructor.rs b/moli-renderer-v8/src/context_bootstrap/worker_host/constructor.rsindex 0f2c968b1..e3b2205d3 100644--- a/moli-renderer-v8/src/context_bootstrap/worker_host/constructor.rs+++ b/moli-renderer-v8/src/context_bootstrap/worker_host/constructor.rs@@ -1010,7 +1010,11 @@ fn local_worker_main_script_network_response(crate::protocol_types::NavigationResponse::from_text_body(resource_url,200,- vec![("content-type".to_owned(), mime_type)],+ vec![(+ "content-type".to_owned(),+ moli_fetch::header_value_from_byte_string(&mime_type)+ .expect("serialized MIME types contain ByteStrings"),+ )],source.to_owned(),)}diff --git a/moli-renderer-v8/src/cross_origin_isolation.rs b/moli-renderer-v8/src/cross_origin_isolation.rsindex 8b258be01..9d5b98a3f 100644--- a/moli-renderer-v8/src/cross_origin_isolation.rs+++ b/moli-renderer-v8/src/cross_origin_isolation.rs@@ -18,7 +18,7 @@ pub(crate) enum DocumentIsolationPolicy {pub(crate) fn response_headers_enable_cross_origin_isolation(final_url: &Url,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> bool {if !moli_url::is_potentially_trustworthy_url(final_url) {return false;@@ -32,7 +32,7 @@ pub(crate) fn response_headers_enable_cross_origin_isolation(}pub(crate) fn cross_origin_embedder_policy_from_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> CrossOriginEmbedderPolicy {match response_header_policy_value(headers, "cross-origin-embedder-policy").as_deref() {Some("require-corp") => CrossOriginEmbedderPolicy::RequireCorp,@@ -42,7 +42,7 @@ pub(crate) fn cross_origin_embedder_policy_from_headers(}pub(crate) fn document_isolation_policy_from_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> DocumentIsolationPolicy {match response_header_policy_value(headers, "document-isolation-policy").as_deref() {Some("isolate-and-require-corp") => DocumentIsolationPolicy::IsolateAndRequireCorp,@@ -82,13 +82,13 @@ impl DocumentIsolationPolicy {}}-fn response_header_policy_value(headers: &[(String, String)], name: &str) -> Option<String> {+fn response_header_policy_value(headers: &[(String, Vec<u8>)], name: &str) -> Option<String> {headers.iter().rev().find(|(header_name, _)| header_name.eq_ignore_ascii_case(name)).map(|(_, value)| {- value+ moli_fetch::decode_header_value(value).split(';').next().unwrap_or_default()@@ -104,14 +104,14 @@ mod tests {#[test]fn coop_coep_headers_enable_cross_origin_isolation_for_trustworthy_urls() {let url = Url::parse("https://example.test/").expect("valid url");- let headers = vec![+ let headers: Vec<(String, Vec<u8>)> = vec![("Cross-Origin-Embedder-Policy".to_owned(),- "require-corp".to_owned(),+ b"require-corp".to_vec(),),("Cross-Origin-Opener-Policy".to_owned(),- "same-origin".to_owned(),+ b"same-origin".to_vec(),),];assert!(response_headers_enable_cross_origin_isolation(@@ -122,9 +122,9 @@ mod tests {#[test]fn cross_origin_isolation_requires_both_headers() {let url = Url::parse("https://example.test/").expect("valid url");- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Cross-Origin-Opener-Policy".to_owned(),- "same-origin".to_owned(),+ b"same-origin".to_vec(),)];assert!(!response_headers_enable_cross_origin_isolation(&url, &headers@@ -134,9 +134,9 @@ mod tests {#[test]fn document_isolation_policy_enables_cross_origin_isolation_for_trustworthy_urls() {let url = Url::parse("https://example.test/").expect("valid url");- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Document-Isolation-Policy".to_owned(),- "isolate-and-require-corp".to_owned(),+ b"isolate-and-require-corp".to_vec(),)];assert!(response_headers_enable_cross_origin_isolation(&url, &headers@@ -146,9 +146,9 @@ mod tests {#[test]fn document_isolation_policy_cross_origin_isolation_requires_trustworthy_url() {let url = Url::parse("http://example.test/").expect("valid url");- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Document-Isolation-Policy".to_owned(),- "isolate-and-credentialless".to_owned(),+ b"isolate-and-credentialless".to_vec(),)];assert!(!response_headers_enable_cross_origin_isolation(&url, &headers@@ -160,21 +160,21 @@ mod tests {assert_eq!(cross_origin_embedder_policy_from_headers(&[("Cross-Origin-Embedder-Policy".to_owned(),- "require-corp; report-to=\"endpoint\"".to_owned()+ b"require-corp; report-to=\"endpoint\"".to_vec())]),CrossOriginEmbedderPolicy::RequireCorp);assert_eq!(cross_origin_embedder_policy_from_headers(&[("Cross-Origin-Embedder-Policy".to_owned(),- "credentialless".to_owned()+ b"credentialless".to_vec())]),CrossOriginEmbedderPolicy::Credentialless);assert_eq!(cross_origin_embedder_policy_from_headers(&[("Cross-Origin-Embedder-Policy".to_owned(),- "invalid".to_owned()+ b"invalid".to_vec())]),CrossOriginEmbedderPolicy::None);@@ -185,21 +185,21 @@ mod tests {assert_eq!(document_isolation_policy_from_headers(&[("Document-Isolation-Policy".to_owned(),- "isolate-and-require-corp; report-to=\"endpoint\"".to_owned()+ b"isolate-and-require-corp; report-to=\"endpoint\"".to_vec())]),DocumentIsolationPolicy::IsolateAndRequireCorp);assert_eq!(document_isolation_policy_from_headers(&[("Document-Isolation-Policy".to_owned(),- "isolate-and-credentialless".to_owned()+ b"isolate-and-credentialless".to_vec())]),DocumentIsolationPolicy::IsolateAndCredentialless);assert_eq!(document_isolation_policy_from_headers(&[("Document-Isolation-Policy".to_owned(),- "invalid".to_owned()+ b"invalid".to_vec())]),DocumentIsolationPolicy::None);diff --git a/moli-renderer-v8/src/document_language.rs b/moli-renderer-v8/src/document_language.rsindex 54e89f722..6bf37598a 100644--- a/moli-renderer-v8/src/document_language.rs+++ b/moli-renderer-v8/src/document_language.rs@@ -1,13 +1,15 @@use crate::dom::native::DomHost;pub(crate) fn document_default_language_from_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Option<String> {headers.iter().rev().find(|(name, _)| name.eq_ignore_ascii_case("content-language"))- .and_then(|(_, value)| single_content_language_value(value))+ .and_then(|(_, value)| {+ single_content_language_value(&moli_fetch::decode_header_value(value))+ })}pub(crate) fn document_default_language_from_meta(dom_host: &DomHost) -> Option<String> {diff --git a/moli-renderer-v8/src/document_last_modified.rs b/moli-renderer-v8/src/document_last_modified.rsindex bb2d1b9c8..eec46f0f6 100644--- a/moli-renderer-v8/src/document_last_modified.rs+++ b/moli-renderer-v8/src/document_last_modified.rs@@ -1,6 +1,7 @@use std::time::UNIX_EPOCH;-pub(crate) fn document_last_modified_from_headers(headers: &[(String, String)]) -> Option<f64> {+pub(crate) fn document_last_modified_from_headers(headers: &[(String, Vec<u8>)]) -> Option<f64> {+ let headers = moli_fetch::headers_to_byte_strings(headers);let value = headers.iter().rev()@@ -23,14 +24,14 @@ mod tests {assert_eq!(document_last_modified_from_headers(&[("LAST-MODIFIED".to_owned(),- "Thu, 01 Jan 1970 01:23:45 GMT".to_owned(),+ b"Thu, 01 Jan 1970 01:23:45 GMT".to_vec(),)]),Some(5_025_000.0));assert_eq!(document_last_modified_from_headers(&[("Last-Modified".to_owned(),- "not a date".to_owned(),+ b"not a date".to_vec(),)]),None);diff --git a/moli-renderer-v8/src/document_runtime/security_policy.rs b/moli-renderer-v8/src/document_runtime/security_policy.rsindex 864f713e5..e8e37a401 100644--- a/moli-renderer-v8/src/document_runtime/security_policy.rs+++ b/moli-renderer-v8/src/document_runtime/security_policy.rs@@ -135,7 +135,7 @@ impl DocumentConnectPolicySnapshot {impl DocumentPolicyContainer {pub(crate) fn from_navigation_response_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],final_url: &Url,) -> Self {let response_content_security_policies =@@ -2141,13 +2141,13 @@ pub(crate) fn create_content_security_policy_violation_event<'s>(}pub(crate) fn response_content_security_policies_from_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Vec<String> {content_security_policy_headers(headers)}pub(crate) fn response_content_security_report_only_policies_from_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Vec<String> {content_security_policy_report_only_headers(headers)}@@ -2292,7 +2292,7 @@ mod tests {crate::content_security_policy::content_security_policy_reporting_endpoints_from_headers(&[("Reporting-Endpoints".to_owned(),- "csp=\"/reports/csp\"".to_owned(),+ b"csp=\"/reports/csp\"".to_vec(),)],&Url::parse("https://example.test/page").unwrap(),)@@ -2995,13 +2995,13 @@ mod tests {response_content_security_policies_from_headers(&[("Content-Security-Policy".to_owned(),- " default-src 'self' ".to_owned()+ b" default-src 'self' ".to_vec()),("content-security-policy-report-only".to_owned(),- "default-src 'none'".to_owned()+ b"default-src 'none'".to_vec()),- ("X-Other".to_owned(), "ignored".to_owned()),+ ("X-Other".to_owned(), b"ignored".to_vec()),]),vec!["default-src 'self'"]);@@ -3009,13 +3009,13 @@ mod tests {response_content_security_report_only_policies_from_headers(&[("Content-Security-Policy".to_owned(),- "default-src 'self'".to_owned()+ b"default-src 'self'".to_vec()),("content-security-policy-report-only".to_owned(),- " default-src 'none' ".to_owned()+ b" default-src 'none' ".to_vec()),- ("X-Other".to_owned(), "ignored".to_owned()),+ ("X-Other".to_owned(), b"ignored".to_vec()),]),vec!["default-src 'none'"]);@@ -3024,27 +3024,27 @@ mod tests {#[test]fn navigation_response_headers_build_one_complete_document_policy_container() {let final_url = Url::parse("https://example.test/page").unwrap();- let headers = vec![+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Security-Policy".to_owned(),- "sandbox allow-scripts; frame-ancestors 'self'".to_owned(),+ b"sandbox allow-scripts; frame-ancestors 'self'".to_vec(),),("Content-Security-Policy-Report-Only".to_owned(),- "frame-ancestors https://embedder.test; report-to csp".to_owned(),+ b"frame-ancestors https://embedder.test; report-to csp".to_vec(),),- ("Referrer-Policy".to_owned(), "no-referrer".to_owned()),+ ("Referrer-Policy".to_owned(), b"no-referrer".to_vec()),("Reporting-Endpoints".to_owned(),- "csp=\"/reports/csp\"".to_owned(),+ b"csp=\"/reports/csp\"".to_vec(),),("Cross-Origin-Embedder-Policy".to_owned(),- "require-corp".to_owned(),+ b"require-corp".to_vec(),),("Cross-Origin-Opener-Policy".to_owned(),- "same-origin".to_owned(),+ b"same-origin".to_vec(),),];diff --git a/moli-renderer-v8/src/document_script_scheduler.rs b/moli-renderer-v8/src/document_script_scheduler.rsindex 1dd2b581f..797aaf5af 100644--- a/moli-renderer-v8/src/document_script_scheduler.rs+++ b/moli-renderer-v8/src/document_script_scheduler.rs@@ -1096,7 +1096,7 @@ mod tests {moli_fetch::ResponseHead {final_url: module_script.url.clone(),status: 200,- headers: vec![("content-type".to_owned(), "text/javascript".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/javascript".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-renderer-v8/src/native_bridge/context_host/child_documents/loads.rs b/moli-renderer-v8/src/native_bridge/context_host/child_documents/loads.rsindex bd9ce2a8a..84ec7cc11 100644--- a/moli-renderer-v8/src/native_bridge/context_host/child_documents/loads.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/child_documents/loads.rs@@ -786,13 +786,13 @@ fn child_document_load_outcome_from_response(}#[cfg(test)]-fn response_referrer_policy(headers: &[(String, String)]) -> Option<String> {+fn response_referrer_policy(headers: &[(String, Vec<u8>)]) -> Option<String> {response_referrer_policy_from_headers(headers)}fn child_document_response_should_ignore_navigation(status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> bool {matches!(status, 204 | 205)|| moli_web_mime::response_headers_indicate_attachment_download(headers)@@ -841,7 +841,7 @@ mod tests {moli_fetch::ResponseHead {final_url: url::Url::parse("https://example.test/child").unwrap(),status: 200,- headers: vec![("Content-Type".to_owned(), "text/html".to_owned())],+ headers: vec![("Content-Type".to_owned(), b"text/html".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -897,9 +897,9 @@ mod tests {#[test]fn child_document_response_referrer_policy_uses_last_valid_token() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Referrer-Policy".to_owned(),- "not-yet-standardized, no-referrer".to_owned(),+ b"not-yet-standardized, no-referrer".to_vec(),)];assert_eq!(@@ -910,9 +910,9 @@ mod tests {#[test]fn child_document_response_referrer_policy_combines_header_instances() {- let headers = vec![- ("Referrer-Policy".to_owned(), "no-referrer".to_owned()),- ("referrer-policy".to_owned(), "future-policy".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Referrer-Policy".to_owned(), b"no-referrer".to_vec()),+ ("referrer-policy".to_owned(), b"future-policy".to_vec()),];assert_eq!(@@ -923,11 +923,11 @@ mod tests {#[test]fn child_document_response_referrer_policy_ignores_invalid_later_header() {- let headers = vec![- ("Referrer-Policy".to_owned(), "no-referrer".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Referrer-Policy".to_owned(), b"no-referrer".to_vec()),("Referrer-Policy".to_owned(),- "not-yet-standardized".to_owned(),+ b"not-yet-standardized".to_vec(),),];@@ -947,7 +947,7 @@ mod tests {] {assert!(child_document_response_should_ignore_navigation(200,- &[("Content-Type".to_owned(), content_type.to_owned())],+ &[("Content-Type".to_owned(), content_type.as_bytes().to_vec())],));}}@@ -964,7 +964,7 @@ mod tests {] {assert!(!child_document_response_should_ignore_navigation(200,- &[("Content-Type".to_owned(), content_type.to_owned())],+ &[("Content-Type".to_owned(), content_type.as_bytes().to_vec())],));}assert!(!child_document_response_should_ignore_navigation(200, &[]));diff --git a/moli-renderer-v8/src/native_bridge/context_host/child_documents/snapshots.rs b/moli-renderer-v8/src/native_bridge/context_host/child_documents/snapshots.rsindex 0a4826314..71d318c35 100644--- a/moli-renderer-v8/src/native_bridge/context_host/child_documents/snapshots.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/child_documents/snapshots.rs@@ -184,7 +184,7 @@ impl JsContextHost {}pub(in crate::native_bridge::context_host) fn child_document_content_type_from_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Option<String> {response_document_content_type(headers)}@@ -205,11 +205,11 @@ mod tests {#[test]fn child_document_content_type_routes_through_web_mime_helpers() {- let headers = vec![- ("content-type".to_owned(), "text/plain".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("content-type".to_owned(), b"text/plain".to_vec()),("Content-Type".to_owned(),- " Image/SVG+XML ; charset=utf-8 ".to_owned(),+ b" Image/SVG+XML ; charset=utf-8 ".to_vec(),),];assert_eq!(@@ -217,10 +217,7 @@ mod tests {Some("image/svg+xml"));assert_eq!(- child_document_content_type_from_headers(&[(- "Content-Type".to_owned(),- " ".to_owned()- )]),+ child_document_content_type_from_headers(&[("Content-Type".to_owned(), b" ".to_vec())]),None);assert_eq!(diff --git a/moli-renderer-v8/src/native_bridge/context_host/image_resources/preload.rs b/moli-renderer-v8/src/native_bridge/context_host/image_resources/preload.rsindex 36949d503..d2e907a1a 100644--- a/moli-renderer-v8/src/native_bridge/context_host/image_resources/preload.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/image_resources/preload.rs@@ -567,7 +567,7 @@ mod tests {let response = crate::protocol_types::NavigationResponse::from_text_body(url,200,- vec![("Content-Type".to_owned(), "image/png".to_owned())],+ vec![("Content-Type".to_owned(), b"image/png".to_vec())],String::new(),);let encoded =@@ -638,7 +638,7 @@ mod tests {let response = crate::protocol_types::NavigationResponse::from_text_body(url,200,- vec![("Content-Type".to_owned(), "image/png".to_owned())],+ vec![("Content-Type".to_owned(), b"image/png".to_vec())],String::new(),);let encoded =diff --git a/moli-renderer-v8/src/native_bridge/context_host/popups.rs b/moli-renderer-v8/src/native_bridge/context_host/popups.rsindex 666199dff..cbb2614ce 100644--- a/moli-renderer-v8/src/native_bridge/context_host/popups.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/popups.rs@@ -4900,7 +4900,7 @@ fn lightweight_popup_javascript_url_callback<'s>(fn popup_document_response_should_ignore_navigation(status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> bool {matches!(status, 204 | 205)|| moli_web_mime::response_headers_indicate_attachment_download(headers)diff --git a/moli-renderer-v8/src/native_bridge/context_host/shared_workers.rs b/moli-renderer-v8/src/native_bridge/context_host/shared_workers.rsindex 0272a7654..4e4e50bfb 100644--- a/moli-renderer-v8/src/native_bridge/context_host/shared_workers.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/shared_workers.rs@@ -155,7 +155,7 @@ impl JsContextHost {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.browser_context_runtime.continue_shared_worker_fetch_response(@@ -171,7 +171,7 @@ impl JsContextHost {instance_id: SharedWorkerInstanceId,request: WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.browser_context_runtime.continue_shared_worker_xhr_response(@@ -257,7 +257,7 @@ impl JsContextHost {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.browser_context_runtime.fulfill_shared_worker_fetch(@@ -274,7 +274,7 @@ impl JsContextHost {instance_id: SharedWorkerInstanceId,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.browser_context_runtime.fulfill_shared_worker_xhr(@@ -291,7 +291,7 @@ impl JsContextHost {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.browser_context_runtime@@ -309,7 +309,7 @@ impl JsContextHost {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.browser_context_runtime@@ -327,7 +327,7 @@ impl JsContextHost {instance_id: SharedWorkerInstanceId,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.browser_context_runtimediff --git a/moli-renderer-v8/src/native_bridge/context_host/websockets/events.rs b/moli-renderer-v8/src/native_bridge/context_host/websockets/events.rsindex efb503909..163ef5afc 100644--- a/moli-renderer-v8/src/native_bridge/context_host/websockets/events.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/websockets/events.rs@@ -15,7 +15,7 @@ impl JsContextHost {response_status: u16,response_headers: moli_fetch::ResponseHeaders,) {- let response_headers = response_headers.to_byte_strings();+ let response_headers = response_headers.into_iter().collect::<Vec<_>>();let cookie_set_reports =self.store_websocket_response_cookies(socket_id, &response_headers);let Some(state) = self.websockets.get_mut(&socket_id) else {@@ -154,7 +154,7 @@ impl JsContextHost {fn store_websocket_response_cookies(&self,socket_id: u64,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> Vec<StoredCookieSetReport> {if !response_headers.iter()diff --git a/moli-renderer-v8/src/native_bridge/context_host/websockets/registration.rs b/moli-renderer-v8/src/native_bridge/context_host/websockets/registration.rsindex dcda3e9fe..d2ef7cf16 100644--- a/moli-renderer-v8/src/native_bridge/context_host/websockets/registration.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/websockets/registration.rs@@ -253,7 +253,7 @@ impl JsContextHost {request_url: Url,request_headers: moli_fetch::RequestHeaders,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,) -> Result<(), String> {let event_sender = self.page_websocket_sender().event_sender();let Some(state) = self.websockets.get_mut(&pending.socket_id) else {@@ -263,8 +263,7 @@ impl JsContextHost {pending.socket_id,request_headers,response_status,- moli_fetch::ResponseHeaders::from_byte_strings(&response_headers)- .map_err(|error| error.to_string())?,+ moli_fetch::ResponseHeaders::from_bytes(response_headers),event_sender,);state.url = request_url;@@ -304,7 +303,7 @@ impl JsContextHost {request_cookie_report: None,network_request_headers: None,response_status,- response_headers: response_headers.to_byte_strings(),+ response_headers: response_headers.into_iter().collect(),response_body: SubresourceResponseBody::from_bytes(Vec::new()),from_cache: false,}),@@ -316,7 +315,7 @@ impl JsContextHost {&mut self,pending: PendingWebSocketResponseState,response_status: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> Result<(), String> {let Some(state) = self.websockets.get_mut(&pending.socket_id) else {return Err(format!("unknown pending WebSocket `{}`", pending.socket_id));@@ -330,11 +329,7 @@ impl JsContextHost {controller.continue_open(response_status,- response_headers- .as_ref()- .map(|headers| moli_fetch::ResponseHeaders::from_byte_strings(headers))- .transpose()- .map_err(|error| error.to_string())?,+ response_headers.map(moli_fetch::ResponseHeaders::from_bytes),).map_err(|error| format!("pending WebSocket `{}`: {error}", pending.socket_id))}diff --git a/moli-renderer-v8/src/native_bridge/context_host/workers/registration.rs b/moli-renderer-v8/src/native_bridge/context_host/workers/registration.rsindex 270052da3..6c314044b 100644--- a/moli-renderer-v8/src/native_bridge/context_host/workers/registration.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/workers/registration.rs@@ -820,7 +820,7 @@ impl JsContextHost {worker_id: DedicatedWorkerId,request: WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.workers.get_mut(&worker_id)@@ -843,7 +843,7 @@ impl JsContextHost {worker_id: DedicatedWorkerId,request: WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.workers.get_mut(&worker_id)@@ -988,7 +988,7 @@ impl JsContextHost {worker_id: DedicatedWorkerId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.workers@@ -1013,7 +1013,7 @@ impl JsContextHost {worker_id: DedicatedWorkerId,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.workers@@ -1038,7 +1038,7 @@ impl JsContextHost {worker_id: DedicatedWorkerId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.workers@@ -1063,7 +1063,7 @@ impl JsContextHost {worker_id: DedicatedWorkerId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.workers@@ -1088,7 +1088,7 @@ impl JsContextHost {worker_id: DedicatedWorkerId,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.workers@@ -1570,7 +1570,7 @@ fn loaded_worker_script_from_navigation_response(}fn dedicated_worker_policy_context_from_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],creator_policy_context: SubresourcePolicyContext,) -> SubresourcePolicyContext {SubresourcePolicyContext {@@ -1595,14 +1595,14 @@ mod tests {cross_origin_isolated: true,..Default::default()};- let headers = vec![+ let headers: Vec<(String, Vec<u8>)> = vec![("Cross-Origin-Embedder-Policy".to_owned(),- "credentialless".to_owned(),+ b"credentialless".to_vec(),),("Document-Isolation-Policy".to_owned(),- "isolate-and-credentialless".to_owned(),+ b"isolate-and-credentialless".to_vec(),),];diff --git a/moli-renderer-v8/src/network/backend/memory_cache.rs b/moli-renderer-v8/src/network/backend/memory_cache.rsindex 684637283..856b4123d 100644--- a/moli-renderer-v8/src/network/backend/memory_cache.rs+++ b/moli-renderer-v8/src/network/backend/memory_cache.rs@@ -765,7 +765,7 @@ fn raw_subresource_retained_bytes(key: &RawSubresourceCacheKey, response: &RawRe.saturating_add(response.body_bytes().len())}-fn response_head_retained_bytes(final_url: &str, headers: &[(String, String)]) -> usize {+fn response_head_retained_bytes(final_url: &str, headers: &[(String, Vec<u8>)]) -> usize {headers.iter().fold(final_url.len(), |bytes, (name, value)| {@@ -824,7 +824,7 @@ mod tests {ResponseHead {final_url: Url::parse(url).expect("response URL"),status: 200,- headers: vec![("cache-control".to_owned(), "max-age=60".to_owned())],+ headers: vec![("cache-control".to_owned(), b"max-age=60".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -841,7 +841,7 @@ mod tests {ResponseHead {final_url: Url::parse(url).expect("response URL"),status: 200,- headers: vec![("cache-control".to_owned(), "max-age=60".to_owned())],+ headers: vec![("cache-control".to_owned(), b"max-age=60".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -1003,7 +1003,7 @@ mod tests {ResponseHead {final_url: request.url.clone(),status: 200,- headers: vec![("cache-control".to_owned(), "max-age=60".to_owned())],+ headers: vec![("cache-control".to_owned(), b"max-age=60".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-renderer-v8/src/network/devtools_resource_load.rs b/moli-renderer-v8/src/network/devtools_resource_load.rsindex 9e7d2202d..58676fd66 100644--- a/moli-renderer-v8/src/network/devtools_resource_load.rs+++ b/moli-renderer-v8/src/network/devtools_resource_load.rs@@ -83,7 +83,7 @@ pub enum RendererNetworkResourceLoadOutcome {pub struct RendererNetworkResourceLoadResponse {pub final_url: url::Url,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub body: Vec<u8>,pub completion_error: Option<String>,pub request_cookie_report: Option<StoredCookieQueryReport>,diff --git a/moli-renderer-v8/src/network/request_client/tests.rs b/moli-renderer-v8/src/network/request_client/tests.rsindex 10a89ebeb..33f9d6ef5 100644--- a/moli-renderer-v8/src/network/request_client/tests.rs+++ b/moli-renderer-v8/src/network/request_client/tests.rs@@ -273,7 +273,7 @@ async fn memory_cache_tee_drop_after_body_eof_cancels_pending_completion_and_relResponseHead {final_url: request.url.clone(),status: 200,- headers: vec![("cache-control".to_owned(), "max-age=60".to_owned())],+ headers: vec![("cache-control".to_owned(), b"max-age=60".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -1091,7 +1091,7 @@ async fn text_stream_fetch_handles_local_data_stylesheet_urls() -> Result<()> {response.headers.iter()- .any(|(name, value)| name.eq_ignore_ascii_case("content-type") && value == "text/css")+ .any(|(name, value)| name.eq_ignore_ascii_case("content-type") && value == b"text/css"));assert_eq!(response.body_text(), ":root{background:green}");assert!(!response.from_cache);@@ -1572,7 +1572,7 @@ async fn cached_raw_subresource_marks_redirect_hops_from_cache() -> Result<()> {ResponseHead {final_url: final_url.clone(),status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: true,@@ -1581,7 +1581,7 @@ async fn cached_raw_subresource_marks_redirect_hops_from_cache() -> Result<()> {from_url: start_url,to_url: final_url,status: 301,- headers: vec![("location".to_owned(), "/final.txt".to_owned())],+ headers: vec![("location".to_owned(), b"/final.txt".to_vec())],network_extra_info_available: true,request_extra_info: None,response_extra_info: None,diff --git a/moli-renderer-v8/src/network_host/async_fetch.rs b/moli-renderer-v8/src/network_host/async_fetch.rsindex 4dff4ab74..43983ee4a 100644--- a/moli-renderer-v8/src/network_host/async_fetch.rs+++ b/moli-renderer-v8/src/network_host/async_fetch.rs@@ -321,7 +321,7 @@ fn validate_actual_cors_response_head(fn next_redirect_url(final_url: &url::Url,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirect_count: usize,) -> Result<Option<url::Url>, String> {if !matches!(status, 301 | 302 | 303 | 307 | 308) {@@ -330,7 +330,7 @@ fn next_redirect_url(let Some(location) = headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("location"))- .map(|(_, value)| value.as_str())+ .map(|(_, value)| moli_fetch::decode_header_value(value))else {return Ok(None);};@@ -338,8 +338,8 @@ fn next_redirect_url(return Err(format!("redirect limit exceeded for {final_url}"));}final_url- .join(location)- .or_else(|_| url::Url::parse(location))+ .join(&location)+ .or_else(|_| url::Url::parse(&location)).map(Some).map_err(|error| {format!("failed to resolve redirect location `{location}` from {final_url}: {error}")@@ -849,7 +849,7 @@ fn validate_redirect_mode_response_head(fn validate_redirect_mode_parts(final_url: &url::Url,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirect_mode: RequestRedirectMode,) -> Result<(), String> {if redirect_mode != RequestRedirectMode::Error {@@ -921,10 +921,7 @@ mod tests {ResponseHead {final_url: Url::parse("https://origin.test/start")?,status: 303,- headers: vec![(- "Location".to_owned(),- "https://target.test/final".to_owned(),- )],+ headers: vec![("Location".to_owned(), b"https://target.test/final".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -1423,7 +1420,10 @@ mod tests {from_url: source_url.clone(),to_url: target_url.clone(),status: 302,- headers: vec![("Location".to_owned(), target_url.to_string())],+ headers: vec![(+ "Location".to_owned(),+ target_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,diff --git a/moli-renderer-v8/src/network_host/browser_response.rs b/moli-renderer-v8/src/network_host/browser_response.rsindex 7b20b44e2..2ca1d48fa 100644--- a/moli-renderer-v8/src/network_host/browser_response.rs+++ b/moli-renderer-v8/src/network_host/browser_response.rs@@ -10,10 +10,11 @@ pub(in crate::network_host) fn http_status_text(status: u16) -> &'static str {pub(crate) fn blob_url_response(url: &url::Url) -> Option<Response> {let (body_bytes, mime_type) = blob::object_url_bytes_and_type(url.as_str())?;- let headers = vec![+ let headers = moli_fetch::headers_from_byte_strings(&[("Content-Length".to_owned(), body_bytes.len().to_string()),("Content-Type".to_owned(), mime_type),- ];+ ])+ .expect("Blob response headers contain ByteStrings");Some(Response::from_head_and_lossy_body_bytes(moli_fetch::ResponseHead {final_url: url.clone(),@@ -36,7 +37,11 @@ pub(crate) fn data_url_response(url: &url::Url) -> Option<Response> {moli_fetch::ResponseHead {final_url: url.clone(),status: 200,- headers: vec![("Content-Type".to_owned(), mime_type)],+ headers: vec![(+ "Content-Type".to_owned(),+ moli_fetch::header_value_from_byte_string(&mime_type)+ .expect("serialized MIME types contain ByteStrings"),+ )],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -106,8 +111,8 @@ mod tests {.headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("content-type"))- .map(|(_, value)| value.as_str()),- Some("text/html;charset=iso-2022-jp")+ .map(|(_, value)| value.as_slice()),+ Some(b"text/html;charset=iso-2022-jp".as_slice()));}diff --git a/moli-renderer-v8/src/network_host/fetch_surface.rs b/moli-renderer-v8/src/network_host/fetch_surface.rsindex 56bf4b8d1..570a8ce75 100644--- a/moli-renderer-v8/src/network_host/fetch_surface.rs+++ b/moli-renderer-v8/src/network_host/fetch_surface.rs@@ -462,7 +462,10 @@ fn response_content_type<'s>() -> Option<String> {let headers = response_slot_object(scope, response, RESPONSE_HEADERS_SLOT)?;moli_web_mime::response_header_value(- &normalized_headers_entries(&headers_entries(scope, headers)),+ &moli_fetch::headers_from_byte_strings(&normalized_headers_entries(&headers_entries(+ scope, headers,+ )))+ .expect("Headers contain ByteStrings"),"content-type",)}diff --git a/moli-renderer-v8/src/network_host/image.rs b/moli-renderer-v8/src/network_host/image.rsindex e9a59c65d..5d49b0bad 100644--- a/moli-renderer-v8/src/network_host/image.rs+++ b/moli-renderer-v8/src/network_host/image.rs@@ -441,7 +441,7 @@ pub(crate) fn image_response_descriptor_from_parkable(fn image_response_descriptor_from_bytes(status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body: &[u8],) -> Option<crate::native_bridge::ImageResponseDescriptor> {if !image_response_status_is_successful(status) {diff --git a/moli-renderer-v8/src/network_host/response/body_methods.rs b/moli-renderer-v8/src/network_host/response/body_methods.rsindex a2c7182b4..870fc37a1 100644--- a/moli-renderer-v8/src/network_host/response/body_methods.rs+++ b/moli-renderer-v8/src/network_host/response/body_methods.rs@@ -177,14 +177,17 @@ fn body_headers<'s>(scope: &mut v8::PinScope<'s, '_>,object: v8::Local<'s, v8::Object>,receiver: BodyReceiver,-) -> Option<Vec<(String, String)>> {+) -> Option<Vec<(String, Vec<u8>)>> {match receiver {BodyReceiver::Response => response_slot_object(scope, object, RESPONSE_HEADERS_SLOT).map(|headers| headers_entries(scope, headers)),BodyReceiver::Request => request_slot_object(scope, object, REQUEST_HEADERS_SLOT).map(|headers| headers_entries(scope, headers)),}- .map(|headers| normalized_headers_entries(&headers))+ .map(|headers| {+ moli_fetch::headers_from_byte_strings(&normalized_headers_entries(&headers))+ .expect("Headers contain ByteStrings")+ })}fn is_urlencoded_content_type(content_type: &str) -> bool {diff --git a/moli-renderer-v8/src/network_host/response/cors.rs b/moli-renderer-v8/src/network_host/response/cors.rsindex a260ecb5b..07f1de53c 100644--- a/moli-renderer-v8/src/network_host/response/cors.rs+++ b/moli-renderer-v8/src/network_host/response/cors.rs@@ -169,7 +169,7 @@ pub(crate) fn validate_fetch_response_security_policy_with_body_classified(pub(crate) fn validate_opaque_response_blocking(request_origin: impl Into<WebOrigin>,response_url: &url::Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> Result<(), String> {let request_origin = request_origin.into();if !matches!(response_url.scheme(), "http" | "https")@@ -188,7 +188,7 @@ pub(crate) fn validate_opaque_response_blocking(pub(crate) fn validate_opaque_response_blocking_with_body(request_origin: impl Into<WebOrigin>,response_url: &url::Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],response_body: &[u8],) -> Result<(), String> {let request_origin = request_origin.into();@@ -209,7 +209,7 @@ pub(crate) fn validate_opaque_response_blocking_with_body(fn validate_cross_origin_embedder_policy(request_origin: impl Into<WebOrigin>,response_url: &url::Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],request_mode: RequestMode,credentials_mode: RequestCredentialsMode,embedder_policy: CrossOriginEmbedderPolicy,@@ -229,7 +229,7 @@ fn validate_cross_origin_embedder_policy(pub(crate) fn validate_cross_origin_embedder_and_document_isolation_policy(request_origin: impl Into<WebOrigin>,response_url: &url::Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],request_mode: RequestMode,credentials_mode: RequestCredentialsMode,embedder_policy: CrossOriginEmbedderPolicy,@@ -328,7 +328,7 @@ fn request_includes_credentials(pub(crate) fn validate_cross_origin_resource_policy(request_origin: impl Into<WebOrigin>,response_url: &url::Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> Result<(), String> {let request_origin = request_origin.into();if !matches!(response_url.scheme(), "http" | "https") {@@ -393,7 +393,7 @@ pub(crate) fn validate_cors_preflight_response(requested_method: &str,request_headers: &[(String, String)],response_status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> Result<(), String> {if !(200..300).contains(&response_status) {return Err(format!(@@ -452,7 +452,7 @@ pub(crate) fn filter_cors_exposed_response_headers(request_origin: impl Into<WebOrigin>,head: &moli_fetch::ResponseHead,credentials_mode: RequestCredentialsMode,-) -> Vec<(String, String)> {+) -> Vec<(String, Vec<u8>)> {let request_origin = request_origin.into();let response_headers = &head.headers;if !head.url_list().has_cross_origin_url(&request_origin) {@@ -530,7 +530,7 @@ mod tests {fn header_response(final_url: url::Url,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,) -> moli_fetch::ResponseHead {moli_fetch::ResponseHead {final_url,@@ -551,7 +551,7 @@ mod tests {let mut head = moli_fetch::ResponseHead {final_url: url("https://final.test/script.js"),status: 200,- headers: vec![("Access-Control-Allow-Origin".to_owned(), "*".to_owned())],+ headers: vec![("Access-Control-Allow-Origin".to_owned(), b"*".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: true,@@ -579,7 +579,7 @@ mod tests {head.redirect_chain[0].headers.push(("Access-Control-Allow-Origin".to_owned(),- "https://document.test".to_owned(),+ b"https://document.test".to_vec(),));validate_cors_response_chain(&document_url, &head, RequestCredentialsMode::SameOrigin).expect("authorized HTTP redirect should pass");@@ -637,18 +637,18 @@ mod tests {("X-Test".to_owned(), "yes".to_owned()),("Content-Type".to_owned(), "application/json".to_owned()),];- let response_headers = vec![+ let response_headers: Vec<(String, Vec<u8>)> = vec![("Access-Control-Allow-Origin".to_owned(),- "http://example.test".to_owned(),+ b"http://example.test".to_vec(),),("Access-Control-Allow-Methods".to_owned(),- "POST, PUT".to_owned(),+ b"POST, PUT".to_vec(),),("Access-Control-Allow-Headers".to_owned(),- "content-type, x-test".to_owned(),+ b"content-type, x-test".to_vec(),),];@@ -668,11 +668,11 @@ mod tests {#[test]fn validate_cors_preflight_response_allows_safelisted_methods_without_allow_methods() {let document_url = url::Url::parse("https://origin.test/page").unwrap();- let response_headers = vec![- ("Access-Control-Allow-Origin".to_owned(), "*".to_owned()),+ let response_headers: Vec<(String, Vec<u8>)> = vec![+ ("Access-Control-Allow-Origin".to_owned(), b"*".to_vec()),("Access-Control-Allow-Headers".to_owned(),- "content-type".to_owned(),+ b"content-type".to_vec(),),];@@ -696,11 +696,11 @@ mod tests {#[test]fn validate_cors_preflight_response_rejects_unsafelisted_method_without_allow_methods() {let document_url = url::Url::parse("https://origin.test/page").unwrap();- let response_headers = vec![- ("Access-Control-Allow-Origin".to_owned(), "*".to_owned()),+ let response_headers: Vec<(String, Vec<u8>)> = vec![+ ("Access-Control-Allow-Origin".to_owned(), b"*".to_vec()),("Access-Control-Allow-Headers".to_owned(),- "content-type".to_owned(),+ b"content-type".to_vec(),),];@@ -718,16 +718,16 @@ mod tests {#[test]fn cors_exposed_headers_keep_safelisted_and_explicit_names() {- let headers = vec![- ("Content-Type".to_owned(), "text/plain".to_owned()),- ("Content-Language".to_owned(), "en".to_owned()),- ("X-Visible".to_owned(), "yes".to_owned()),- ("X-Hidden".to_owned(), "no".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Content-Type".to_owned(), b"text/plain".to_vec()),+ ("Content-Language".to_owned(), b"en".to_vec()),+ ("X-Visible".to_owned(), b"yes".to_vec()),+ ("X-Hidden".to_owned(), b"no".to_vec()),("Access-Control-Expose-Headers".to_owned(),- "X-Visible".to_owned(),+ b"X-Visible".to_vec(),),- ("Set-Cookie".to_owned(), "secret=1".to_owned()),+ ("Set-Cookie".to_owned(), b"secret=1".to_vec()),];let filtered = filter_cors_exposed_response_headers(@@ -739,19 +739,19 @@ mod tests {assert_eq!(filtered,vec![- ("Content-Type".to_owned(), "text/plain".to_owned()),- ("Content-Language".to_owned(), "en".to_owned()),- ("X-Visible".to_owned(), "yes".to_owned()),+ ("Content-Type".to_owned(), b"text/plain".to_vec()),+ ("Content-Language".to_owned(), b"en".to_vec()),+ ("X-Visible".to_owned(), b"yes".to_vec()),]);}#[test]fn cors_exposed_headers_wildcard_does_not_apply_to_credentials_include() {- let headers = vec![- ("Content-Type".to_owned(), "text/plain".to_owned()),- ("X-Wildcard".to_owned(), "yes".to_owned()),- ("Access-Control-Expose-Headers".to_owned(), "*".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Content-Type".to_owned(), b"text/plain".to_vec()),+ ("X-Wildcard".to_owned(), b"yes".to_vec()),+ ("Access-Control-Expose-Headers".to_owned(), b"*".to_vec()),];let non_credentialed = filter_cors_exposed_response_headers(@@ -768,17 +768,17 @@ mod tests {);assert_eq!(credentialed,- vec![("Content-Type".to_owned(), "text/plain".to_owned())]+ vec![("Content-Type".to_owned(), b"text/plain".to_vec())]);}#[test]fn cors_exposed_headers_same_origin_keeps_existing_surface() {- let headers = vec![- ("X-Internal".to_owned(), "ok".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("X-Internal".to_owned(), b"ok".to_vec()),("Set-Cookie".to_owned(),- "kept-for-current-surface".to_owned(),+ b"kept-for-current-surface".to_vec(),),];@@ -793,9 +793,9 @@ mod tests {#[test]fn cors_response_header_lookup_uses_http_header_names() {- let headers = vec![- ("Access-Control-Allow-Origin".to_owned(), "*".to_owned()),- ("Bad Header".to_owned(), "ignored".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Access-Control-Allow-Origin".to_owned(), b"*".to_vec()),+ ("Bad Header".to_owned(), b"ignored".to_vec()),];assert_eq!(@@ -814,7 +814,7 @@ mod tests {&url("https://cdn.test/data"),&[("Cross-Origin-Resource-Policy".to_owned(),- "same-origin".to_owned(),+ b"same-origin".to_vec(),)],).expect_err("cross-origin response should be blocked");@@ -829,7 +829,7 @@ mod tests {&url("https://cdn.example.test/data"),&[("Cross-Origin-Resource-Policy".to_owned(),- "same-site".to_owned(),+ b"same-site".to_vec(),)],);assert!(same_site.is_ok());@@ -839,7 +839,7 @@ mod tests {&url("http://cdn.example.test/data"),&[("Cross-Origin-Resource-Policy".to_owned(),- "same-site".to_owned(),+ b"same-site".to_vec(),)],);assert!(cross_scheme.is_err());@@ -926,7 +926,7 @@ mod tests {let error = validate_opaque_response_blocking(&url("https://example.test/page"),&url("https://cdn.test/data.json"),- &[("Content-Type".to_owned(), "application/json".to_owned())],+ &[("Content-Type".to_owned(), b"application/json".to_vec())],).expect_err("cross-origin opaque JSON response should be blocked");@@ -939,7 +939,7 @@ mod tests {validate_opaque_response_blocking_with_body(&url("https://example.test/page"),&url("https://cdn.test/image"),- &[("Content-Type".to_owned(), "text/html".to_owned())],+ &[("Content-Type".to_owned(), b"text/html".to_vec())],b"\x89PNG\r\n\x1A\nrest",).is_ok()@@ -948,7 +948,7 @@ mod tests {validate_opaque_response_blocking_with_body(&url("https://example.test/page"),&url("https://cdn.test/script"),- &[("Content-Type".to_owned(), "application/json".to_owned())],+ &[("Content-Type".to_owned(), b"application/json".to_vec())],b"function fn() { return 42; }",).is_ok()@@ -957,7 +957,7 @@ mod tests {validate_opaque_response_blocking_with_body(&url("https://example.test/page"),&url("https://cdn.test/data.json"),- &[("Content-Type".to_owned(), "application/json".to_owned())],+ &[("Content-Type".to_owned(), b"application/json".to_vec())],br#"{"hello":"world"}"#,).is_err()@@ -970,7 +970,7 @@ mod tests {validate_opaque_response_blocking(&url("https://example.test/page"),&url("https://example.test/data.json"),- &[("Content-Type".to_owned(), "application/json".to_owned())],+ &[("Content-Type".to_owned(), b"application/json".to_vec())],).is_ok());@@ -978,7 +978,7 @@ mod tests {validate_opaque_response_blocking(&url("https://example.test/page"),&url("https://cdn.test/image.png"),- &[("Content-Type".to_owned(), "image/png".to_owned())],+ &[("Content-Type".to_owned(), b"image/png".to_vec())],).is_ok());diff --git a/moli-renderer-v8/src/network_host/response/materialize.rs b/moli-renderer-v8/src/network_host/response/materialize.rsindex ffd669226..26609feab 100644--- a/moli-renderer-v8/src/network_host/response/materialize.rs+++ b/moli-renderer-v8/src/network_host/response/materialize.rs@@ -366,7 +366,10 @@ fn build_fetch_response_object_head<'s>(RESPONSE_INTERNAL_STATUS_TEXT_SLOT,http_status_text(head.status),);- let internal_headers = filter_headers_for_guard(&head.headers, HeadersGuard::Response);+ let internal_headers = filter_headers_for_guard(+ &moli_fetch::headers_to_byte_strings(&head.headers),+ HeadersGuard::Response,+ );let internal_headers_obj =build_headers_object_with_state(scope, &internal_headers, HeadersGuard::Response, true);set_response_slot_value(@@ -398,7 +401,10 @@ fn finish_fetch_response_object_with_body_stream<'s>(} else {&[][..]};- let headers = filter_headers_for_guard(header_entries, HeadersGuard::Response);+ let headers = filter_headers_for_guard(+ &moli_fetch::headers_to_byte_strings(header_entries),+ HeadersGuard::Response,+ );let headers_obj =build_headers_object_with_state(scope, &headers, HeadersGuard::Response, true);set_response_slot_value(scope, obj, RESPONSE_HEADERS_SLOT, headers_obj.into());@@ -463,7 +469,7 @@ pub(crate) struct MaterializedResponseObject {pub(crate) redirected: bool,pub(crate) status: u16,pub(crate) status_text: String,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,pub(crate) body: Vec<u8>,}@@ -474,7 +480,7 @@ pub(crate) struct MaterializedResponseHead {pub(crate) redirected: bool,pub(crate) status: u16,pub(crate) status_text: String,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,}impl MaterializedResponseHead {@@ -573,7 +579,10 @@ pub(crate) fn materialize_response_object_head<'s>(let status_text =response_slot_string(scope, response, RESPONSE_STATUS_TEXT_SLOT).unwrap_or_default();let headers = response_slot_object(scope, response, RESPONSE_HEADERS_SLOT)- .map(|headers| headers_entries(scope, headers))+ .map(|headers| {+ moli_fetch::headers_from_byte_strings(&headers_entries(scope, headers))+ .expect("Headers contain ByteStrings")+ }).unwrap_or_default();Ok((@@ -604,7 +613,10 @@ pub(crate) fn materialize_response_object_head_for_service_worker_respond_with<'response_slot_string(scope, response, RESPONSE_INTERNAL_STATUS_TEXT_SLOT).unwrap_or_default();head.headers = response_slot_object(scope, response, RESPONSE_INTERNAL_HEADERS_SLOT)- .map(|headers| headers_entries(scope, headers))+ .map(|headers| {+ moli_fetch::headers_from_byte_strings(&headers_entries(scope, headers))+ .expect("Headers contain ByteStrings")+ }).unwrap_or_default();}Ok((head, response))diff --git a/moli-renderer-v8/src/network_host/xhr/delivery/pending.rs b/moli-renderer-v8/src/network_host/xhr/delivery/pending.rsindex f4bbd70e4..fdaa5ed04 100644--- a/moli-renderer-v8/src/network_host/xhr/delivery/pending.rs+++ b/moli-renderer-v8/src/network_host/xhr/delivery/pending.rs@@ -125,7 +125,7 @@ fn xhr_complete_callback(apply_xhr_failure(scope, xhr);return;};- let headers = serde_json::from_str::<Vec<(String, String)>>(&pending_headers_json)+ let headers = serde_json::from_str::<Vec<(String, Vec<u8>)>>(&pending_headers_json).unwrap_or_default();apply_xhr_response_pending_body(scope,diff --git a/moli-renderer-v8/src/network_host/xhr/delivery/response.rs b/moli-renderer-v8/src/network_host/xhr/delivery/response.rsindex c4202c5b6..f5f1095db 100644--- a/moli-renderer-v8/src/network_host/xhr/delivery/response.rs+++ b/moli-renderer-v8/src/network_host/xhr/delivery/response.rs@@ -531,7 +531,8 @@ fn xhr_response_progress(head: &moli_fetch::ResponseHead, loaded: f64) -> XhrRes}}-fn identity_encoded_content_length(headers: &[(String, String)]) -> Option<u64> {+fn identity_encoded_content_length(headers: &[(String, Vec<u8>)]) -> Option<u64> {+ let headers = moli_fetch::headers_to_byte_strings(headers);let cannot_compare_delivered_body_length = headers.iter().any(|(name, value)| {(name.eq_ignore_ascii_case("content-encoding")&& !value.trim().eq_ignore_ascii_case("identity"))@@ -575,7 +576,7 @@ fn buffer_value_byte_length(value: v8::Local<'_, v8::Value>) -> Option<usize> {fn xhr_response_mime_essence(scope: &mut v8::PinScope<'_, '_>,xhr: v8::Local<'_, v8::Object>,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Option<String> {let override_mime = xhr_state_string_property(scope, xhr, XHR_OVERRIDE_MIME_TYPE_SLOT);effective_response_mime_essence(headers, override_mime.as_deref())@@ -584,7 +585,7 @@ fn xhr_response_mime_essence(fn parse_default_xhr_response_xml<'s>(scope: &mut v8::PinScope<'s, '_>,xhr: v8::Local<'_, v8::Object>,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body_text: &str,) -> v8::Local<'s, v8::Value> {let mime = xhr_response_mime_essence(scope, xhr, headers);@@ -609,7 +610,7 @@ fn parse_xhr_response_document<'s>(fn xhr_response_blob_mime_type(scope: &mut v8::PinScope<'_, '_>,xhr: v8::Local<'_, v8::Object>,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> String {// overrideMimeType already stores a parsed and serialized MIME record.// Native response Blobs use that record, not Blob constructor normalization.@@ -625,9 +626,9 @@ mod tests {#[test]fn xhr_document_response_mime_uses_shared_effective_essence() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "Text/HTML; Charset=UTF-8".to_owned(),+ b"Text/HTML; Charset=UTF-8".to_vec(),)];assert_eq!(diff --git a/moli-renderer-v8/src/network_host/xhr/header_surface.rs b/moli-renderer-v8/src/network_host/xhr/header_surface.rsindex 947842f40..2f0acfe83 100644--- a/moli-renderer-v8/src/network_host/xhr/header_surface.rs+++ b/moli-renderer-v8/src/network_host/xhr/header_surface.rs@@ -61,14 +61,16 @@ pub(super) fn xhr_set_request_header_callback<'s>(}pub(super) fn xhr_response_headers_for_script(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Vec<(String, String)> {use crate::network_host::headers::{HeadersGuard, filter_headers_for_guard, normalized_headers_entries,};- let mut headers =- normalized_headers_entries(&filter_headers_for_guard(headers, HeadersGuard::Response));+ let mut headers = normalized_headers_entries(&filter_headers_for_guard(+ &moli_fetch::headers_to_byte_strings(headers),+ HeadersGuard::Response,+ ));// XHR uses legacy uppercase-byte order, unlike Headers iteration. Keep// the serialized names lowercase and preserve duplicate values in order.headers.sort_by(|(left, _), (right, _)| {diff --git a/moli-renderer-v8/src/permissions_policy.rs b/moli-renderer-v8/src/permissions_policy.rsindex 4f6afd87e..71dbbe5db 100644--- a/moli-renderer-v8/src/permissions_policy.rs+++ b/moli-renderer-v8/src/permissions_policy.rs@@ -28,7 +28,7 @@ impl DocumentPermissionsPolicy {}pub(crate) fn from_navigation_response_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],document_url: &Url,) -> Self {let mut policy = Self::default();@@ -36,7 +36,7 @@ impl DocumentPermissionsPolicy {.iter().filter(|(name, _)| name.eq_ignore_ascii_case("permissions-policy")){- for directive in value.split(',') {+ for directive in moli_fetch::decode_header_value(value).split(',') {let Some((feature, allowlist)) = directive.split_once('=') else {continue;};@@ -141,8 +141,8 @@ mod tests {fn permissions_policy_header_takes_precedence_over_legacy_feature_policy() {let policy = DocumentPermissionsPolicy::from_navigation_response_headers(&[- ("Permissions-Policy".to_owned(), "gamepad=*".to_owned()),- ("Feature-Policy".to_owned(), "gamepad 'none'".to_owned()),+ ("Permissions-Policy".to_owned(), b"gamepad=*".to_vec()),+ ("Feature-Policy".to_owned(), b"gamepad 'none'".to_vec()),],&url("https://example.test/document"),);@@ -152,7 +152,7 @@ mod tests {#[test]fn permissions_policy_response_none_disables_recognized_features() {let policy = DocumentPermissionsPolicy::from_navigation_response_headers(- &[("permissions-policy".to_owned(), "gamepad=()".to_owned())],+ &[("permissions-policy".to_owned(), b"gamepad=()".to_vec())],&url("https://example.test/document"),);assert!(!policy.gamepad_enabled());diff --git a/moli-renderer-v8/src/planning.rs b/moli-renderer-v8/src/planning.rsindex be96b765a..ed4e77bee 100644--- a/moli-renderer-v8/src/planning.rs+++ b/moli-renderer-v8/src/planning.rs@@ -837,7 +837,7 @@ mod tests {200,headers.into_iter()- .map(|(name, value)| (name.to_owned(), value.to_owned()))+ .map(|(name, value)| (name.to_owned(), value.as_bytes().to_vec())).collect(),"console.log('ok')".to_owned(),)diff --git a/moli-renderer-v8/src/referrer_policy.rs b/moli-renderer-v8/src/referrer_policy.rsindex 355810063..be12f0116 100644--- a/moli-renderer-v8/src/referrer_policy.rs+++ b/moli-renderer-v8/src/referrer_policy.rs@@ -21,7 +21,7 @@ pub(crate) fn normalize_referrer_policy(raw: &str) -> Option<String> {}pub(crate) fn response_referrer_policy_from_headers(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Option<String> {let mut combined = String::new();for (_, value) in headers@@ -31,7 +31,7 @@ pub(crate) fn response_referrer_policy_from_headers(if !combined.is_empty() {combined.push_str(", ");}- combined.push_str(value);+ combined.push_str(&moli_fetch::decode_header_value(value));}(!combined.is_empty()).then(|| normalize_referrer_policy(&combined))@@ -64,9 +64,9 @@ mod tests {#[test]fn response_referrer_policy_combines_header_instances_before_normalizing() {- let headers = vec![- ("Referrer-Policy".to_owned(), "no-referrer".to_owned()),- ("referrer-policy".to_owned(), "future-policy".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Referrer-Policy".to_owned(), b"no-referrer".to_vec()),+ ("referrer-policy".to_owned(), b"future-policy".to_vec()),];assert_eq!(diff --git a/moli-renderer-v8/src/runtime/browser_context_runtime.rs b/moli-renderer-v8/src/runtime/browser_context_runtime.rsindex 75d8b1b53..343ff229b 100644--- a/moli-renderer-v8/src/runtime/browser_context_runtime.rs+++ b/moli-renderer-v8/src/runtime/browser_context_runtime.rs@@ -286,7 +286,7 @@ impl DetachedParserScriptFetchContinuation {pub fn fulfill(&self,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: Vec<u8>,) -> bool {let Some(inner) = self.take() else {diff --git a/moli-renderer-v8/src/runtime/browser_context_runtime/shared_workers.rs b/moli-renderer-v8/src/runtime/browser_context_runtime/shared_workers.rsindex b5528c18c..9882c7918 100644--- a/moli-renderer-v8/src/runtime/browser_context_runtime/shared_workers.rs+++ b/moli-renderer-v8/src/runtime/browser_context_runtime/shared_workers.rs@@ -239,7 +239,7 @@ impl RendererBrowserContextRuntime {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.shared_worker_runtime_if_initialized().is_some_and(|runtime| {@@ -257,7 +257,7 @@ impl RendererBrowserContextRuntime {instance_id: SharedWorkerInstanceId,request: WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.shared_worker_runtime_if_initialized().is_some_and(|runtime| {@@ -353,7 +353,7 @@ impl RendererBrowserContextRuntime {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.shared_worker_runtime_if_initialized()@@ -373,7 +373,7 @@ impl RendererBrowserContextRuntime {instance_id: SharedWorkerInstanceId,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.shared_worker_runtime_if_initialized()@@ -393,7 +393,7 @@ impl RendererBrowserContextRuntime {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.shared_worker_runtime_if_initialized()@@ -413,7 +413,7 @@ impl RendererBrowserContextRuntime {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.shared_worker_runtime_if_initialized()@@ -433,7 +433,7 @@ impl RendererBrowserContextRuntime {instance_id: SharedWorkerInstanceId,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.shared_worker_runtime_if_initialized()diff --git a/moli-renderer-v8/src/runtime/owner.rs b/moli-renderer-v8/src/runtime/owner.rsindex 031f692f1..08d78a6a2 100644--- a/moli-renderer-v8/src/runtime/owner.rs+++ b/moli-renderer-v8/src/runtime/owner.rs@@ -139,7 +139,7 @@ pub struct RendererCreateHtmlPageRequest {pub navigation_redirected: bool,pub navigation_redirect_count: usize,pub response_status: u16,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,pub loader: ResourceRequestClient,pub navigator_identity: moli_browser_profile::BrowserIdentityProfile,pub web_storage: crate::RendererWebStorageHandles,@@ -188,7 +188,7 @@ pub struct RendererCreateStreamingRawPageRequest {pub navigation_redirect_count: usize,pub navigation_redirect_chain: Vec<crate::protocol_types::NavigationRedirect>,pub response_status: u16,- pub response_headers: Vec<(String, String)>,+ pub response_headers: Vec<(String, Vec<u8>)>,pub loader: ResourceRequestClient,pub navigator_identity: moli_browser_profile::BrowserIdentityProfile,pub web_storage: crate::RendererWebStorageHandles,@@ -657,7 +657,7 @@ enum RenderRuntimeTurn {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,page_vm: Box<PageVm>,page_tasks: Vec<PostParsePageOwnedWork>,stage: PageVmInitStage,@@ -1217,7 +1217,7 @@ impl RendererOwnerHandle {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,page_vm: PageVm,pending_download: Option<RendererPendingDownloadActivation>,lifecycle_decision: Option<PageVmInitStage>,@@ -1247,7 +1247,7 @@ impl RendererOwnerHandle {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,pending_navigation: PageVmPendingPhaseOneNavigation,lifecycle_decision: Option<PageVmInitStage>,) -> Result<RendererPendingPageCreation> {@@ -1315,7 +1315,7 @@ impl RendererOwnerHandle {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,page_vm: PageVm,page_tasks: Vec<PostParsePageOwnedWork>,stage: PageVmInitStage,@@ -1374,7 +1374,7 @@ impl RendererOwnerHandle {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,pending_navigation: PageVmPendingPhaseOneNavigation,stage: PageVmInitStage,reply_boundary: crate::RendererReplyBoundary,@@ -1457,7 +1457,7 @@ impl RendererOwnerHandle {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,page_vm: PageVm,stage: PageVmInitStage,reply_boundary: crate::RendererReplyBoundary,@@ -2052,7 +2052,7 @@ impl RendererOwnerHandle {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,loader: &ResourceRequestClient,web_storage: crate::RendererWebStorageHandles,final_url: Url,@@ -2102,7 +2102,7 @@ impl RendererOwnerHandle {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,loader: &ResourceRequestClient,web_storage: crate::RendererWebStorageHandles,final_url: Url,@@ -2167,7 +2167,7 @@ impl RendererOwnerHandle {navigation_redirect_count: usize,navigation_redirect_chain: Vec<crate::protocol_types::NavigationRedirect>,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,loader: &ResourceRequestClient,web_storage: crate::RendererWebStorageHandles,raw_body: ExternalRawDocumentBodyStream,diff --git a/moli-renderer-v8/src/runtime/owner_local_store/bound.rs b/moli-renderer-v8/src/runtime/owner_local_store/bound.rsindex 453d9c27b..8db6c4767 100644--- a/moli-renderer-v8/src/runtime/owner_local_store/bound.rs+++ b/moli-renderer-v8/src/runtime/owner_local_store/bound.rs@@ -50,7 +50,7 @@ pub(in crate::runtime) fn install_page_vm_on_bound_owner_local_store(navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,vm: PageVm,pending_download: Option<RendererPendingDownloadActivation>,lifecycle_gate: Option<PageVmInitStage>,@@ -78,7 +78,7 @@ pub(in crate::runtime) fn install_phase_one_blocked_page_on_bound_owner_local_stnavigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,pending_navigation: PageVmPendingPhaseOneNavigation,lifecycle_gate: Option<PageVmInitStage>,) -> Result<RendererPendingPageCreation> {diff --git a/moli-renderer-v8/src/runtime/owner_local_store/mod.rs b/moli-renderer-v8/src/runtime/owner_local_store/mod.rsindex b3a1dd663..82b065e14 100644--- a/moli-renderer-v8/src/runtime/owner_local_store/mod.rs+++ b/moli-renderer-v8/src/runtime/owner_local_store/mod.rs@@ -746,7 +746,7 @@ impl RendererOwnerLocalStoreSession<'_> {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,vm: PageVm,pending_download: Option<RendererPendingDownloadActivation>,lifecycle_gate: Option<PageVmInitStage>,@@ -773,7 +773,7 @@ impl RendererOwnerLocalStoreSession<'_> {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,pending_navigation: PageVmPendingPhaseOneNavigation,lifecycle_gate: Option<PageVmInitStage>,) -> Result<RendererPendingPageCreation> {@@ -1602,7 +1602,7 @@ impl RendererOwnerLocalStore {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,mut vm: PageVm,pending_download: Option<RendererPendingDownloadActivation>,lifecycle_gate: Option<PageVmInitStage>,@@ -1649,7 +1649,7 @@ impl RendererOwnerLocalStore {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,mut pending_navigation: PageVmPendingPhaseOneNavigation,lifecycle_gate: Option<PageVmInitStage>,) -> Result<RendererPendingPageCreation> {diff --git a/moli-renderer-v8/src/runtime/page.rs b/moli-renderer-v8/src/runtime/page.rsindex 60648e82b..435ebce44 100644--- a/moli-renderer-v8/src/runtime/page.rs+++ b/moli-renderer-v8/src/runtime/page.rs@@ -65,7 +65,7 @@ pub(crate) struct PageVmNavigationResponse {pub(crate) redirect_count: usize,pub(crate) redirect_chain: Vec<crate::protocol_types::NavigationRedirect>,pub(crate) status: u16,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,}#[derive(Debug, Clone)]@@ -252,7 +252,7 @@ impl JsRuntime {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html>".to_owned(),@@ -342,7 +342,7 @@ impl JsRuntime {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,loader: &ResourceRequestClient,web_storage: crate::RendererWebStorageHandles,html: String,@@ -392,7 +392,7 @@ impl JsRuntime {navigation_redirected: bool,navigation_redirect_count: usize,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,loader: &ResourceRequestClient,web_storage: crate::RendererWebStorageHandles,html: String,@@ -450,7 +450,7 @@ impl JsRuntime {navigation_redirect_count: usize,navigation_redirect_chain: Vec<crate::protocol_types::NavigationRedirect>,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,loader: &ResourceRequestClient,web_storage: crate::RendererWebStorageHandles,raw_body: ExternalRawDocumentBodyStream,@@ -510,7 +510,7 @@ impl JsRuntime {navigation_redirect_count: usize,navigation_redirect_chain: Vec<crate::protocol_types::NavigationRedirect>,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,loader: &ResourceRequestClient,web_storage: crate::RendererWebStorageHandles,raw_body: ExternalRawDocumentBodyStream,diff --git a/moli-renderer-v8/src/runtime/page_network.rs b/moli-renderer-v8/src/runtime/page_network.rsindex 18da2f1a9..f49e6a602 100644--- a/moli-renderer-v8/src/runtime/page_network.rs+++ b/moli-renderer-v8/src/runtime/page_network.rs@@ -346,7 +346,7 @@ impl PageVm {&mut self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> Result<()> {let execution = self.vm_mut().fulfill_pending_subresource_fetch_body(@@ -362,7 +362,7 @@ impl PageVm {&mut self,internal_id: u64,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> Result<()> {let execution = self.vm_mut().continue_pending_subresource_response_body(internal_id,@@ -387,7 +387,7 @@ impl PageVm {&mut self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> Result<()> {let execution = self.vm_mut().fulfill_pending_subresource_response_body(diff --git a/moli-renderer-v8/src/runtime/page_state.rs b/moli-renderer-v8/src/runtime/page_state.rsindex 288ab0aaa..2c79e63a9 100644--- a/moli-renderer-v8/src/runtime/page_state.rs+++ b/moli-renderer-v8/src/runtime/page_state.rs@@ -17,7 +17,7 @@ pub struct RendererPageState {pub final_url: Url,pub document_title: String,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub script_execution: Arc<ScriptExecutionReport>,pub idle_override: Option<crate::protocol_types::EmulatedIdleOverride>,pub service_worker_client_id: u64,@@ -32,7 +32,7 @@ impl RendererPageState {mut navigation_redirected: bool,mut navigation_redirect_count: usize,mut status: u16,- mut headers: Vec<(String, String)>,+ mut headers: Vec<(String, Vec<u8>)>,state_capture: PageVmStateCapture,) -> Arc<Self> {let mut navigation_redirect_chain = Vec::new();diff --git a/moli-renderer-v8/src/runtime/page_surface.rs b/moli-renderer-v8/src/runtime/page_surface.rsindex 41fb05e37..2986ce787 100644--- a/moli-renderer-v8/src/runtime/page_surface.rs+++ b/moli-renderer-v8/src/runtime/page_surface.rs@@ -49,7 +49,7 @@ pub struct RendererPageView {pub struct RendererPendingDownloadResponse {pub final_url: String,pub status: u16,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub body: Vec<u8>,}@@ -732,7 +732,7 @@ pub enum RendererServiceWorkerFetchDiagnosticResult {final_url: String,status: u16,status_text: String,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,body_len: usize,},Failure {@@ -5244,13 +5244,13 @@ pub enum RendererPageCommand {FulfillPendingSubresourceFetch {internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},ContinuePendingSubresourceResponse {internal_id: u64,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,},FailPendingSubresourceResponse {internal_id: u64,@@ -5259,7 +5259,7 @@ pub enum RendererPageCommand {FulfillPendingSubresourceResponse {internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},ReceiveSyntheticWebSocketText {diff --git a/moli-renderer-v8/src/runtime/page_vm/followed_navigation.rs b/moli-renderer-v8/src/runtime/page_vm/followed_navigation.rsindex ecae78a67..96b59bab3 100644--- a/moli-renderer-v8/src/runtime/page_vm/followed_navigation.rs+++ b/moli-renderer-v8/src/runtime/page_vm/followed_navigation.rs@@ -35,7 +35,7 @@ pub(super) enum LoadedFollowedLocationNavigation {requested_url: Url,final_url: Url,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,},}@@ -59,7 +59,7 @@ impl LoadedFollowedLocationNavigation {};headers.iter()- .any(|(name, value)| name.eq_ignore_ascii_case(expected_name) && value == "1")+ .any(|(name, value)| name.eq_ignore_ascii_case(expected_name) && value == b"1")}}@@ -201,7 +201,7 @@ pub(super) async fn bootstrap_committed_followed_location_navigation(Output = Result<(PageVmFollowedNavigationBuildOutcome,u16,- Vec<(String, String)>,+ Vec<(String, Vec<u8>)>,)>,>,>,@@ -370,7 +370,7 @@ async fn streaming_navigation_result_to_turn_outcome() -> Result<(PageVmFollowedNavigationBuildOutcome,u16,- Vec<(String, String)>,+ Vec<(String, Vec<u8>)>,)> {match result {StreamingNavigationPageCreationResult::Download(download) => Ok((@@ -443,7 +443,7 @@ fn external_raw_document_body_from_materialized_response() -> Result<(Url,u16,- Vec<(String, String)>,+ Vec<(String, Vec<u8>)>,ExternalRawDocumentBodyStream,)> {let (head, body) = response.into_body();@@ -485,7 +485,7 @@ fn about_blank_navigation_response(url: &Url) -> Option<moli_fetch::Response> {status: 200,headers: vec![("Content-Type".to_owned(),- "text/html; charset=utf-8".to_owned(),+ b"text/html; charset=utf-8".to_vec(),)],request_cookie_report: None,cookie_set_reports: Vec::new(),@@ -1425,8 +1425,8 @@ mod tests {.headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("content-type"))- .map(|(_, value)| value.as_str()),- Some("text/html; charset=utf-8")+ .map(|(_, value)| value.as_slice()),+ Some(b"text/html; charset=utf-8".as_slice()));}}diff --git a/moli-renderer-v8/src/runtime/page_vm/mod.rs b/moli-renderer-v8/src/runtime/page_vm/mod.rsindex 18b82a747..f2f17ba41 100644--- a/moli-renderer-v8/src/runtime/page_vm/mod.rs+++ b/moli-renderer-v8/src/runtime/page_vm/mod.rs@@ -1105,7 +1105,7 @@ impl PageVmEnvConfig {pub(crate) fn apply_navigation_response_headers(&mut self,final_url: &Url,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) {self.document_policy_container =crate::document_runtime::DocumentPolicyContainer::from_navigation_response_headers(diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/async_subresource_completion.rs b/moli-renderer-v8/src/runtime/page_vm/tests/async_subresource_completion.rsindex c7ba3204e..56b4fa184 100644--- a/moli-renderer-v8/src/runtime/page_vm/tests/async_subresource_completion.rs+++ b/moli-renderer-v8/src/runtime/page_vm/tests/async_subresource_completion.rs@@ -238,7 +238,7 @@ fetch({:?})head: moli_fetch::ResponseHead {final_url: request_url,status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -452,7 +452,7 @@ async fn streaming_finish_requires_matching_request_and_body_source_identity() {head: moli_fetch::ResponseHead {final_url: request_url,status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/dedicated_worker_client_event.rs b/moli-renderer-v8/src/runtime/page_vm/tests/dedicated_worker_client_event.rsindex 57034ecb1..d48bfda15 100644--- a/moli-renderer-v8/src/runtime/page_vm/tests/dedicated_worker_client_event.rs+++ b/moli-renderer-v8/src/runtime/page_vm/tests/dedicated_worker_client_event.rs@@ -607,7 +607,7 @@ async fn successful_script_loaded_worker_event_transitions_through_selected_disp200,vec![("Content-Type".to_owned(),- "application/javascript".to_owned(),+ b"application/javascript".to_vec(),)],"self.onmessage = () => {};".to_owned(),),diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/fetch_xhr.rs b/moli-renderer-v8/src/runtime/page_vm/tests/fetch_xhr.rsindex 01d0e70cf..a1a15a84f 100644--- a/moli-renderer-v8/src/runtime/page_vm/tests/fetch_xhr.rs+++ b/moli-renderer-v8/src/runtime/page_vm/tests/fetch_xhr.rs@@ -4628,7 +4628,7 @@ async fn window_fetch_manual_redirect_returns_opaqueredirect_filtered_response()};assert_eq!(*status, 302);assert!(response_headers.iter().any(|header| {- header.0.eq_ignore_ascii_case("location") && header.1 == "/target"+ header.0.eq_ignore_ascii_case("location") && header.1 == b"/target"}));}).await;diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs b/moli-renderer-v8/src/runtime/page_vm/tests/mod.rsindex 471ba3769..98500ffcc 100644--- a/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs+++ b/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs@@ -1221,7 +1221,7 @@ async fn stale_child_unusable_stylesheet_preserves_physical_output_without_documlet physical_response = crate::protocol_types::NavigationResponse::from_text_body(request_url.clone(),200,- vec![("Content-Type".to_owned(), "text/html".to_owned())],+ vec![("Content-Type".to_owned(), b"text/html".to_vec())],"<html>not a stylesheet</html>".to_owned(),);let mut queue = RendererPageNetworkingSource::new_for_test();@@ -14110,7 +14110,7 @@ fn module_graph_network_result_records_staged_response_started_with_cache_state(moli_fetch::ResponseHead {final_url: request_url.clone(),status: 200,- headers: vec![("content-type".to_owned(), "text/javascript".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/javascript".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/websocket/handshake.rs b/moli-renderer-v8/src/runtime/page_vm/tests/websocket/handshake.rsindex db20aaa23..128ef6349 100644--- a/moli-renderer-v8/src/runtime/page_vm/tests/websocket/handshake.rs+++ b/moli-renderer-v8/src/runtime/page_vm/tests/websocket/handshake.rs@@ -97,7 +97,7 @@ async fn websocket_handshake_inherits_browser_cookie_store() {&cookie_url,&[("set-cookie".to_owned(),- "sid=server; Path=/; HttpOnly".to_owned(),+ b"sid=server; Path=/; HttpOnly".to_vec(),)],);assert!(reports.iter().any(|report| report.is_accepted()));diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/worker.rs b/moli-renderer-v8/src/runtime/page_vm/tests/worker.rsindex 664f47d11..005ba6ebf 100644--- a/moli-renderer-v8/src/runtime/page_vm/tests/worker.rs+++ b/moli-renderer-v8/src/runtime/page_vm/tests/worker.rs@@ -2941,7 +2941,7 @@ async fn external_dedicated_module_worker_retains_creator_csp_for_static_importscrate::document_runtime::DocumentPolicyContainer::from_navigation_response_headers(&[("Content-Security-Policy".to_owned(),- "worker-src 'self'; script-src data:".to_owned(),+ b"worker-src 'self'; script-src data:".to_vec(),)],&document_url,),diff --git a/moli-renderer-v8/src/runtime/phase_one/mod.rs b/moli-renderer-v8/src/runtime/phase_one/mod.rsindex d03d23169..c6010fd26 100644--- a/moli-renderer-v8/src/runtime/phase_one/mod.rs+++ b/moli-renderer-v8/src/runtime/phase_one/mod.rs@@ -4111,7 +4111,7 @@ document.body.setAttribute('data-error-state', [let response = crate::protocol_types::NavigationResponse::from_text_body(script.url.clone(),200,- vec![("Content-Type".to_owned(), "text/javascript".to_owned())],+ vec![("Content-Type".to_owned(), b"text/javascript".to_vec())],String::new(),);let response = crate::protocol_types::NavigationResponse::from_head_and_body(@@ -4170,7 +4170,7 @@ document.body.setAttribute('data-error-state', [let response = crate::protocol_types::NavigationResponse::from_text_body(script.url.clone(),200,- vec![("Content-Type".to_owned(), "text/javascript".to_owned())],+ vec![("Content-Type".to_owned(), b"text/javascript".to_vec())],String::new(),);let response = crate::protocol_types::NavigationResponse::from_head_and_body(diff --git a/moli-renderer-v8/src/runtime/phase_one/streaming.rs b/moli-renderer-v8/src/runtime/phase_one/streaming.rsindex d3862df63..08304b7be 100644--- a/moli-renderer-v8/src/runtime/phase_one/streaming.rs+++ b/moli-renderer-v8/src/runtime/phase_one/streaming.rs@@ -10,7 +10,7 @@ use tokio::sync::{mpsc, oneshot};pub(in crate::runtime) struct StreamingHtmlPageCreationResult {pub(in crate::runtime) response_status: u16,- pub(in crate::runtime) response_headers: Vec<(String, String)>,+ pub(in crate::runtime) response_headers: Vec<(String, Vec<u8>)>,pub(in crate::runtime) outcome: ParseTimePageVmCreationOutcome,}@@ -179,7 +179,7 @@ impl ConcurrentParseTimeRuntime {started: Instant,final_url: Url,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,reply_boundary: crate::RendererReplyBoundary,) -> Result<StreamingNavigationPageCreationResult> {@@ -233,7 +233,7 @@ impl ConcurrentParseTimeRuntime {started: Instant,final_url: Url,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,) -> Result<StreamingNavigationPageCreationResult> {Self::create_from_committed_external_raw_document_response(@@ -263,7 +263,7 @@ impl ConcurrentParseTimeRuntime {started: Instant,final_url: Url,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,) -> Result<StreamingNavigationPageCreationResult> {Self::create_from_committed_external_raw_document_response(@@ -293,7 +293,7 @@ impl ConcurrentParseTimeRuntime {started: Instant,final_url: Url,response_status: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,raw_body: ExternalRawDocumentBodyStream,boundary: CommittedNavigationBootstrapBoundary,) -> Result<StreamingNavigationPageCreationResult> {@@ -480,7 +480,7 @@ impl ConcurrentParseTimeRuntime {}}-fn response_headers_indicate_xml_document(headers: &[(String, String)]) -> bool {+fn response_headers_indicate_xml_document(headers: &[(String, Vec<u8>)]) -> bool {moli_web_mime::response_document_content_type(headers).is_some_and(|mime| moli_web_mime::is_dom_parser_xml_mime(&mime))}@@ -898,7 +898,9 @@ fn sync_state_document_character_set_from_decoder(.set_document_character_set(encoding);}-pub(in crate::runtime) fn response_headers_indicate_download(headers: &[(String, String)]) -> bool {+pub(in crate::runtime) fn response_headers_indicate_download(+ headers: &[(String, Vec<u8>)],+) -> bool {response_headers_indicate_attachment_download(headers)}@@ -1198,9 +1200,9 @@ mod tests {drop(body_tx);completion_tx.send(Ok(())).unwrap();let mut source = RawDocumentBodySource::External(raw_body);- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=utf-8".to_owned(),+ b"text/html; charset=utf-8".to_vec(),)];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);@@ -1273,9 +1275,9 @@ mod tests {drop(body_tx);completion_tx.send(Ok(())).unwrap();let mut source = RawDocumentBodySource::External(raw_body);- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=utf-8".to_owned(),+ b"text/html; charset=utf-8".to_vec(),)];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);@@ -1334,9 +1336,9 @@ mod tests {let mut state = ParseTimeDriverState::new_with_scripting_enabled_for_test(Url::parse("https://example.test/").expect("test url"),);- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "text/html; charset=utf-8".to_owned(),+ b"text/html; charset=utf-8".to_vec(),)];let mut decoder = HtmlDocumentStreamingDecoder::new(&headers);@@ -1359,12 +1361,12 @@ mod tests {fn streaming_navigation_download_detection_uses_content_disposition_type() {assert!(response_headers_indicate_download(&[("Content-Disposition".to_owned(),- "attachment; filename=report.html".to_owned(),+ b"attachment; filename=report.html".to_vec(),)]));assert!(!response_headers_indicate_download(&[("Content-Disposition".to_owned(),- "inline; filename=attachment.html".to_owned(),+ b"inline; filename=attachment.html".to_vec(),)]));}}diff --git a/moli-renderer-v8/src/runtime/phase_one/streaming_admission_tests.rs b/moli-renderer-v8/src/runtime/phase_one/streaming_admission_tests.rsindex e30087354..b64d1459b 100644--- a/moli-renderer-v8/src/runtime/phase_one/streaming_admission_tests.rs+++ b/moli-renderer-v8/src/runtime/phase_one/streaming_admission_tests.rs@@ -266,7 +266,7 @@ fn followed_navigation_returns_at_document_commit_before_parsing_buffered_body()Instant::now(),Url::parse("https://example.test/").expect("test URL"),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],raw_body,).await@@ -403,7 +403,7 @@ fn open_streaming_residence_does_not_treat_link_event_as_parser_obstruction() {Instant::now(),Url::parse("https://example.test/").expect("test URL"),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],raw_body,).await@@ -593,7 +593,7 @@ fn streaming_stylesheet_and_json_ld_reach_tail_and_post_parse_boundary() {Instant::now(),Url::parse("https://example.test/").expect("test URL"),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],raw_body,).awaitdiff --git a/moli-renderer-v8/src/runtime/protocol_output/transport_memory.rs b/moli-renderer-v8/src/runtime/protocol_output/transport_memory.rsindex 73c4dfc5f..87f003683 100644--- a/moli-renderer-v8/src/runtime/protocol_output/transport_memory.rs+++ b/moli-renderer-v8/src/runtime/protocol_output/transport_memory.rs@@ -228,15 +228,15 @@ fn owner_action_transport_charge_bytes(action: &RendererOwnerAction) -> usize {}}-fn headers_charge(headers: &[(String, String)]) -> usize {+fn headers_charge<V: AsRef<[u8]>>(headers: &[(String, V)]) -> usize {headers.iter().fold(headers.len()- .saturating_mul(std::mem::size_of::<(String, String)>()),+ .saturating_mul(std::mem::size_of::<(String, V)>()),|total, (name, value)| {total.saturating_add(string_charge(name))- .saturating_add(string_charge(value))+ .saturating_add(value.as_ref().len().saturating_mul(2))},)}@@ -392,7 +392,7 @@ fn service_worker_event_transport_charge_bytes(|total, (name, value)| {total.saturating_add(string_charge(name))- .saturating_add(string_charge(value))+ .saturating_add(value.len().saturating_mul(2))},),crate::runtime::RendererServiceWorkerFetchDiagnosticResult::Failure { message } => {diff --git a/moli-renderer-v8/src/runtime/tests.rs b/moli-renderer-v8/src/runtime/tests.rsindex 7f08b8783..e3c1da8b7 100644--- a/moli-renderer-v8/src/runtime/tests.rs+++ b/moli-renderer-v8/src/runtime/tests.rs@@ -81,7 +81,7 @@ async fn prepare_test_external_raw_document_with_content_type_and_reply_boundary0,Vec::new(),200,- vec![("content-type".to_owned(), content_type.to_owned())],+ vec![("content-type".to_owned(), content_type.as_bytes().to_vec())],loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -2227,7 +2227,7 @@ async fn external_raw_streaming_page_command_builds_phase_one_page() {203,vec![("content-type".to_owned(),- "text/html; charset=UTF-8".to_owned(),+ b"text/html; charset=UTF-8".to_vec(),)],&loader,crate::RendererWebStorageHandles::ephemeral(),@@ -2953,7 +2953,7 @@ async fn external_raw_streaming_empty_document_reaches_dom_content_loaded() {0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -3258,7 +3258,7 @@ async fn external_raw_streaming_delegates_post_load_meta_refresh_to_browser() {0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -3338,7 +3338,7 @@ async fn external_raw_streaming_defers_dcl_handler_navigation_to_page_reply() {0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -3416,7 +3416,7 @@ globalThis.__ordinaryAfterDcl = new Promise(resolve => {0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -3500,7 +3500,7 @@ async fn renderer_owned_navigation_survives_page_creation_observer_detach() {0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -3762,7 +3762,7 @@ async fn per_page_isolate_policy_uses_distinct_isolates_and_isolates_contexts()false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first shared</body>".to_owned(),@@ -3790,7 +3790,7 @@ async fn per_page_isolate_policy_uses_distinct_isolates_and_isolates_contexts()false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second shared</body>".to_owned(),@@ -4252,7 +4252,7 @@ async fn page_document_isolate_completes_real_v8_foreground_task() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>shared v8 foreground task</body>".to_owned(),@@ -4302,7 +4302,7 @@ async fn per_page_isolate_policy_routes_unhandled_rejections_to_originating_pagefalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first rejection listener</body>".to_owned(),@@ -4322,7 +4322,7 @@ async fn per_page_isolate_policy_routes_unhandled_rejections_to_originating_pagefalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second rejection listener</body>".to_owned(),@@ -4491,7 +4491,7 @@ async fn per_page_isolate_policy_keeps_window_open_routes_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first window opener</body>".to_owned(),@@ -4511,7 +4511,7 @@ async fn per_page_isolate_policy_keeps_window_open_routes_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second window opener</body>".to_owned(),@@ -4630,7 +4630,7 @@ async fn per_page_isolate_policy_keeps_dedicated_worker_events_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first worker owner</body>".to_owned(),@@ -4650,7 +4650,7 @@ async fn per_page_isolate_policy_keeps_dedicated_worker_events_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second worker owner</body>".to_owned(),@@ -4887,7 +4887,7 @@ async fn per_page_isolate_policy_keeps_indexed_db_managers_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first idb</body>".to_owned(),@@ -4908,7 +4908,7 @@ async fn per_page_isolate_policy_keeps_indexed_db_managers_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second idb</body>".to_owned(),@@ -4972,7 +4972,7 @@ async fn per_page_isolate_policy_keeps_blob_urls_page_owned_after_other_page_clofalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first blob owner</body>".to_owned(),@@ -4992,7 +4992,7 @@ async fn per_page_isolate_policy_keeps_blob_urls_page_owned_after_other_page_clofalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second blob owner</body>".to_owned(),@@ -5084,7 +5084,7 @@ async fn per_page_isolate_policy_keeps_domparser_detached_docs_cleanup_neutral()false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first detached owner</body>".to_owned(),@@ -5104,7 +5104,7 @@ async fn per_page_isolate_policy_keeps_domparser_detached_docs_cleanup_neutral()false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second detached peer</body>".to_owned(),@@ -5202,7 +5202,7 @@ async fn per_page_isolate_policy_keeps_isolated_worlds_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first isolated world</body>".to_owned(),@@ -5222,7 +5222,7 @@ async fn per_page_isolate_policy_keeps_isolated_worlds_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second isolated world</body>".to_owned(),@@ -5412,7 +5412,7 @@ async fn per_page_isolate_policy_keeps_child_default_contexts_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),r#"<!doctype html><body><iframe srcdoc="<body>first child</body>"></iframe></body>"#@@ -5433,7 +5433,7 @@ async fn per_page_isolate_policy_keeps_child_default_contexts_page_owned() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),r#"<!doctype html><body><iframe srcdoc="<body>second child</body>"></iframe></body>"#@@ -5608,7 +5608,7 @@ None,false,0,200,-vec![("content-type".to_owned(), "text/html".to_owned())],+vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),r#"<!doctype html><body><iframe srcdoc="<body>first child isolated</body>"></iframe></body>"#@@ -5627,7 +5627,7 @@ None,false,0,200,-vec![("content-type".to_owned(), "text/html".to_owned())],+vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),r#"<!doctype html><body><iframe srcdoc="<body>second child isolated</body>"></iframe></body>"#@@ -5826,7 +5826,7 @@ async fn per_page_isolate_policy_reuses_navigation_isolate_and_replaces_contextsfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>old shared navigation document</body>".to_owned(),@@ -5846,7 +5846,7 @@ async fn per_page_isolate_policy_reuses_navigation_isolate_and_replaces_contextsfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>peer shared navigation document</body>".to_owned(),@@ -6138,7 +6138,7 @@ async fn per_page_isolate_parser_blocking_navigation_restores_replacement_inspecfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>parser-blocking navigation source</body>".to_owned(),@@ -6241,7 +6241,7 @@ async fn per_page_isolate_navigation_churn_disposes_replaced_page_vms() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>churn-initial</body>".to_owned(),@@ -6355,7 +6355,7 @@ async fn per_page_isolate_policy_drops_stale_timer_after_navigation_replacement(false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>stale timer source</body>".to_owned(),@@ -6375,7 +6375,7 @@ async fn per_page_isolate_policy_drops_stale_timer_after_navigation_replacement(false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>stale timer peer</body>".to_owned(),@@ -6504,7 +6504,7 @@ async fn per_page_isolate_policy_drops_stale_fetch_after_navigation_replacement(false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>stale fetch source</body>".to_owned(),@@ -6524,7 +6524,7 @@ async fn per_page_isolate_policy_drops_stale_fetch_after_navigation_replacement(false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>stale fetch peer</body>".to_owned(),@@ -6679,7 +6679,7 @@ export const marker = "late-module";"#,false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>stale module source</body>".to_owned(),@@ -6699,7 +6699,7 @@ export const marker = "late-module";"#,false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>stale module peer</body>".to_owned(),@@ -6846,7 +6846,7 @@ async fn per_page_isolate_policy_drops_stale_worker_message_after_navigation_repfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>stale worker message source</body>".to_owned(),@@ -6866,7 +6866,7 @@ async fn per_page_isolate_policy_drops_stale_worker_message_after_navigation_repfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>stale worker message peer</body>".to_owned(),@@ -7065,7 +7065,7 @@ async fn per_page_isolate_policy_routes_dynamic_import_to_originating_page() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first dynamic import owner</body>".to_owned(),@@ -7085,7 +7085,7 @@ async fn per_page_isolate_policy_routes_dynamic_import_to_originating_page() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second dynamic import owner</body>".to_owned(),@@ -7187,7 +7187,7 @@ async fn per_page_isolate_policy_keeps_shared_worker_alive_after_peer_page_closefalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first shared worker client</body>".to_owned(),@@ -7207,7 +7207,7 @@ async fn per_page_isolate_policy_keeps_shared_worker_alive_after_peer_page_closefalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second shared worker client</body>".to_owned(),@@ -7560,7 +7560,7 @@ async fn per_page_isolate_policy_removes_only_navigated_shared_worker_client() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first shared worker navigation client</body>".to_owned(),@@ -7580,7 +7580,7 @@ async fn per_page_isolate_policy_removes_only_navigated_shared_worker_client() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second shared worker navigation client</body>".to_owned(),@@ -7726,7 +7726,7 @@ async fn per_page_isolate_policy_rejects_cross_page_runtime_object_ids() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first runtime object owner</body>".to_owned(),@@ -7746,7 +7746,7 @@ async fn per_page_isolate_policy_rejects_cross_page_runtime_object_ids() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second runtime object owner</body>".to_owned(),@@ -7977,7 +7977,7 @@ async fn per_page_isolate_policy_scopes_same_numeric_runtime_evaluate_context_idfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first runtime context owner</body>".to_owned(),@@ -7997,7 +7997,7 @@ async fn per_page_isolate_policy_scopes_same_numeric_runtime_evaluate_context_idfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second runtime context owner</body>".to_owned(),@@ -8148,7 +8148,7 @@ async fn per_page_isolate_policy_scopes_same_numeric_runtime_evaluate_default_cofalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first default runtime context owner</body>".to_owned(),@@ -8168,7 +8168,7 @@ async fn per_page_isolate_policy_scopes_same_numeric_runtime_evaluate_default_cofalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second default runtime context owner</body>".to_owned(),@@ -8301,7 +8301,7 @@ None,false,0,200,-vec![("content-type".to_owned(), "text/html".to_owned())],+vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),r#"<!doctype html><body><iframe srcdoc="<body>first runtime child</body>"></iframe></body>"#@@ -8320,7 +8320,7 @@ None,false,0,200,-vec![("content-type".to_owned(), "text/html".to_owned())],+vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),r#"<!doctype html><body><iframe srcdoc="<body>second runtime child</body>"></iframe></body>"#@@ -8540,7 +8540,7 @@ async fn per_page_isolate_policy_keeps_release_object_group_page_local() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first release group owner</body>".to_owned(),@@ -8560,7 +8560,7 @@ async fn per_page_isolate_policy_keeps_release_object_group_page_local() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second release group owner</body>".to_owned(),@@ -8698,7 +8698,7 @@ async fn per_page_isolate_policy_replays_runtime_contexts_per_page() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first runtime replay owner</body>".to_owned(),@@ -8718,7 +8718,7 @@ async fn per_page_isolate_policy_replays_runtime_contexts_per_page() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second runtime replay owner</body>".to_owned(),@@ -8917,7 +8917,7 @@ async fn runtime_enable_events_for_new_inspector_session_replays_existing_isolatfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>new inspector session</body>".to_owned(),@@ -8963,7 +8963,7 @@ async fn runtime_enable_events_include_renderer_root_frame_id_for_default_contexfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>root frame id</body>".to_owned(),@@ -9027,7 +9027,7 @@ async fn per_page_isolate_policy_scopes_runtime_bindings_to_page_worlds() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first runtime binding owner</body>".to_owned(),@@ -9047,7 +9047,7 @@ async fn per_page_isolate_policy_scopes_runtime_bindings_to_page_worlds() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second runtime binding owner</body>".to_owned(),@@ -9674,7 +9674,7 @@ async fn per_page_isolate_policy_scopes_same_numeric_runtime_binding_context_id_false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first binding context owner</body>".to_owned(),@@ -9694,7 +9694,7 @@ async fn per_page_isolate_policy_scopes_same_numeric_runtime_binding_context_id_false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second binding context owner</body>".to_owned(),@@ -9868,7 +9868,7 @@ async fn per_page_isolate_policy_keeps_remove_binding_page_local() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first remove-binding owner</body>".to_owned(),@@ -9888,7 +9888,7 @@ async fn per_page_isolate_policy_keeps_remove_binding_page_local() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second remove-binding owner</body>".to_owned(),@@ -10021,7 +10021,7 @@ async fn per_page_isolate_policy_scopes_document_start_scripts_to_page_worlds()false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first document-start owner</body>".to_owned(),@@ -10041,7 +10041,7 @@ async fn per_page_isolate_policy_scopes_document_start_scripts_to_page_worlds()false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second document-start owner</body>".to_owned(),@@ -10145,7 +10145,7 @@ async fn per_page_isolate_policy_keeps_stored_document_start_scripts_page_local(false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>first stored preload owner</body>".to_owned(),@@ -10165,7 +10165,7 @@ async fn per_page_isolate_policy_keeps_stored_document_start_scripts_page_local(false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>second stored preload owner</body>".to_owned(),@@ -10300,7 +10300,7 @@ async fn stored_document_start_script_remove_uses_registry_key_namespace() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>stored preload key namespace</body>".to_owned(),@@ -10410,7 +10410,7 @@ async fn owner_loop_applies_subresource_fetch_completion_without_wait_command()false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>owner wake</body>".to_owned(),@@ -14599,7 +14599,7 @@ async fn owner_loop_ticks_page_timer_from_active_timer_index() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>timer index</body>".to_owned(),@@ -14828,7 +14828,7 @@ async fn owner_runtime_expression_await_uses_page_wake_or_timer_deadline() {false,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),"<!doctype html><body>runtime expression await</body>".to_owned(),@@ -15477,7 +15477,7 @@ async fn domcontentloaded_page_creation_reply_resumes_owner_to_load_without_exte0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -15556,7 +15556,7 @@ async fn document_commit_background_dcl_completion_resumes_owner_to_load() {0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -15856,7 +15856,7 @@ async fn owner_loop_completes_post_dcl_async_script_without_wait_command() {0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -16236,7 +16236,7 @@ document.addEventListener("DOMContentLoaded", () => {0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -16354,7 +16354,7 @@ blocked page0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,@@ -16800,7 +16800,7 @@ fn start_test_html_page_with_optional_indexed_db_manager_and_navigation_dispatchfalse,0,200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],loader,crate::RendererWebStorageHandles::ephemeral(),html.to_owned(),@@ -16861,7 +16861,7 @@ async fn create_test_html_page_at_document_commit_with_navigation_dispatch(0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,diff --git a/moli-renderer-v8/src/runtime/tests/open_streaming.rs b/moli-renderer-v8/src/runtime/tests/open_streaming.rsindex b282b0041..da5d6200f 100644--- a/moli-renderer-v8/src/runtime/tests/open_streaming.rs+++ b/moli-renderer-v8/src/runtime/tests/open_streaming.rs@@ -185,7 +185,7 @@ impl OpenStreamingPage {0,Vec::new(),200,- vec![("content-type".to_owned(), "text/html".to_owned())],+ vec![("content-type".to_owned(), b"text/html".to_vec())],&loader,crate::RendererWebStorageHandles::ephemeral(),raw_body,diff --git a/moli-renderer-v8/src/runtime/tests/redirect_chain.rs b/moli-renderer-v8/src/runtime/tests/redirect_chain.rsindex a23e995b5..791ea7290 100644--- a/moli-renderer-v8/src/runtime/tests/redirect_chain.rs+++ b/moli-renderer-v8/src/runtime/tests/redirect_chain.rs@@ -36,7 +36,7 @@ async fn assert_streaming_redirect_chain(reply_boundary: RendererReplyBoundary)from_url: from_url.clone(),to_url: to_url.clone(),status: 302,- headers: vec![("location".to_owned(), location.to_owned())],+ headers: vec![("location".to_owned(), location.as_bytes().to_vec())],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,@@ -51,7 +51,8 @@ async fn assert_streaming_redirect_chain(reply_boundary: RendererReplyBoundary)}).collect();let final_url = from_url;- let headers = vec![("content-type".to_owned(), content_type.to_owned())];+ let headers: Vec<(String, Vec<u8>)> =+ vec![("content-type".to_owned(), content_type.as_bytes().to_vec())];// DocumentCommit forces a pending phase-one installation, even when// the body is already buffered. No network timing or sleep is needed.let (mut page, initial, _, artifacts, download) = runtimediff --git a/moli-renderer-v8/src/script_vm/subresource_fetch.rs b/moli-renderer-v8/src/script_vm/subresource_fetch.rsindex 8ca25a98a..e0a4070f9 100644--- a/moli-renderer-v8/src/script_vm/subresource_fetch.rs+++ b/moli-renderer-v8/src/script_vm/subresource_fetch.rs@@ -868,7 +868,7 @@ impl ScriptVm {target: WorkerOwnedFetchTarget,request: crate::worker::WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {match target {WorkerOwnedFetchTarget::Dedicated { worker_id, .. } => self@@ -897,7 +897,7 @@ impl ScriptVm {target: WorkerOwnedXhrTarget,request: crate::worker::WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {match target {WorkerOwnedXhrTarget::Dedicated { worker_id, .. } => self@@ -957,7 +957,7 @@ impl ScriptVm {target: WorkerOwnedFetchTarget,request: crate::worker::WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {match target {@@ -987,7 +987,7 @@ impl ScriptVm {target: WorkerOwnedXhrTarget,request: crate::worker::WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {match target {@@ -1017,7 +1017,7 @@ impl ScriptVm {target: WorkerOwnedCspReportTarget,request: crate::worker::WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {match target {@@ -1048,7 +1048,7 @@ impl ScriptVm {target: WorkerOwnedFetchTarget,request: crate::worker::WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {match target {@@ -1080,7 +1080,7 @@ impl ScriptVm {target: WorkerOwnedXhrTarget,request: crate::worker::WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {match target {@@ -2167,7 +2167,7 @@ impl ScriptVm {&mut self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> Result<AsyncSubresourceCommandExecution<()>> {let pending = self@@ -2613,7 +2613,7 @@ impl ScriptVm {&mut self,internal_id: u64,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> Result<AsyncSubresourceCommandExecution<()>> {let pending_websocket_response = {self._context_host@@ -2896,7 +2896,7 @@ impl ScriptVm {&mut self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> Result<AsyncSubresourceCommandExecution<()>> {let pending_websocket_response = {@@ -3121,7 +3121,7 @@ impl ScriptVm {&mut self,internal_id: u64,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> Result<()> {let execution = self.fulfill_pending_subresource_fetch_body(diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/images.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/images.rsindex 68a13102b..bf0e11beb 100644--- a/moli-renderer-v8/src/script_vm/tests/browser_api/images.rs+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/images.rs@@ -404,7 +404,7 @@ async fn image_fetch_enabled_rejects_http_success_with_corrupt_image_bytes() {vm.fulfill_pending_subresource_fetch(pending[0].internal_id,200,- vec![("Content-Type".to_owned(), "image/jpeg".to_owned())],+ vec![("Content-Type".to_owned(), b"image/jpeg".to_vec())],crate::runtime::RendererSyntheticResponseBody::from_bytes(b"<html>not an image</html>".to_vec(),),@@ -454,7 +454,7 @@ async fn inserting_completed_detached_image_does_not_restart_request() {vm.fulfill_pending_subresource_fetch(pending[0].internal_id,200,- vec![("Content-Type".to_owned(), "image/gif".to_owned())],+ vec![("Content-Type".to_owned(), b"image/gif".to_vec())],one_by_one_gif_response_body(),).expect("detached image response should complete");@@ -525,7 +525,7 @@ async fn removed_lazy_image_suppresses_in_flight_terminal_event() {vm.fulfill_pending_subresource_fetch(pending[0].internal_id,200,- vec![("Content-Type".to_owned(), "image/gif".to_owned())],+ vec![("Content-Type".to_owned(), b"image/gif".to_vec())],one_by_one_gif_response_body(),).expect("removed lazy image response should complete");@@ -719,7 +719,7 @@ async fn replacing_image_source_discards_queued_stale_decode_pixels() {vm.fulfill_pending_subresource_fetch(old_request[0].internal_id,200,- vec![("Content-Type".to_owned(), "image/png".to_owned())],+ vec![("Content-Type".to_owned(), b"image/png".to_vec())],crate::runtime::RendererSyntheticResponseBody::from_bytes(old_png.bytes),).expect("old image response should fulfill");@@ -763,7 +763,7 @@ async fn replacing_image_source_discards_queued_stale_decode_pixels() {vm.fulfill_pending_subresource_fetch(new_request[0].internal_id,200,- vec![("Content-Type".to_owned(), "image/png".to_owned())],+ vec![("Content-Type".to_owned(), b"image/png".to_vec())],crate::runtime::RendererSyntheticResponseBody::from_bytes(new_png.bytes),).expect("replacement image response should fulfill");@@ -831,7 +831,7 @@ async fn image_request_interception_fulfills_through_image_continuation() {vm.fulfill_pending_subresource_fetch(pending.internal_id,404,- vec![("Content-Type".to_owned(), "text/plain".to_owned())],+ vec![("Content-Type".to_owned(), b"text/plain".to_vec())],crate::runtime::RendererSyntheticResponseBody::empty(),).expect("intercepted image request should fulfill");@@ -889,7 +889,7 @@ async fn image_decode_waits_for_in_flight_pixels_and_reuses_the_ready_resource()vm.fulfill_pending_subresource_fetch(pending[0].internal_id,200,- vec![("Content-Type".to_owned(), "image/gif".to_owned())],+ vec![("Content-Type".to_owned(), b"image/gif".to_vec())],one_by_one_gif_response_body(),).expect("in-flight image response should fulfill");@@ -996,7 +996,7 @@ async fn changing_image_cross_origin_restarts_intercepted_request() {vm.fulfill_pending_subresource_fetch(first[0].internal_id,200,- vec![("Content-Type".to_owned(), "image/png".to_owned())],+ vec![("Content-Type".to_owned(), b"image/png".to_vec())],crate::runtime::RendererSyntheticResponseBody::empty(),).is_err(),@@ -1013,7 +1013,7 @@ async fn changing_image_cross_origin_restarts_intercepted_request() {vm.fulfill_pending_subresource_fetch(second[0].internal_id,200,- vec![("Content-Type".to_owned(), "image/gif".to_owned())],+ vec![("Content-Type".to_owned(), b"image/gif".to_vec())],one_by_one_gif_response_body(),).expect("replacement image request should fulfill");@@ -1078,7 +1078,7 @@ async fn changing_picture_source_restarts_intercepted_image_request() {vm.fulfill_pending_subresource_fetch(second[0].internal_id,200,- vec![("Content-Type".to_owned(), "image/gif".to_owned())],+ vec![("Content-Type".to_owned(), b"image/gif".to_vec())],one_by_one_gif_response_body(),).expect("replacement picture image request should fulfill");diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/navigation.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/navigation.rsindex 997207b33..6627b1edf 100644--- a/moli-renderer-v8/src/script_vm/tests/browser_api/navigation.rs+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/navigation.rs@@ -663,7 +663,7 @@ fn parser_script_network_results_populate_buffered_resource_timing_snapshots() {status: 200,headers: vec![("Content-Type".to_owned(),- "Application/JavaScript; charset=utf-8".to_owned(),+ b"Application/JavaScript; charset=utf-8".to_vec(),)],request_cookie_report: None,cookie_set_reports: Vec::new(),diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/response_headers.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/response_headers.rsindex 486139f32..00c3d6056 100644--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/response_headers.rs+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/response_headers.rs@@ -8,6 +8,7 @@ fn xhr_response_headers_are_filtered_combined_and_sorted_before_events() {.unwrap();let headers: Vec<(String, String)> =serde_json::from_value(fixture["headers"].clone()).unwrap();+ let headers = moli_fetch::headers_from_byte_strings(&headers).unwrap();for streaming in [false, true] {let mut vm = new_storage_test_vm("https://xhr-response-headers.test/");vm.set_fetch_subresource_interception(diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/xhr.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/xhr.rsindex bf5fb475b..249c29353 100644--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/xhr.rs+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/xhr.rs@@ -845,7 +845,8 @@ fn xml_http_request_blob_response_uses_final_mime_type() {let headers = headers.iter().map(|value| ("Content-Type".to_owned(), (*value).to_owned()))- .collect();+ .collect::<Vec<_>>();+ let headers = moli_fetch::headers_from_byte_strings(&headers).unwrap();let context_ptr: *const v8::Global<v8::Context> = &vm.page_default_context as *const _;vm.renderer_document_isolate@@ -905,6 +906,25 @@ fn xml_http_request_blob_response_uses_final_mime_type() {.expect("xhr override MIME response probe should run");assert_eq!(result, format!("4|{expected}|throw:InvalidStateError"));++ let roundtrip = vm+ .eval(+ r#"+(() => {+ const url = URL.createObjectURL(__xhrMime.response);+ try {+ const xhr = new XMLHttpRequest();+ xhr.open('GET', url, false);+ xhr.send();+ return xhr.getResponseHeader('Content-Type');+ } finally {+ URL.revokeObjectURL(url);+ }+})()+"#,+ )+ .expect("Blob URL response should preserve MIME header bytes");+ assert_eq!(roundtrip, *expected);}}@@ -948,7 +968,7 @@ fn xml_http_request_default_response_type_parses_response_xml_for_document_mime(final_url: Url::parse("https://xhr-response-xml.test/xml-doc").expect("XML response URL should parse"),status: 200,- headers: vec![("Content-Type".to_owned(), "text/plain".to_owned())],+ headers: vec![("Content-Type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -974,7 +994,7 @@ fn xml_http_request_default_response_type_parses_response_xml_for_document_mime(final_url: Url::parse("https://xhr-response-xml.test/plain").expect("plain response URL should parse"),status: 200,- headers: vec![("Content-Type".to_owned(), "text/plain".to_owned())],+ headers: vec![("Content-Type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -1955,9 +1975,9 @@ __streamingXhr.send();headers: vec![("Content-Type".to_owned(),- "text/plain; charset=utf-8".to_owned(),+ b"text/plain; charset=utf-8".to_vec(),),- ("Content-Length".to_owned(), "7".to_owned()),+ ("Content-Length".to_owned(), b"7".to_vec()),],request_cookie_report: None,cookie_set_reports: Vec::new(),@@ -2113,7 +2133,7 @@ async fn streaming_subresource_finish_preserves_response_head_cache_state() {head: moli_fetch::ResponseHead {final_url: final_url.clone(),status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: true,@@ -2122,7 +2142,10 @@ async fn streaming_subresource_finish_preserves_response_head_cache_state() {from_url: request_url.clone(),to_url: final_url.clone(),status: 301,- headers: vec![("location".to_owned(), final_url.to_string())],+ headers: vec![(+ "location".to_owned(),+ final_url.as_str().as_bytes().to_vec(),+ )],network_extra_info_available: false,request_extra_info: None,response_extra_info: None,@@ -2403,7 +2426,7 @@ async fn streaming_fetch_body_error_records_response_started_then_body_failed()head: moli_fetch::ResponseHead {final_url: final_url.clone(),status: 206,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -2499,7 +2522,7 @@ fn install_streaming_fetch_response_fixture(moli_fetch::ResponseHead {final_url: request_url.clone(),status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -2558,7 +2581,7 @@ fn install_streaming_fetch_response_fixture(head: moli_fetch::ResponseHead {final_url: request_url,status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -2667,7 +2690,7 @@ async fn streaming_fetch_body_cancel_aborts_streaming_subresource() {head: moli_fetch::ResponseHead {final_url: request_url,status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-renderer-v8/src/script_vm/tests/mod.rs b/moli-renderer-v8/src/script_vm/tests/mod.rsindex c017bb662..5615fdad0 100644--- a/moli-renderer-v8/src/script_vm/tests/mod.rs+++ b/moli-renderer-v8/src/script_vm/tests/mod.rs@@ -502,7 +502,7 @@ fn redirected_fetch_response(source_url: &Url, final_url: Url) -> crate::types::let mut response = crate::types::NavigationResponse::from_text_body(final_url.clone(),200,- vec![("content-type".to_owned(), "text/plain".to_owned())],+ vec![("content-type".to_owned(), b"text/plain".to_vec())],"redirected Fetch completed".to_owned(),);response.redirected = true;@@ -3000,7 +3000,7 @@ async fn child_navigation_aborts_fetch_and_detaches_keepalive() {result: Ok(crate::types::NavigationResponse::from_text_body(final_url,200,- vec![("content-type".to_owned(), "text/plain".to_owned())],+ vec![("content-type".to_owned(), b"text/plain".to_vec())],"keepalive completed".to_owned(),)).into(),@@ -3803,7 +3803,7 @@ fn isolated_realm_destruction_aborts_fetch_and_detaches_keepalive() {head: moli_fetch::ResponseHead {final_url: request_url,status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs b/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rsindex 659d60c45..59f8d35cd 100644--- a/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs+++ b/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs@@ -9496,7 +9496,7 @@ fn response_clone_tees_pending_network_body_after_parent_consumption() {moli_fetch::ResponseHead {final_url: response_url,status: 200,- headers: vec![("content-type".to_owned(), "application/json".to_owned())],+ headers: vec![("content-type".to_owned(), b"application/json".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -9597,7 +9597,7 @@ fn pending_fetch_body_pipe_through_text_decoder_stream_pulls_future_chunks() {moli_fetch::ResponseHead {final_url: response_url,status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -9715,7 +9715,7 @@ fn materialize_response_object_preserves_redirected_slot() {moli_fetch::ResponseHead {final_url: final_url.clone(),status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: true,@@ -9767,7 +9767,7 @@ fn filtered_response_materialization_preserves_urls_across_clone_and_cache() {moli_fetch::ResponseHead {final_url: final_url.clone(),status: 302,- headers: vec![("location".to_owned(), "target.html".to_owned())],+ headers: vec![("location".to_owned(), b"target.html".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-renderer-v8/src/script_vm/tests/window_execution_context.rs b/moli-renderer-v8/src/script_vm/tests/window_execution_context.rsindex cb805eb3c..43ee7ba06 100644--- a/moli-renderer-v8/src/script_vm/tests/window_execution_context.rs+++ b/moli-renderer-v8/src/script_vm/tests/window_execution_context.rs@@ -522,7 +522,7 @@ fn borrowed_fetch_uses_receiver_realm_and_keeps_reaction_realm_independent() {result: Ok(crate::types::NavigationResponse::from_text_body(completion_url,200,- vec![("content-type".to_owned(), "text/plain".to_owned())],+ vec![("content-type".to_owned(), b"text/plain".to_vec())],"borrowed completion".to_owned(),)).into(),diff --git a/moli-renderer-v8/src/service_worker_runtime/events.rs b/moli-renderer-v8/src/service_worker_runtime/events.rsindex 042a08819..b7777acea 100644--- a/moli-renderer-v8/src/service_worker_runtime/events.rs+++ b/moli-renderer-v8/src/service_worker_runtime/events.rs@@ -631,7 +631,7 @@ pub(crate) struct ServiceWorkerFetchResponse {pub(crate) redirected: bool,pub(crate) status: u16,pub(crate) status_text: String,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,pub(crate) body: Vec<u8>,}@@ -695,7 +695,7 @@ pub(crate) struct MaterializedServiceWorkerFetchResponseHead {pub(crate) response_type: String,pub(crate) redirected: bool,pub(crate) status: u16,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,}#[derive(Debug)]diff --git a/moli-renderer-v8/src/service_worker_runtime/host.rs b/moli-renderer-v8/src/service_worker_runtime/host.rsindex d355365b3..eea1cfd95 100644--- a/moli-renderer-v8/src/service_worker_runtime/host.rs+++ b/moli-renderer-v8/src/service_worker_runtime/host.rs@@ -964,7 +964,7 @@ fn spawn_service_worker(fn service_worker_script_policy_context(final_url: &url::Url,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> SubresourcePolicyContext {SubresourcePolicyContext {cross_origin_embedder_policy:@@ -1001,18 +1001,18 @@ mod tests {fn service_worker_script_policy_context_uses_response_headers() {let final_url = url::Url::parse("https://worker.test/service-worker.js").expect("valid service worker url");- let headers = vec![+ let headers: Vec<(String, Vec<u8>)> = vec![("Cross-Origin-Embedder-Policy".to_owned(),- "require-corp".to_owned(),+ b"require-corp".to_vec(),),("Cross-Origin-Opener-Policy".to_owned(),- "same-origin".to_owned(),+ b"same-origin".to_vec(),),("Document-Isolation-Policy".to_owned(),- "isolate-and-credentialless".to_owned(),+ b"isolate-and-credentialless".to_vec(),),];@@ -1033,18 +1033,18 @@ mod tests {fn service_worker_script_policy_context_requires_trustworthy_url_for_capability() {let final_url = url::Url::parse("http://worker.test/service-worker.js").expect("valid service worker url");- let headers = vec![+ let headers: Vec<(String, Vec<u8>)> = vec![("Cross-Origin-Embedder-Policy".to_owned(),- "require-corp".to_owned(),+ b"require-corp".to_vec(),),("Cross-Origin-Opener-Policy".to_owned(),- "same-origin".to_owned(),+ b"same-origin".to_vec(),),("Document-Isolation-Policy".to_owned(),- "isolate-and-require-corp".to_owned(),+ b"isolate-and-require-corp".to_vec(),),];diff --git a/moli-renderer-v8/src/service_worker_runtime/path_restriction.rs b/moli-renderer-v8/src/service_worker_runtime/path_restriction.rsindex dfc5de725..e3e259a3b 100644--- a/moli-renderer-v8/src/service_worker_runtime/path_restriction.rs+++ b/moli-renderer-v8/src/service_worker_runtime/path_restriction.rs@@ -2,7 +2,7 @@ use url::Url;const SERVICE_WORKER_ALLOWED_HEADER: &str = "Service-Worker-Allowed";-pub(super) fn service_worker_allowed_header_value(headers: &[(String, String)]) -> Option<String> {+pub(super) fn service_worker_allowed_header_value(headers: &[(String, Vec<u8>)]) -> Option<String> {moli_web_mime::response_header_value(headers, SERVICE_WORKER_ALLOWED_HEADER).map(|value| value.trim().to_owned())}@@ -259,7 +259,8 @@ mod tests {#[test]fn allowed_header_value_is_case_insensitive_and_trimmed() {- let headers = vec![("service-worker-allowed".to_owned(), " /app/ ".to_owned())];+ let headers: Vec<(String, Vec<u8>)> =+ vec![("service-worker-allowed".to_owned(), b" /app/ ".to_vec())];assert_eq!(service_worker_allowed_header_value(&headers).as_deref(),Some("/app/")diff --git a/moli-renderer-v8/src/service_worker_runtime/resource_store.rs b/moli-renderer-v8/src/service_worker_runtime/resource_store.rsindex 84cc0f365..76f0242d4 100644--- a/moli-renderer-v8/src/service_worker_runtime/resource_store.rs+++ b/moli-renderer-v8/src/service_worker_runtime/resource_store.rs@@ -363,7 +363,8 @@ struct JsonScriptResource {final_url: String,kind: String,status: u16,- headers: Vec<(String, String)>,+ #[serde(deserialize_with = "moli_fetch::deserialize_headers")]+ headers: Vec<(String, Vec<u8>)>,body_len: usize,body_sha256: String,response_time_ms: u64,@@ -897,7 +898,7 @@ mod tests {final_url: raw_url.parse().expect("final URL should parse"),kind,status: 200,- headers: vec![("content-type".to_owned(), "text/javascript".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/javascript".to_vec())],body_len: 11,body_sha256: "hash".to_owned(),response_time_ms: 7,diff --git a/moli-renderer-v8/src/service_worker_runtime/script_loading.rs b/moli-renderer-v8/src/service_worker_runtime/script_loading.rsindex 1def35185..bd4062d16 100644--- a/moli-renderer-v8/src/service_worker_runtime/script_loading.rs+++ b/moli-renderer-v8/src/service_worker_runtime/script_loading.rs@@ -54,7 +54,7 @@ pub(super) struct ServiceWorkerScriptResource {pub(super) final_url: Url,pub(super) kind: WorkerScriptResourceKind,pub(super) status: u16,- pub(super) headers: Vec<(String, String)>,+ pub(super) headers: Vec<(String, Vec<u8>)>,pub(super) body_len: usize,pub(super) body_sha256: String,pub(super) response_time_ms: u64,@@ -428,7 +428,7 @@ mod tests {let head = ResponseHead {final_url: Url::parse("https://example.test/app/sw.js?final").unwrap(),status: 200,- headers: vec![("Content-Type".to_owned(), "text/javascript".to_owned())],+ headers: vec![("Content-Type".to_owned(), b"text/javascript".to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,@@ -816,7 +816,7 @@ mod tests {let head = ResponseHead {final_url: script_url.clone(),status: 200,- headers: vec![("Content-Type".to_owned(), mime_type.to_owned())],+ headers: vec![("Content-Type".to_owned(), mime_type.as_bytes().to_vec())],request_cookie_report: None,cookie_set_reports: Vec::new(),redirected: false,diff --git a/moli-renderer-v8/src/service_worker_runtime/service.rs b/moli-renderer-v8/src/service_worker_runtime/service.rsindex 0200c5162..a0624250f 100644--- a/moli-renderer-v8/src/service_worker_runtime/service.rs+++ b/moli-renderer-v8/src/service_worker_runtime/service.rs@@ -1321,7 +1321,7 @@ mod tests {final_url: script_url.clone(),kind: crate::worker::WorkerScriptResourceKind::JavaScript,status: 200,- headers: vec![("Content-Type".to_owned(), "text/javascript".to_owned())],+ headers: vec![("Content-Type".to_owned(), b"text/javascript".to_vec())],body_len: 3,body_sha256: "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad".to_owned(),@@ -1336,7 +1336,7 @@ mod tests {final_url: script_url.clone(),kind: crate::worker::WorkerScriptResourceKind::JavaScript,status: 200,- headers: vec![("Content-Type".to_owned(), "text/javascript".to_owned())],+ headers: vec![("Content-Type".to_owned(), b"text/javascript".to_vec())],body_len: 3,body_sha256: "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad".to_owned(),@@ -8715,7 +8715,7 @@ self.addEventListener("message", event => {result: ServiceWorkerFetchResult::Response(ServiceWorkerFetchResponse {status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],body: b"handled".to_vec(),final_url: None,response_type: "basic".to_owned(),@@ -9016,7 +9016,7 @@ self.addEventListener("message", event => {result: ServiceWorkerFetchResult::Response(ServiceWorkerFetchResponse {status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],body: b"late".to_vec(),final_url: None,response_type: "basic".to_owned(),@@ -9508,8 +9508,8 @@ self.addEventListener("message", event => {.headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("x-service-worker"))- .map(|(_, value)| value.as_str()),- Some("worker-client")+ .map(|(_, value)| value.as_slice()),+ Some(b"worker-client".as_slice()));assert_eq!(response.response.body_text(),diff --git a/moli-renderer-v8/src/service_worker_runtime/service/fetch_settlement.rs b/moli-renderer-v8/src/service_worker_runtime/service/fetch_settlement.rsindex 55112497b..e373a74c1 100644--- a/moli-renderer-v8/src/service_worker_runtime/service/fetch_settlement.rs+++ b/moli-renderer-v8/src/service_worker_runtime/service/fetch_settlement.rs@@ -26,7 +26,7 @@ fn service_worker_redirect_target(.headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("location"))- .map(|(_, value)| value.as_str())+ .map(|(_, value)| moli_fetch::decode_header_value(value))else {return Ok(None);};@@ -36,7 +36,7 @@ fn service_worker_redirect_target(response.final_url.as_ref().unwrap_or(&job.request.url)));}- if let Ok(url) = Url::parse(location) {+ if let Ok(url) = Url::parse(&location) {return Ok(Some(url));}let Some(base_url) = response.final_url.as_ref() else {@@ -44,7 +44,7 @@ fn service_worker_redirect_target("failed to resolve redirect location `{location}` for a generated response without a response URL"));};- base_url.join(location).map(Some).map_err(|error| {+ base_url.join(&location).map(Some).map_err(|error| {format!("failed to resolve redirect location `{location}` from {base_url}: {error}")})}@@ -802,7 +802,7 @@ fn validate_service_worker_fetch_response_body_security_policy(fn validate_service_worker_fetch_response_head_security_policy(job: &ServiceWorkerFetchJob,final_url: &Url,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Result<(), String> {if job.request.request_mode != moli_fetch::RequestMode::NoCors|| matches!(@@ -1260,7 +1260,7 @@ mod tests {redirected: false,status: 202,status_text: "Accepted".to_owned(),- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],body: b"service-worker-body".to_vec(),}),});@@ -1280,7 +1280,7 @@ mod tests {assert!(!response.redirected);assert_eq!(response.headers,- vec![("content-type".to_owned(), "text/plain".to_owned())]+ vec![("content-type".to_owned(), b"text/plain".to_vec())]);assert_eq!(response.body_text(), "service-worker-body");}@@ -1316,7 +1316,7 @@ mod tests {response_type: "default".to_owned(),redirected: false,status: 202,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],},});@@ -1354,7 +1354,7 @@ mod tests {redirected: false,status: 202,status_text: "Accepted".to_owned(),- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],body: b"AB".to_vec(),}),});@@ -1400,7 +1400,7 @@ mod tests {response_type: "default".to_owned(),redirected: false,status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],},});match pop_async_subresource_event(&mut completion_queue) {@@ -1655,7 +1655,7 @@ mod tests {status_text: "Found".to_owned(),headers: vec![("location".to_owned(),- "https://example.test/redirected.txt".to_owned(),+ b"https://example.test/redirected.txt".to_vec(),)],body: Vec::new(),}),@@ -1776,7 +1776,7 @@ mod tests {redirected: false,status: 302,status_text: "Found".to_owned(),- headers: vec![("location".to_owned(), "/manual-target.txt".to_owned())],+ headers: vec![("location".to_owned(), b"/manual-target.txt".to_vec())],body: Vec::new(),}),});@@ -1797,7 +1797,7 @@ mod tests {assert!(response.redirect_chain.is_empty());assert_eq!(response.headers,- vec![("location".to_owned(), "/manual-target.txt".to_owned())]+ vec![("location".to_owned(), b"/manual-target.txt".to_vec())]);}@@ -1839,7 +1839,7 @@ mod tests {status_text: "Found".to_owned(),headers: vec![("Location".to_owned(),- "https://example.test/app/next.txt".to_owned(),+ b"https://example.test/app/next.txt".to_vec(),)],body: Vec::new(),}),@@ -1944,7 +1944,7 @@ mod tests {redirected: false,status: 303,status_text: "See Other".to_owned(),- headers: vec![("Location".to_owned(), "next".to_owned())],+ headers: vec![("Location".to_owned(), b"next".to_vec())],body: Vec::new(),};let next_url = service_worker_redirect_target(&job, &response)@@ -2018,7 +2018,7 @@ mod tests {redirected: false,status: 302,status_text: "Found".to_owned(),- headers: vec![("Location".to_owned(), "relative-target.txt".to_owned())],+ headers: vec![("Location".to_owned(), b"relative-target.txt".to_vec())],body: Vec::new(),}),});@@ -2065,7 +2065,7 @@ mod tests {redirected: false,status: 302,status_text: "Found".to_owned(),- headers: vec![("Location".to_owned(), "blank.html".to_owned())],+ headers: vec![("Location".to_owned(), b"blank.html".to_vec())],body: Vec::new(),}),});@@ -2335,10 +2335,10 @@ mod tests {status: 200,status_text: "OK".to_owned(),headers: vec![- ("content-type".to_owned(), "image/png".to_owned()),+ ("content-type".to_owned(), b"image/png".to_vec()),("cross-origin-resource-policy".to_owned(),- "same-origin".to_owned(),+ b"same-origin".to_vec(),),],body: b"blocked".to_vec(),@@ -2388,10 +2388,10 @@ mod tests {status: 200,status_text: "OK".to_owned(),headers: vec![- ("content-type".to_owned(), "image/png".to_owned()),+ ("content-type".to_owned(), b"image/png".to_vec()),("cross-origin-resource-policy".to_owned(),- "same-origin".to_owned(),+ b"same-origin".to_vec(),),],body: b"blocked".to_vec(),@@ -2450,7 +2450,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],body: b"png".to_vec(),}),});@@ -2509,7 +2509,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],body: b"png".to_vec(),}),});@@ -2568,10 +2568,10 @@ mod tests {status: 200,status_text: "OK".to_owned(),headers: vec![- ("content-type".to_owned(), "image/png".to_owned()),+ ("content-type".to_owned(), b"image/png".to_vec()),("cross-origin-resource-policy".to_owned(),- "cross-origin".to_owned(),+ b"cross-origin".to_vec(),),],body: b"png".to_vec(),@@ -2626,10 +2626,10 @@ mod tests {status: 200,status_text: "OK".to_owned(),headers: vec![- ("content-type".to_owned(), "image/png".to_owned()),+ ("content-type".to_owned(), b"image/png".to_vec()),("cross-origin-resource-policy".to_owned(),- "cross-origin".to_owned(),+ b"cross-origin".to_vec(),),],body: b"png".to_vec(),@@ -2684,7 +2684,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],body: b"png".to_vec(),}),});@@ -2737,7 +2737,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],body: b"png".to_vec(),}),});@@ -2795,7 +2795,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],body: b"png".to_vec(),}),});@@ -2852,7 +2852,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],body: b"png".to_vec(),}),});@@ -2903,7 +2903,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],body: b"png".to_vec(),}),});@@ -2961,7 +2961,7 @@ mod tests {response_type: "default".to_owned(),redirected: false,status: 200,- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],},});@@ -3028,7 +3028,7 @@ mod tests {response_type: "default".to_owned(),redirected: false,status: 200,- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],},});@@ -3092,7 +3092,7 @@ mod tests {response_type: "default".to_owned(),redirected: false,status: 200,- headers: vec![("content-type".to_owned(), "image/png".to_owned())],+ headers: vec![("content-type".to_owned(), b"image/png".to_vec())],},});@@ -3143,7 +3143,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "application/json".to_owned())],+ headers: vec![("content-type".to_owned(), b"application/json".to_vec())],body: br#"{"secret":true}"#.to_vec(),}),});@@ -3189,7 +3189,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("content-type".to_owned(), "application/json".to_owned())],+ headers: vec![("content-type".to_owned(), b"application/json".to_vec())],body: br#"{"visible":true}"#.to_vec(),}),});diff --git a/moli-renderer-v8/src/shared_worker_runtime/loading.rs b/moli-renderer-v8/src/shared_worker_runtime/loading.rsindex 070349ede..89cb132e5 100644--- a/moli-renderer-v8/src/shared_worker_runtime/loading.rs+++ b/moli-renderer-v8/src/shared_worker_runtime/loading.rs@@ -602,13 +602,13 @@ pub(super) fn load_shared_worker_blob_script_source(})}-fn response_referrer_policy(headers: &[(String, String)]) -> Option<String> {+fn response_referrer_policy(headers: &[(String, Vec<u8>)]) -> Option<String> {response_referrer_policy_from_headers(headers)}fn worker_policy_context_from_response(final_url: &Url,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> SubresourcePolicyContext {SubresourcePolicyContext {cross_origin_embedder_policy:@@ -742,14 +742,14 @@ mod tests {#[test]fn shared_worker_response_policy_context_uses_response_headers() {- let headers = vec![+ let headers: Vec<(String, Vec<u8>)> = vec![("Cross-Origin-Embedder-Policy".to_owned(),- "require-corp".to_owned(),+ b"require-corp".to_vec(),),("Document-Isolation-Policy".to_owned(),- "isolate-and-credentialless".to_owned(),+ b"isolate-and-credentialless".to_vec(),),];@@ -820,9 +820,9 @@ mod tests {#[test]fn shared_worker_response_referrer_policy_combines_header_instances() {- let headers = vec![- ("Referrer-Policy".to_owned(), "no-referrer".to_owned()),- ("referrer-policy".to_owned(), "future-policy".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Referrer-Policy".to_owned(), b"no-referrer".to_vec()),+ ("referrer-policy".to_owned(), b"future-policy".to_vec()),];assert_eq!(@@ -833,9 +833,9 @@ mod tests {#[test]fn shared_worker_response_referrer_policy_uses_last_valid_token() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Referrer-Policy".to_owned(),- "not-yet-standardized, no-referrer".to_owned(),+ b"not-yet-standardized, no-referrer".to_vec(),)];assert_eq!(@@ -846,11 +846,11 @@ mod tests {#[test]fn shared_worker_response_referrer_policy_ignores_invalid_later_header() {- let headers = vec![- ("Referrer-Policy".to_owned(), "no-referrer".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Referrer-Policy".to_owned(), b"no-referrer".to_vec()),("Referrer-Policy".to_owned(),- "not-yet-standardized".to_owned(),+ b"not-yet-standardized".to_vec(),),];diff --git a/moli-renderer-v8/src/shared_worker_runtime/resource_commands.rs b/moli-renderer-v8/src/shared_worker_runtime/resource_commands.rsindex bdb80b477..6d40776e4 100644--- a/moli-renderer-v8/src/shared_worker_runtime/resource_commands.rs+++ b/moli-renderer-v8/src/shared_worker_runtime/resource_commands.rs@@ -22,7 +22,7 @@ impl RendererSharedWorkerHost {&self,request: WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.send_worker_message(WorkerMessage::ContinuePendingFetchResponse {request,@@ -35,7 +35,7 @@ impl RendererSharedWorkerHost {&self,request: WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.send_worker_message(WorkerMessage::ContinuePendingXhrResponse {request,@@ -125,7 +125,7 @@ impl RendererSharedWorkerHost {&self,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.send_worker_message(WorkerMessage::FulfillPendingFetch {@@ -140,7 +140,7 @@ impl RendererSharedWorkerHost {&self,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.send_worker_message(WorkerMessage::FulfillPendingXhr {@@ -155,7 +155,7 @@ impl RendererSharedWorkerHost {&self,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.send_worker_message(WorkerMessage::FulfillPendingCspReport {@@ -170,7 +170,7 @@ impl RendererSharedWorkerHost {&self,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.send_worker_message(WorkerMessage::FulfillPendingFetchResponse {@@ -185,7 +185,7 @@ impl RendererSharedWorkerHost {&self,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.send_worker_message(WorkerMessage::FulfillPendingXhrResponse {diff --git a/moli-renderer-v8/src/shared_worker_runtime/resource_routing.rs b/moli-renderer-v8/src/shared_worker_runtime/resource_routing.rsindex 90b653e36..f07d1e768 100644--- a/moli-renderer-v8/src/shared_worker_runtime/resource_routing.rs+++ b/moli-renderer-v8/src/shared_worker_runtime/resource_routing.rs@@ -20,12 +20,12 @@ enum SharedWorkerResourceCommand {ContinueFetchResponse {request: WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,},ContinueXhrResponse {request: WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,},FailFetch {request: WorkerPendingFetchContinue,@@ -58,31 +58,31 @@ enum SharedWorkerResourceCommand {FulfillFetch {request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},FulfillXhr {request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},FulfillCspReport {request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},FulfillFetchResponse {request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},FulfillXhrResponse {request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},}@@ -229,7 +229,7 @@ impl SharedWorkerRuntimeService {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.dispatch_resource_command(instance_id,@@ -246,7 +246,7 @@ impl SharedWorkerRuntimeService {instance_id: SharedWorkerInstanceId,request: WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) -> bool {self.dispatch_resource_command(instance_id,@@ -368,7 +368,7 @@ impl SharedWorkerRuntimeService {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.dispatch_resource_command(@@ -387,7 +387,7 @@ impl SharedWorkerRuntimeService {instance_id: SharedWorkerInstanceId,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.dispatch_resource_command(@@ -406,7 +406,7 @@ impl SharedWorkerRuntimeService {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.dispatch_resource_command(@@ -425,7 +425,7 @@ impl SharedWorkerRuntimeService {instance_id: SharedWorkerInstanceId,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.dispatch_resource_command(@@ -444,7 +444,7 @@ impl SharedWorkerRuntimeService {instance_id: SharedWorkerInstanceId,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) -> bool {self.dispatch_resource_command(diff --git a/moli-renderer-v8/src/stylesheet_blocking.rs b/moli-renderer-v8/src/stylesheet_blocking.rsindex 741693b00..60dca0533 100644--- a/moli-renderer-v8/src/stylesheet_blocking.rs+++ b/moli-renderer-v8/src/stylesheet_blocking.rs@@ -389,7 +389,7 @@ mod tests {body: &str,) -> crate::protocol_types::NavigationResponse {let headers = content_type- .map(|value| vec![("Content-Type".to_owned(), value.to_owned())])+ .map(|value| vec![("Content-Type".to_owned(), value.as_bytes().to_vec())]).unwrap_or_default();crate::protocol_types::NavigationResponse::from_text_body(url.clone(),@@ -511,10 +511,10 @@ mod tests {stylesheet_url.clone(),200,vec![- ("Content-Type".to_owned(), "text/css".to_owned()),+ ("Content-Type".to_owned(), b"text/css".to_vec()),("Access-Control-Allow-Origin".to_owned(),- "https://page.example.test".to_owned(),+ b"https://page.example.test".to_vec(),),],"body { color: green; }".to_owned(),@@ -548,7 +548,7 @@ mod tests {let response = crate::protocol_types::NavigationResponse::from_text_body(stylesheet_url.clone(),200,- vec![("Content-Type".to_owned(), "text/css".to_owned())],+ vec![("Content-Type".to_owned(), b"text/css".to_vec())],"body { color: red; }".to_owned(),);@@ -577,7 +577,7 @@ mod tests {let response = crate::protocol_types::NavigationResponse::from_text_body(stylesheet_url.clone(),404,- vec![("Content-Type".to_owned(), "text/css".to_owned())],+ vec![("Content-Type".to_owned(), b"text/css".to_vec())],"body { color: red; }".to_owned(),);diff --git a/moli-renderer-v8/src/types.rs b/moli-renderer-v8/src/types.rsindex 3f5598bb5..9d6c98eb1 100644--- a/moli-renderer-v8/src/types.rs+++ b/moli-renderer-v8/src/types.rs@@ -990,11 +990,16 @@ pub(super) struct XhrStreamingResponseState {}impl XhrStreamingResponseState {- pub(super) fn new(headers: &[(String, String)]) -> Self {+ pub(super) fn new(headers: &[(String, Vec<u8>)]) -> Self {let total = headers.iter().find(|(name, _)| name.eq_ignore_ascii_case("content-length"))- .and_then(|(_, value)| value.trim().parse::<usize>().ok());+ .and_then(|(_, value)| {+ moli_fetch::decode_header_value(value)+ .trim()+ .parse::<usize>()+ .ok()+ });Self {pending_utf8_bytes: Vec::new(),loaded: 0,diff --git a/moli-renderer-v8/src/worker/global_scope/content_security_policy.rs b/moli-renderer-v8/src/worker/global_scope/content_security_policy.rsindex 6ff817a54..dc9a6d068 100644--- a/moli-renderer-v8/src/worker/global_scope/content_security_policy.rs+++ b/moli-renderer-v8/src/worker/global_scope/content_security_policy.rs@@ -663,7 +663,7 @@ pub(in crate::worker) fn fulfill_pending_worker_csp_report(state: &Rc<RefCell<WorkerGlobalState>>,continuation: WorkerPendingFetchContinue,_response_code: u16,- _response_headers: Vec<(String, String)>,+ _response_headers: Vec<(String, Vec<u8>)>,_response_body: RendererSyntheticResponseBody,) {statediff --git a/moli-renderer-v8/src/worker/global_scope/fetch.rs b/moli-renderer-v8/src/worker/global_scope/fetch.rsindex f65adab86..dbc60413b 100644--- a/moli-renderer-v8/src/worker/global_scope/fetch.rs+++ b/moli-renderer-v8/src/worker/global_scope/fetch.rs@@ -802,7 +802,7 @@ pub(in crate::worker) fn fulfill_pending_worker_fetch(state: &Rc<RefCell<WorkerGlobalState>>,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) {let fetch_id = request.fetch_id;@@ -843,7 +843,7 @@ pub(in crate::worker) fn continue_pending_worker_fetch_response(state: &Rc<RefCell<WorkerGlobalState>>,request: WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) {let fetch_id = request.fetch_id;let completion = {@@ -913,7 +913,7 @@ pub(in crate::worker) fn fulfill_pending_worker_fetch_response(state: &Rc<RefCell<WorkerGlobalState>>,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) {let fetch_id = request.fetch_id;@@ -1110,7 +1110,7 @@ pub(in crate::worker) fn fulfill_pending_worker_xhr(state: &Rc<RefCell<WorkerGlobalState>>,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) {let xhr_id = request.xhr_id;@@ -1150,7 +1150,7 @@ pub(in crate::worker) fn continue_pending_worker_xhr_response(state: &Rc<RefCell<WorkerGlobalState>>,request: WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) {let xhr_id = request.xhr_id;let completion = {@@ -1216,7 +1216,7 @@ pub(in crate::worker) fn fulfill_pending_worker_xhr_response(state: &Rc<RefCell<WorkerGlobalState>>,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) {let xhr_id = request.xhr_id;@@ -1566,7 +1566,7 @@ pub(in crate::worker) fn dispatch_worker_websocket_event(socket_id,&socket_url,&loader,- &response_headers.to_byte_strings(),+ response_headers,);parent_messages.push(WorkerToParentMessage::WebSocketLifecycle(WorkerWebSocketLifecycleEvent::Open {@@ -1588,7 +1588,7 @@ pub(in crate::worker) fn dispatch_worker_websocket_event(Vec::new(),socket_url.clone(),*response_status,- response_headers.to_byte_strings(),+ response_headers.to_vec(),String::new(),cookie_set_reports,)@@ -1720,7 +1720,7 @@ pub(in crate::worker) fn store_worker_websocket_response_cookies(_socket_id: u64,socket_url: &Url,request_client: &crate::network::context::WorkerResourceLoader,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],) -> Vec<StoredCookieSetReport> {if !response_headers.iter()@@ -2476,7 +2476,7 @@ pub(in crate::worker) fn reject_worker_fetches_for_signal(pub(in crate::worker) fn worker_response_from_body(final_url: Url,status: u16,- headers: Vec<(String, String)>,+ headers: Vec<(String, Vec<u8>)>,body: RendererSyntheticResponseBody,) -> Response {body.into_fetch_response(ResponseHead {diff --git a/moli-renderer-v8/src/worker/global_scope/import_scripts.rs b/moli-renderer-v8/src/worker/global_scope/import_scripts.rsindex 890345003..a8cf664f6 100644--- a/moli-renderer-v8/src/worker/global_scope/import_scripts.rs+++ b/moli-renderer-v8/src/worker/global_scope/import_scripts.rs@@ -139,7 +139,11 @@ fn ensure_worker_import_script_mime_acceptable(mime_type: &str,body: &[u8],) -> Result<(), WorkerImportScriptError> {- let headers = [("Content-Type".to_owned(), mime_type.to_owned())];+ let headers = [(+ "Content-Type".to_owned(),+ moli_fetch::header_value_from_byte_string(mime_type)+ .expect("serialized MIME types contain ByteStrings"),+ )];crate::worker::ensure_worker_script_mime_acceptable(script_url, &headers, body).map_err(WorkerImportScriptError::network)}diff --git a/moli-renderer-v8/src/worker/handle.rs b/moli-renderer-v8/src/worker/handle.rsindex 91cf5b366..a444a2e6d 100644--- a/moli-renderer-v8/src/worker/handle.rs+++ b/moli-renderer-v8/src/worker/handle.rs@@ -176,13 +176,13 @@ pub(crate) enum WorkerMessage {ContinuePendingFetchResponse {request: WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,},/// Continue a worker-owned XHR response that was paused for Fetch domain interception.ContinuePendingXhrResponse {request: WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,},/// Fail a worker-owned fetch() that was paused for Fetch domain interception.FailPendingFetch {@@ -223,35 +223,35 @@ pub(crate) enum WorkerMessage {FulfillPendingFetch {request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},/// Fulfill a worker-owned XHR that was paused for Fetch domain interception.FulfillPendingXhr {request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},/// Fulfill a worker-owned CSP report that was paused for Fetch domain interception.FulfillPendingCspReport {request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},/// Fulfill a worker-owned fetch() response that was paused for Fetch domain interception.FulfillPendingFetchResponse {request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},/// Fulfill a worker-owned XHR response that was paused for Fetch domain interception.FulfillPendingXhrResponse {request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,},/// Request the worker to terminate.@@ -392,7 +392,7 @@ pub(crate) struct WorkerScriptResource {pub(crate) final_url: Url,pub(crate) kind: WorkerScriptResourceKind,pub(crate) status: u16,- pub(crate) headers: Vec<(String, String)>,+ pub(crate) headers: Vec<(String, Vec<u8>)>,pub(crate) body_len: usize,pub(crate) body_sha256: String,pub(crate) response_time_ms: u64,@@ -1188,7 +1188,7 @@ impl WorkerHandle {&self,request: WorkerPendingFetchContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) {let _ = self.tx.send(WorkerMessage::ContinuePendingFetchResponse {request,@@ -1201,7 +1201,7 @@ impl WorkerHandle {&self,request: WorkerPendingXhrContinue,response_code: Option<u16>,- response_headers: Option<Vec<(String, String)>>,+ response_headers: Option<Vec<(String, Vec<u8>)>>,) {let _ = self.tx.send(WorkerMessage::ContinuePendingXhrResponse {request,@@ -1287,7 +1287,7 @@ impl WorkerHandle {&self,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) {let _ = self.tx.send(WorkerMessage::FulfillPendingFetch {@@ -1302,7 +1302,7 @@ impl WorkerHandle {&self,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) {let _ = self.tx.send(WorkerMessage::FulfillPendingXhr {@@ -1317,7 +1317,7 @@ impl WorkerHandle {&self,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) {let _ = self.tx.send(WorkerMessage::FulfillPendingCspReport {@@ -1332,7 +1332,7 @@ impl WorkerHandle {&self,request: WorkerPendingFetchContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) {let _ = self.tx.send(WorkerMessage::FulfillPendingFetchResponse {@@ -1347,7 +1347,7 @@ impl WorkerHandle {&self,request: WorkerPendingXhrContinue,response_code: u16,- response_headers: Vec<(String, String)>,+ response_headers: Vec<(String, Vec<u8>)>,response_body: RendererSyntheticResponseBody,) {let _ = self.tx.send(WorkerMessage::FulfillPendingXhrResponse {diff --git a/moli-renderer-v8/src/worker/module_mime.rs b/moli-renderer-v8/src/worker/module_mime.rsindex 9469e338c..b8b34b8e5 100644--- a/moli-renderer-v8/src/worker/module_mime.rs+++ b/moli-renderer-v8/src/worker/module_mime.rs@@ -64,7 +64,7 @@ pub(crate) fn ensure_worker_text_module_mime())}-fn worker_module_response_content_type(headers: &[(String, String)]) -> Option<String> {+fn worker_module_response_content_type(headers: &[(String, Vec<u8>)]) -> Option<String> {response_header_values(headers, "content-type").into_iter().next_back()diff --git a/moli-renderer-v8/src/worker/script_mime.rs b/moli-renderer-v8/src/worker/script_mime.rsindex eda00458f..58209656e 100644--- a/moli-renderer-v8/src/worker/script_mime.rs+++ b/moli-renderer-v8/src/worker/script_mime.rs@@ -5,20 +5,20 @@ use url::Url;pub(crate) fn ensure_worker_script_mime_acceptable(script_url: &Url,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body: &[u8],) -> Result<(), String> {check_script_response_mime(headers, body, FetchDestination::Worker, true).map_err(|error| worker_script_mime_error_message(script_url, error))}-pub(crate) fn worker_response_content_type(headers: &[(String, String)]) -> Option<String> {+pub(crate) fn worker_response_content_type(headers: &[(String, Vec<u8>)]) -> Option<String> {response_header_values(headers, "content-type").into_iter().next_back()}-pub(crate) fn worker_response_has_webassembly_mime(headers: &[(String, String)]) -> bool {+pub(crate) fn worker_response_has_webassembly_mime(headers: &[(String, Vec<u8>)]) -> bool {worker_response_content_type(headers).as_deref().is_some_and(moli_web_mime::is_webassembly_mime)@@ -42,9 +42,9 @@ mod tests {#[test]fn worker_script_mime_accepts_javascript_content_types() {let url = Url::parse("https://example.test/worker.js").expect("valid url");- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "Text/JavaScript; charset=utf-8".to_owned(),+ b"Text/JavaScript; charset=utf-8".to_vec(),)];assert!(ensure_worker_script_mime_acceptable(&url, &headers, b"").is_ok());@@ -53,7 +53,8 @@ mod tests {#[test]fn worker_script_mime_rejects_http_non_javascript_content_types() {let url = Url::parse("https://example.test/worker.py").expect("valid url");- let headers = vec![("content-type".to_owned(), "text/html".to_owned())];+ let headers: Vec<(String, Vec<u8>)> =+ vec![("content-type".to_owned(), b"text/html".to_vec())];assert!(ensure_worker_script_mime_acceptable(&url, &headers, b"").is_err());}@@ -70,7 +71,8 @@ mod tests {#[test]fn worker_script_mime_allows_invalid_content_type_through_script_context_default() {let url = Url::parse("https://example.test/worker").expect("valid url");- let headers = vec![("content-type".to_owned(), "not a mime type".to_owned())];+ let headers: Vec<(String, Vec<u8>)> =+ vec![("content-type".to_owned(), b"not a mime type".to_vec())];assert!(ensure_worker_script_mime_acceptable(&url, &headers, b"").is_ok());}@@ -78,7 +80,8 @@ mod tests {#[test]fn worker_script_mime_rejects_nosniff_missing_content_type() {let url = Url::parse("https://example.test/worker").expect("valid url");- let headers = vec![("x-content-type-options".to_owned(), "nosniff".to_owned())];+ let headers: Vec<(String, Vec<u8>)> =+ vec![("x-content-type-options".to_owned(), b"nosniff".to_vec())];assert!(ensure_worker_script_mime_acceptable(&url, &headers, b"").is_err());}diff --git a/moli-renderer-v8/src/worker/thread/tests/lifecycle.rs b/moli-renderer-v8/src/worker/thread/tests/lifecycle.rsindex 535ca5da4..5d6d678fe 100644--- a/moli-renderer-v8/src/worker/thread/tests/lifecycle.rs+++ b/moli-renderer-v8/src/worker/thread/tests/lifecycle.rs@@ -769,7 +769,7 @@ async fn service_worker_fetch_event_preload_response_resolves_network_response()response_type: "default".to_owned(),redirected: false,status: 202,- headers: vec![("x-preload".to_owned(), "yes".to_owned())],+ headers: vec![("x-preload".to_owned(), b"yes".to_vec())],},},);@@ -880,7 +880,7 @@ async fn service_worker_fetch_event_preload_response_opaqueredirect_exposes_requresponse_type: "default".to_owned(),redirected: false,status: 302,- headers: vec![("location".to_owned(), "/app/final.html".to_owned())],+ headers: vec![("location".to_owned(), b"/app/final.html".to_vec())],},},);@@ -1053,7 +1053,7 @@ async fn service_worker_fetch_event_preload_response_body_errors_after_response(response_type: "default".to_owned(),redirected: false,status: 202,- headers: vec![("x-preload".to_owned(), "yes".to_owned())],+ headers: vec![("x-preload".to_owned(), b"yes".to_vec())],},},);@@ -1166,7 +1166,7 @@ async fn service_worker_fetch_event_preload_response_body_completes_after_fetch_response_type: "default".to_owned(),redirected: false,status: 200,- headers: vec![("content-type".to_owned(), "text/plain".to_owned())],+ headers: vec![("content-type".to_owned(), b"text/plain".to_vec())],},},);@@ -2152,7 +2152,7 @@ async fn service_worker_fetch_respond_with_materialized_response() {response.headers.iter()- .any(|(name, value)| name == "x-worker" && value == "yes")+ .any(|(name, value)| name == "x-worker" && value == b"yes"));handle.terminate_and_join();}@@ -2193,7 +2193,7 @@ async fn service_worker_fetch_respond_with_readable_stream_body_materializes() {response.headers.iter()- .any(|(name, value)| name == "x-stream" && value == "yes")+ .any(|(name, value)| name == "x-stream" && value == b"yes"));handle.terminate_and_join();}@@ -2253,7 +2253,7 @@ async fn service_worker_fetch_respond_with_readable_stream_body_posts_stream_chu.response_head.headers.iter()- .any(|(name, value)| name == "x-stream" && value == "yes")+ .any(|(name, value)| name == "x-stream" && value == b"yes"));body_source_id = Some(started.body_source_id);}@@ -9128,7 +9128,7 @@ async fn worker_fetch_csp_report_to_posts_reporting_api_body() {crate::content_security_policy::content_security_policy_reporting_endpoints_from_headers(&[("Reporting-Endpoints".to_owned(),- "csp=\"/report-to\"".to_owned(),+ b"csp=\"/report-to\"".to_vec(),)],&url::Url::parse(&script_url).expect("script url"),);diff --git a/moli-renderer-v8/src/worker/thread/tests/modules.rs b/moli-renderer-v8/src/worker/thread/tests/modules.rsindex e0509390a..bb791ffad 100644--- a/moli-renderer-v8/src/worker/thread/tests/modules.rs+++ b/moli-renderer-v8/src/worker/thread/tests/modules.rs@@ -1248,7 +1248,7 @@ async fn worker_module_same_origin_dependency_fetch_sends_cookies() {&url::Url::parse(&format!("{base_url}/worker/main.js")).unwrap(),&[("set-cookie".to_owned(),- "wpt_worker_module_credentials=fixture; Path=/worker; SameSite=Lax".to_owned(),+ b"wpt_worker_module_credentials=fixture; Path=/worker; SameSite=Lax".to_vec(),)],);}diff --git a/moli-renderer-v8/src/worker/thread/tests/network.rs b/moli-renderer-v8/src/worker/thread/tests/network.rsindex 5eec4ff85..5d34fab00 100644--- a/moli-renderer-v8/src/worker/thread/tests/network.rs+++ b/moli-renderer-v8/src/worker/thread/tests/network.rs@@ -2928,10 +2928,10 @@ async fn worker_xhr_request_stage_interception_can_fulfill_synthetic_response()request,204,vec![- ("content-type".to_owned(), "text/plain".to_owned()),+ ("content-type".to_owned(), b"text/plain".to_vec()),("x-worker-xhr-intercept".to_owned(),- "request-stage".to_owned(),+ b"request-stage".to_vec(),),],RendererSyntheticResponseBody::from_bytes(b"fulfilled-worker-xhr".to_vec()),@@ -3090,10 +3090,10 @@ async fn worker_xhr_response_stage_interception_pauses_before_done() {request,Some(206),Some(vec![- ("content-type".to_owned(), "text/plain".to_owned()),+ ("content-type".to_owned(), b"text/plain".to_vec()),("x-worker-xhr-response-stage".to_owned(),- "continued".to_owned(),+ b"continued".to_vec(),),]),);@@ -3950,8 +3950,8 @@ async fn worker_fetch_request_stage_interception_can_fulfill_synthetic_response(request,202,vec![- ("content-type".to_owned(), "text/plain".to_owned()),- ("x-worker-intercept".to_owned(), "request-stage".to_owned()),+ ("content-type".to_owned(), b"text/plain".to_vec()),+ ("x-worker-intercept".to_owned(), b"request-stage".to_vec()),],RendererSyntheticResponseBody::from_bytes(b"fulfilled-worker-fetch".to_vec()),);@@ -4038,13 +4038,13 @@ async fn worker_subresource_request_handles_are_owner_unique() {first.fulfill_pending_fetch(first_request,200,- vec![("content-type".to_owned(), "text/plain".to_owned())],+ vec![("content-type".to_owned(), b"text/plain".to_vec())],RendererSyntheticResponseBody::from_bytes(b"first-worker-body".to_vec()),);second.fulfill_pending_fetch(second_request,200,- vec![("content-type".to_owned(), "text/plain".to_owned())],+ vec![("content-type".to_owned(), b"text/plain".to_vec())],RendererSyntheticResponseBody::from_bytes(b"second-worker-body".to_vec()),);@@ -4219,8 +4219,8 @@ async fn worker_fetch_response_stage_interception_pauses_before_resolving_responrequest,Some(203),Some(vec![- ("content-type".to_owned(), "text/plain".to_owned()),- ("x-worker-response-stage".to_owned(), "continued".to_owned()),+ ("content-type".to_owned(), b"text/plain".to_vec()),+ ("x-worker-response-stage".to_owned(), b"continued".to_vec()),]),);diff --git a/moli-storage-service/Cargo.toml b/moli-storage-service/Cargo.tomlindex 1e3756549..7966cf494 100644--- a/moli-storage-service/Cargo.toml+++ b/moli-storage-service/Cargo.toml@@ -6,6 +6,7 @@ edition = "2024"description = "Renderer-neutral Moli storage service and bucket identity"[dependencies]+moli-header-field = { path = "../moli-header-field" }anyhow = "1.0.100"base64 = "0.22.1"moli-browser-profile = { path = "../moli-browser-profile" }diff --git a/moli-storage-service/src/buckets.rs b/moli-storage-service/src/buckets.rsindex b4aa01153..2bd0ac7d3 100644--- a/moli-storage-service/src/buckets.rs+++ b/moli-storage-service/src/buckets.rs@@ -137,7 +137,7 @@ pub struct StorageBucketCachedResponse {pub redirected: bool,pub status: u16,pub status_text: String,- pub headers: Vec<(String, String)>,+ pub headers: Vec<(String, Vec<u8>)>,pub body: Vec<u8>,}@@ -409,7 +409,8 @@ struct StorageBucketCacheJsonEntry {redirected: bool,status: u16,status_text: String,- headers: Vec<(String, String)>,+ #[serde(deserialize_with = "moli_header_field::deserialize_headers")]+ headers: Vec<(String, Vec<u8>)>,body_base64: String,}@@ -1779,10 +1780,11 @@ fn cache_entry_matches_query(}fn cached_response_vary_matches_request(- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],stored_request_headers: &[(String, String)],query_request_headers: &[(String, String)],) -> bool {+ let response_headers = moli_header_field::headers_to_byte_strings(response_headers);let vary_names = response_headers.iter().filter(|(name, _)| name.eq_ignore_ascii_case("vary"))@@ -3161,7 +3163,7 @@ mod tests {redirected: false,status: 201,status_text: "Created".to_owned(),- headers: vec![("x-cache".to_owned(), "hit".to_owned())],+ headers: vec![("x-cache".to_owned(), b"hit".to_vec())],body: b"cached body".to_vec(),};@@ -3310,7 +3312,7 @@ mod tests {let mut store = StorageBucketRegistry::default();let identity = store.open_bucket("https://a.test", "bucket")?;assert!(store.open_cache_for_identity(&identity, "cache")?);- let response = |body: &str, headers: Vec<(String, String)>| StorageBucketCachedResponse {+ let response = |body: &str, headers: Vec<(String, Vec<u8>)>| StorageBucketCachedResponse {response_type: "default".to_owned(),url: String::new(),redirected: false,@@ -3336,7 +3338,7 @@ mod tests {method: "GET".to_owned(),headers: vec![("x-mode".to_owned(), "alpha".to_owned())],},- response("vary-alpha", vec![("vary".to_owned(), "X-Mode".to_owned())]),+ response("vary-alpha", vec![("vary".to_owned(), b"X-Mode".to_vec())]),),] {assert_eq!(@@ -3920,7 +3922,12 @@ mod tests {redirected: false,status: 202,status_text: "Accepted".to_owned(),- headers: vec![("x-cache".to_owned(), "persisted".to_owned())],+ headers: vec![+ ("x-cache".to_owned(), b"persisted".to_vec()),+ ("x-bytes".to_owned(), b"\xff\x80\xa0".to_vec()),+ ("x-bytes".to_owned(), b"\xc3\xbf".to_vec()),+ ("x-empty".to_owned(), Vec::new()),+ ],body: b"profile cache body".to_vec(),};{@@ -3992,7 +3999,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("x-cache".to_owned(), "old".to_owned())],+ headers: vec![("x-cache".to_owned(), b"old".to_vec())],body: b"old committed cache body".to_vec(),};let new_response = StorageBucketCachedResponse {@@ -4001,7 +4008,7 @@ mod tests {redirected: false,status: 201,status_text: "Created".to_owned(),- headers: vec![("x-cache".to_owned(), "new".to_owned())],+ headers: vec![("x-cache".to_owned(), b"new".to_vec())],body: b"new committed cache body".to_vec(),};@@ -4085,7 +4092,7 @@ mod tests {redirected: false,status: 206,status_text: "Partial Content".to_owned(),- headers: vec![("x-cache".to_owned(), "next".to_owned())],+ headers: vec![("x-cache".to_owned(), b"next".to_vec())],body: b"replacement cache body".to_vec(),};{@@ -4137,7 +4144,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("x-cache".to_owned(), "previous".to_owned())],+ headers: vec![("x-cache".to_owned(), b"previous".to_vec())],body: b"previous cache body".to_vec(),};{@@ -4554,7 +4561,7 @@ mod tests {redirected: false,status: 200,status_text: "OK".to_owned(),- headers: vec![("x-cache".to_owned(), "legacy-path".to_owned())],+ headers: vec![("x-cache".to_owned(), b"legacy-path".to_vec())],body: b"legacy cache path".to_vec(),};let entries = BTreeMap::from([(diff --git a/moli-stylesheet-blocking/src/state.rs b/moli-stylesheet-blocking/src/state.rsindex 3a2a92386..35d228749 100644--- a/moli-stylesheet-blocking/src/state.rs+++ b/moli-stylesheet-blocking/src/state.rs@@ -806,7 +806,7 @@ mod tests {moli_page_types::NavigationResponse::from_text_body(url,200,- vec![("content-type".to_owned(), "text/css".to_owned())],+ vec![("content-type".to_owned(), b"text/css".to_vec())],"body { color: black; }".to_owned(),),true,@@ -862,7 +862,7 @@ mod tests {moli_page_types::NavigationResponse::from_text_body(url,200,- vec![("content-type".to_owned(), "text/css".to_owned())],+ vec![("content-type".to_owned(), b"text/css".to_vec())],"body { color: black; }".to_owned(),),true,@@ -894,7 +894,7 @@ mod tests {moli_page_types::NavigationResponse::from_text_body(url,200,- vec![("content-type".to_owned(), "text/css".to_owned())],+ vec![("content-type".to_owned(), b"text/css".to_vec())],"body { color: black; }".to_owned(),),true,@@ -1137,7 +1137,7 @@ mod tests {moli_page_types::NavigationResponse::from_text_body(first_url,200,- vec![("content-type".to_owned(), "text/css".to_owned())],+ vec![("content-type".to_owned(), b"text/css".to_vec())],"body { color: red; }".to_owned(),),true,diff --git a/moli-web-mime/Cargo.toml b/moli-web-mime/Cargo.tomlindex 8208d6599..903d71fd6 100644--- a/moli-web-mime/Cargo.toml+++ b/moli-web-mime/Cargo.toml@@ -5,6 +5,7 @@ version = "0.1.0"edition = "2024"[dependencies]+moli-header-field = { path = "../moli-header-field" }content_disposition = "0.4.0"data-url = "0.3.2"http = "1"diff --git a/moli-web-mime/src/headers.rs b/moli-web-mime/src/headers.rsindex ff73f36fa..29b0733df 100644--- a/moli-web-mime/src/headers.rs+++ b/moli-web-mime/src/headers.rs@@ -1,22 +1,22 @@use crate::classification::is_binary_document_mime_type;use crate::parse::{mime_essence, normalize_web_api_mime_type};-pub fn response_header_value(headers: &[(String, String)], name: &str) -> Option<String> {+pub fn response_header_value(headers: &[(String, Vec<u8>)], name: &str) -> Option<String> {response_header_values(headers, name).into_iter().next()}-pub fn response_header_values(headers: &[(String, String)], name: &str) -> Vec<String> {+pub fn response_header_values(headers: &[(String, Vec<u8>)], name: &str) -> Vec<String> {let Some(name) = parsed_header_name(name) else {return Vec::new();};headers.iter().filter(|(header_name, _)| header_name_matches(header_name, &name))- .map(|(_, value)| value.to_owned())+ .map(|(_, value)| moli_header_field::decode_header_value(value).into_owned()).collect()}-pub fn response_content_type(headers: &[(String, String)]) -> Option<String> {+pub fn response_content_type(headers: &[(String, Vec<u8>)]) -> Option<String> {response_header_value(headers, "content-type")}@@ -27,7 +27,7 @@ pub fn response_content_type(headers: &[(String, String)]) -> Option<String> {/// Repeated values with the same essence inherit the first value's charset/// when their own charset is absent.pub fn extract_response_mime_type(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> Option<moli_content_type::MimeType> {let combined = response_header_values(headers, "content-type").join(", ");let mut quoted = false;@@ -70,33 +70,36 @@ pub fn extract_response_mime_type(}/// The essence returned by Fetch's "extract a MIME type" algorithm.-pub fn extract_response_mime_essence(headers: &[(String, String)]) -> Option<String> {+pub fn extract_response_mime_essence(headers: &[(String, Vec<u8>)]) -> Option<String> {extract_response_mime_type(headers).map(|mime| mime.essence())}-pub fn response_headers_indicate_attachment_download(headers: &[(String, String)]) -> bool {+pub fn response_headers_indicate_attachment_download(headers: &[(String, Vec<u8>)]) -> bool {headers.iter().any(|(name, value)| {let Ok(name) = http::HeaderName::from_bytes(name.as_bytes()) else {return false;};name == http::header::CONTENT_DISPOSITION- && content_disposition::parse_content_disposition(value).disposition+ && content_disposition::parse_content_disposition(+ &moli_header_field::decode_header_value(value),+ )+ .disposition== content_disposition::DispositionType::Attachment})}-pub fn response_headers_indicate_binary_document(headers: &[(String, String)]) -> bool {+pub fn response_headers_indicate_binary_document(headers: &[(String, Vec<u8>)]) -> bool {response_content_type(headers).as_deref().is_some_and(is_binary_document_mime_type)}-pub fn response_headers_indicate_raw_document(headers: &[(String, String)]) -> bool {+pub fn response_headers_indicate_raw_document(headers: &[(String, Vec<u8>)]) -> bool {response_headers_indicate_attachment_download(headers)|| response_headers_indicate_binary_document(headers)}-pub fn response_document_content_type(headers: &[(String, String)]) -> Option<String> {+pub fn response_document_content_type(headers: &[(String, Vec<u8>)]) -> Option<String> {let content_type = response_header_values(headers, "content-type").into_iter().last()?;@@ -106,7 +109,7 @@ pub fn response_document_content_type(headers: &[(String, String)]) -> Option<St}pub fn effective_response_mime_type(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],override_mime_type: Option<&str>,) -> Option<String> {override_mime_type@@ -116,7 +119,7 @@ pub fn effective_response_mime_type(}pub fn effective_response_mime_essence(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],override_mime_type: Option<&str>,) -> Option<String> {effective_response_mime_type(headers, override_mime_type)@@ -124,7 +127,7 @@ pub fn effective_response_mime_essence(.and_then(mime_essence)}-pub fn response_blob_mime_type(headers: &[(String, String)]) -> String {+pub fn response_blob_mime_type(headers: &[(String, Vec<u8>)]) -> String {normalize_response_blob_mime_type(response_content_type(headers).as_deref())}diff --git a/moli-web-mime/src/response_policy.rs b/moli-web-mime/src/response_policy.rsindex 8a8b6c4ff..1f13bdb07 100644--- a/moli-web-mime/src/response_policy.rs+++ b/moli-web-mime/src/response_policy.rs@@ -7,18 +7,20 @@ use crate::headers::response_header_value;use crate::parse::{mime_charset, mime_essence};use crate::sniffing::{MimeSniffingContext, computed_mime_type, sniff_image_mime_type};-pub fn determine_nosniff(headers: &[(String, String)]) -> bool {+pub fn determine_nosniff(headers: &[(String, Vec<u8>)]) -> bool {headers.iter()- .filter(|(name, _)| name.eq_ignore_ascii_case("x-content-type-options"))- .flat_map(|(_, value)| value.split(','))- .map(str::trim)- .next()- .is_some_and(|value| value.eq_ignore_ascii_case("nosniff"))+ .find(|(name, _)| name.eq_ignore_ascii_case("x-content-type-options"))+ .is_some_and(|(_, value)| {+ moli_header_field::decode_header_value(value)+ .split(',')+ .next()+ .is_some_and(|value| value.trim().eq_ignore_ascii_case("nosniff"))+ })}pub fn should_response_be_blocked_due_to_nosniff(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],destination: FetchDestination,) -> bool {if !determine_nosniff(headers) {@@ -39,7 +41,7 @@ pub fn should_response_be_blocked_due_to_nosniff(false}-pub fn should_opaque_response_be_blocked_by_orb(headers: &[(String, String)]) -> bool {+pub fn should_opaque_response_be_blocked_by_orb(headers: &[(String, Vec<u8>)]) -> bool {let content_type = response_header_value(headers, "content-type");if determine_nosniff(headers)&& content_type@@ -114,7 +116,7 @@ pub fn should_opaque_response_be_blocked_by_orb(headers: &[(String, String)]) ->}pub fn should_opaque_response_be_blocked_by_orb_with_body(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body: &[u8],) -> bool {if !should_opaque_response_be_blocked_by_orb(headers) {@@ -141,7 +143,7 @@ pub fn should_opaque_response_be_blocked_by_orb_with_body(}pub fn computed_response_mime_type(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],context: MimeSniffingContext,body: &[u8],) -> String {@@ -161,7 +163,7 @@ pub enum ScriptResponseMimeError {}pub fn check_script_response_mime(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body: &[u8],destination: FetchDestination,require_javascript_mime: bool,@@ -185,7 +187,7 @@ pub fn check_script_response_mime(}pub fn should_script_like_response_be_blocked_due_to_mime_type(- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],) -> bool {let Some(content_type) = response_header_value(headers, "content-type") else {return false;diff --git a/moli-web-mime/src/tests.rs b/moli-web-mime/src/tests.rsindex 114541750..560449b5d 100644--- a/moli-web-mime/src/tests.rs+++ b/moli-web-mime/src/tests.rs@@ -96,11 +96,11 @@ fn matches_document_types() {#[test]fn classifies_document_resource_mime_from_headers_and_url() {- let headers = vec![- ("Content-Type".to_owned(), "text/plain".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Content-Type".to_owned(), b"text/plain".to_vec()),("content-type".to_owned(),- " Application/XHTML+XML ; charset=utf-8 ".to_owned(),+ b" Application/XHTML+XML ; charset=utf-8 ".to_vec(),),];assert_eq!(@@ -108,7 +108,7 @@ fn classifies_document_resource_mime_from_headers_and_url() {Some("application/xhtml+xml"));assert_eq!(- response_document_content_type(&[("Content-Type".to_owned(), " ".to_owned())]),+ response_document_content_type(&[("Content-Type".to_owned(), b" ".to_vec())]),None);@@ -137,31 +137,31 @@ fn classifies_document_resource_mime_from_headers_and_url() {fn classifies_binary_main_document_headers() {assert!(response_headers_indicate_raw_document(&[("Content-Type".to_owned(),- "application/pdf; charset=binary".to_owned(),+ b"application/pdf; charset=binary".to_vec(),)]));assert!(response_headers_indicate_raw_document(&[("Content-Type".to_owned(),- "image/png".to_owned(),+ b"image/png".to_vec(),)]));assert!(response_headers_indicate_raw_document(&[("Content-Disposition".to_owned(),- "attachment; filename=report.html".to_owned(),+ b"attachment; filename=report.html".to_vec(),)]));assert!(response_headers_indicate_raw_document(&[("Content-Type".to_owned(),- "application/wasm".to_owned(),+ b"application/wasm".to_vec(),)]));assert!(!response_headers_indicate_raw_document(&[("Content-Type".to_owned(),- "text/html; charset=utf-8".to_owned(),+ b"text/html; charset=utf-8".to_vec(),)]));assert!(!response_headers_indicate_raw_document(&[("Content-Type".to_owned(),- "text/plain".to_owned(),+ b"text/plain".to_vec(),)]));assert!(!response_headers_indicate_raw_document(&[("Content-Disposition".to_owned(),- "inline; filename=report.pdf".to_owned(),+ b"inline; filename=report.pdf".to_vec(),)]));}@@ -302,10 +302,10 @@ fn normalizes_valid_web_api_mime_types() {#[test]fn reads_response_header_values_case_insensitively() {- let headers = vec![- ("Content-Type".to_owned(), "text/html".to_owned()),- ("content-type".to_owned(), "application/json".to_owned()),- ("Bad Header".to_owned(), "ignored".to_owned()),+ let headers: Vec<(String, Vec<u8>)> = vec![+ ("Content-Type".to_owned(), b"text/html".to_vec()),+ ("content-type".to_owned(), b"application/json".to_vec()),+ ("Bad Header".to_owned(), b"ignored".to_vec()),];assert_eq!(@@ -369,7 +369,7 @@ fn extracts_response_mime_essence_from_the_combined_header_list() {(&["application/vnd.中文+json"], None),];for (values, expected) in cases {- let mut headers: Vec<_> = values+ let mut headers: Vec<(String, Vec<u8>)> = values.iter().enumerate().map(|(index, value)| {@@ -380,11 +380,11 @@ fn extracts_response_mime_essence_from_the_combined_header_list() {"cOnTeNt-TyPe"}.to_owned(),- (*value).to_owned(),+ value.as_bytes().to_vec(),)}).collect();- headers.push(("X-Content-Type".to_owned(), "application/json".to_owned()));+ headers.push(("X-Content-Type".to_owned(), b"application/json".to_vec()));assert_eq!(extract_response_mime_essence(&headers).as_deref(),*expected,@@ -448,11 +448,12 @@ fn extracts_response_mime_parameters_with_charset_inheritance() {),];for (values, expected) in cases {- let mut headers: Vec<_> = values+ let headers = values.iter().map(|value| ("cOnTeNt-TyPe".to_owned(), (*value).to_owned()))- .collect();- headers.push(("X-Content-Type".to_owned(), "text/ignored".to_owned()));+ .collect::<Vec<_>>();+ let mut headers = moli_header_field::headers_from_byte_strings(&headers).unwrap();+ headers.push(("X-Content-Type".to_owned(), b"text/ignored".to_vec()));assert_eq!(extract_response_mime_type(&headers).map(|mime| mime.to_string())@@ -465,9 +466,9 @@ fn extracts_response_mime_parameters_with_charset_inheritance() {#[test]fn derives_effective_response_mime_for_body_consumers() {- let headers = vec![(+ let headers: Vec<(String, Vec<u8>)> = vec![("Content-Type".to_owned(),- "Text/HTML; Charset=UTF-8".to_owned(),+ b"Text/HTML; Charset=UTF-8".to_vec(),)];assert_eq!(@@ -487,7 +488,8 @@ fn derives_effective_response_mime_for_body_consumers() {"text/html; charset=utf-8");- let invalid = vec![("Content-Type".to_owned(), "text/plain\n".to_owned())];+ let invalid: Vec<(String, Vec<u8>)> =+ vec![("Content-Type".to_owned(), b"text/plain\n".to_vec())];assert_eq!(response_blob_mime_type(&invalid), "");}@@ -495,38 +497,38 @@ fn derives_effective_response_mime_for_body_consumers() {fn determines_nosniff_from_first_option_token() {assert!(determine_nosniff(&[("X-Content-Type-Options".to_owned(),- "NoSniff".to_owned()+ b"NoSniff".to_vec())]));assert!(determine_nosniff(&[("x-content-type-options".to_owned(),- "nosniff, other".to_owned()+ b"nosniff, other".to_vec())]));assert!(!determine_nosniff(&[("x-content-type-options".to_owned(),- "other, nosniff".to_owned()+ b"other, nosniff".to_vec())]));assert!(!determine_nosniff(&[("x-content-type-options".to_owned(),- "sniff".to_owned()+ b"sniff".to_vec())]));}#[test]fn nosniff_blocks_script_like_and_style_mismatches_only() {- let html_nosniff = vec![- ("content-type".to_owned(), "text/html".to_owned()),- ("x-content-type-options".to_owned(), "nosniff".to_owned()),+ let html_nosniff: Vec<(String, Vec<u8>)> = vec![+ ("content-type".to_owned(), b"text/html".to_vec()),+ ("x-content-type-options".to_owned(), b"nosniff".to_vec()),];- let script_nosniff = vec![+ let script_nosniff: Vec<(String, Vec<u8>)> = vec![("content-type".to_owned(),- "application/javascript".to_owned(),+ b"application/javascript".to_vec(),),- ("x-content-type-options".to_owned(), "nosniff".to_owned()),+ ("x-content-type-options".to_owned(), b"nosniff".to_vec()),];- let css_nosniff = vec![- ("content-type".to_owned(), "text/css".to_owned()),- ("x-content-type-options".to_owned(), "nosniff".to_owned()),+ let css_nosniff: Vec<(String, Vec<u8>)> = vec![+ ("content-type".to_owned(), b"text/css".to_vec()),+ ("x-content-type-options".to_owned(), b"nosniff".to_vec()),];assert!(should_response_be_blocked_due_to_nosniff(@@ -553,7 +555,8 @@ fn nosniff_blocks_script_like_and_style_mismatches_only() {#[test]fn nosniff_blocks_missing_content_type_for_script_like_and_style() {- let headers = vec![("x-content-type-options".to_owned(), "nosniff".to_owned())];+ let headers: Vec<(String, Vec<u8>)> =+ vec![("x-content-type-options".to_owned(), b"nosniff".to_vec())];assert!(should_response_be_blocked_due_to_nosniff(&headers,@@ -587,7 +590,7 @@ fn orb_blocks_opaque_response_blocklisted_mime_types() {assert!(should_opaque_response_be_blocked_by_orb(&[("Content-Type".to_owned(),- content_type.to_owned()+ content_type.as_bytes().to_vec())]),"{content_type} should be ORB-blocked");@@ -606,7 +609,7 @@ fn orb_allows_safelisted_opaque_response_mime_types() {assert!(!should_opaque_response_be_blocked_by_orb(&[("Content-Type".to_owned(),- content_type.to_owned()+ content_type.as_bytes().to_vec())]),"{content_type} should be ORB-allowed");@@ -617,11 +620,11 @@ fn orb_allows_safelisted_opaque_response_mime_types() {fn orb_blocks_missing_or_empty_content_type_with_nosniff() {assert!(should_opaque_response_be_blocked_by_orb(&[("X-Content-Type-Options".to_owned(),- "nosniff".to_owned()+ b"nosniff".to_vec())]));assert!(should_opaque_response_be_blocked_by_orb(&[- ("Content-Type".to_owned(), String::new()),- ("X-Content-Type-Options".to_owned(), "nosniff".to_owned()),+ ("Content-Type".to_owned(), Vec::new()),+ ("X-Content-Type-Options".to_owned(), b"nosniff".to_vec()),]));assert!(!should_opaque_response_be_blocked_by_orb(&[]));}@@ -629,11 +632,11 @@ fn orb_blocks_missing_or_empty_content_type_with_nosniff() {#[test]fn orb_body_sniffing_allows_mislabeled_images() {assert!(!should_opaque_response_be_blocked_by_orb_with_body(- &[("Content-Type".to_owned(), "text/html".to_owned())],+ &[("Content-Type".to_owned(), b"text/html".to_vec())],b"\x89PNG\r\n\x1A\nrest"));assert!(should_opaque_response_be_blocked_by_orb_with_body(- &[("Content-Type".to_owned(), "text/html".to_owned())],+ &[("Content-Type".to_owned(), b"text/html".to_vec())],b"<!doctype html><title>secret</title>"));}@@ -641,11 +644,11 @@ fn orb_body_sniffing_allows_mislabeled_images() {#[test]fn orb_body_sniffing_allows_mislabeled_javascript_but_blocks_json() {assert!(!should_opaque_response_be_blocked_by_orb_with_body(- &[("Content-Type".to_owned(), "application/json".to_owned())],+ &[("Content-Type".to_owned(), b"application/json".to_vec())],b"\"use strict\";\nfunction fn() { return 42; }"));assert!(should_opaque_response_be_blocked_by_orb_with_body(- &[("Content-Type".to_owned(), "application/json".to_owned())],+ &[("Content-Type".to_owned(), b"application/json".to_vec())],br#"{"hello":"world"}"#));}@@ -659,7 +662,7 @@ fn orb_body_sniffing_decodes_utf16_javascript_candidates() {assert!(!should_opaque_response_be_blocked_by_orb_with_body(&[("Content-Type".to_owned(),- "application/json; charset=utf-16".to_owned()+ b"application/json; charset=utf-16".to_vec())],&body));@@ -672,7 +675,7 @@ fn computes_response_mime_type_from_headers_and_body() {assert_eq!(image_without_type, "image/png");let explicit_script = computed_response_mime_type(- &[("Content-Type".to_owned(), "Text/JavaScript".to_owned())],+ &[("Content-Type".to_owned(), b"Text/JavaScript".to_vec())],MimeSniffingContext::Script,b"",);@@ -743,23 +746,23 @@ fn maps_known_url_path_mime_essences() {#[test]fn checks_script_response_mime_for_nosniff_strict_and_classic_rules() {- let html_nosniff = vec![- ("content-type".to_owned(), "text/html".to_owned()),- ("x-content-type-options".to_owned(), "nosniff".to_owned()),+ let html_nosniff: Vec<(String, Vec<u8>)> = vec![+ ("content-type".to_owned(), b"text/html".to_vec()),+ ("x-content-type-options".to_owned(), b"nosniff".to_vec()),];assert_eq!(check_script_response_mime(&html_nosniff, b"", FetchDestination::Script, false),Err(ScriptResponseMimeError::Nosniff));- let html = vec![("content-type".to_owned(), "text/html".to_owned())];+ let html: Vec<(String, Vec<u8>)> = vec![("content-type".to_owned(), b"text/html".to_vec())];assert_eq!(check_script_response_mime(&html, b"", FetchDestination::Script, true),Err(ScriptResponseMimeError::Unsupported("text/html".to_owned())));assert!(check_script_response_mime(&html, b"", FetchDestination::Script, false).is_ok());- let image = vec![("content-type".to_owned(), "image/png".to_owned())];+ let image: Vec<(String, Vec<u8>)> = vec![("content-type".to_owned(), b"image/png".to_vec())];assert_eq!(check_script_response_mime(&image, b"", FetchDestination::Script, false),Err(ScriptResponseMimeError::Unsupported("image/png".to_owned()))@@ -768,10 +771,10 @@ fn checks_script_response_mime_for_nosniff_strict_and_classic_rules() {#[test]fn script_like_mime_type_block_matches_fetch_response_rule() {- let image = vec![("content-type".to_owned(), "image/png".to_owned())];- let video = vec![("content-type".to_owned(), "video/mp4".to_owned())];- let csv = vec![("content-type".to_owned(), "text/csv".to_owned())];- let html = vec![("content-type".to_owned(), "text/html".to_owned())];+ let image: Vec<(String, Vec<u8>)> = vec![("content-type".to_owned(), b"image/png".to_vec())];+ let video: Vec<(String, Vec<u8>)> = vec![("content-type".to_owned(), b"video/mp4".to_vec())];+ let csv: Vec<(String, Vec<u8>)> = vec![("content-type".to_owned(), b"text/csv".to_vec())];+ let html: Vec<(String, Vec<u8>)> = vec![("content-type".to_owned(), b"text/html".to_vec())];assert!(should_script_like_response_be_blocked_due_to_mime_type(&imagediff --git a/moli/src/fetch_dump/dom.rs b/moli/src/fetch_dump/dom.rsindex 69bba7c3d..eb4cbab46 100644--- a/moli/src/fetch_dump/dom.rs+++ b/moli/src/fetch_dump/dom.rs@@ -54,7 +54,7 @@ pub(super) fn render_json_payload(final_url: &str,status: u16,title: Option<&str>,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirect_chain: &[moli_core::page::NavigationRedirect],html: &str,network: Option<Value>,@@ -71,7 +71,7 @@ pub(super) fn render_json_payload(pub(super) fn render_raw_json_payload(final_url: &str,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirect_chain: &[moli_core::page::NavigationRedirect],body: &[u8],) -> Result<String> {@@ -90,7 +90,7 @@ fn response_metadata(final_url: &str,status: u16,title: Option<&str>,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],redirect_chain: &[moli_core::page::NavigationRedirect],) -> Map<String, Value> {let mut payload = Map::new();@@ -110,11 +110,11 @@ fn response_metadata(payload}-fn render_headers(headers: &[(String, String)]) -> Value {+fn render_headers(headers: &[(String, Vec<u8>)]) -> Value {Value::Array(headers.iter()- .map(|(name, value)| json!({ "name": name, "value": value }))+ .map(|(name, value)| json!({ "name": name, "value": moli_fetch::decode_header_value(value) })).collect(),)}diff --git a/moli/src/network_trace.rs b/moli/src/network_trace.rsindex d754e6481..46cf35e66 100644--- a/moli/src/network_trace.rs+++ b/moli/src/network_trace.rs@@ -249,7 +249,7 @@ fn render_websocket_summary(pub(crate) fn render_http_error_network_trace(final_url: &url::Url,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body: &str,config: Option<&NetworkTraceConfigSummary>,) -> Value {@@ -300,7 +300,7 @@ fn render_main_document_trace_from_parts(requested_url: &url::Url,final_url: &url::Url,status: u16,- headers: &[(String, String)],+ headers: &[(String, Vec<u8>)],body: &str,redirected: bool,redirect_count: usize,@@ -417,7 +417,7 @@ fn render_success_response_diagnostics(request_url: &url::Url,final_url: &url::Url,status: u16,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],response_body: &str,redirect_count: usize,redirect_chain: &[NavigationRedirect],@@ -503,7 +503,8 @@ fn render_diagnostics_payload(Some(Value::Object(payload))}-fn auth_schemes(headers: &[(String, String)], name: &str) -> Vec<String> {+fn auth_schemes(headers: &[(String, Vec<u8>)], name: &str) -> Vec<String> {+ let headers = moli_fetch::headers_to_byte_strings(headers);let mut schemes = headers.iter().filter(|(header_name, _)| header_name.eq_ignore_ascii_case(name))@@ -519,7 +520,7 @@ fn auth_schemes(headers: &[(String, String)], name: &str) -> Vec<String> {fn gate_hint_reasons(request_url: &url::Url,final_url: &url::Url,- response_headers: &[(String, String)],+ response_headers: &[(String, Vec<u8>)],response_body: &str,redirect_chain: &[NavigationRedirect],body_mode: GateHintBodyMode,@@ -700,14 +701,17 @@ wherenames}-fn header_value<'a>(headers: &'a [(String, String)], name: &str) -> Option<&'a str> {+fn header_value<'a>(+ headers: &'a [(String, Vec<u8>)],+ name: &str,+) -> Option<std::borrow::Cow<'a, str>> {headers.iter().find(|(header_name, _)| header_name.eq_ignore_ascii_case(name))- .map(|(_, value)| value.as_str())+ .map(|(_, value)| moli_fetch::decode_header_value(value))}-fn json_response_summary(headers: &[(String, String)], body: &str) -> Option<Value> {+fn json_response_summary(headers: &[(String, Vec<u8>)], body: &str) -> Option<Value> {let content_type = header_value(headers, "content-type")?;if !content_type.split(';')@@ -761,7 +765,7 @@ fn clamp_diagnostic_string(text: &str) -> String {output}-fn json_response_error_like(headers: &[(String, String)], body: &str) -> bool {+fn json_response_error_like(headers: &[(String, Vec<u8>)], body: &str) -> bool {let Some(content_type) = header_value(headers, "content-type") else {return false;};@@ -873,7 +877,7 @@ mod tests {401,vec![("WWW-Authenticate".to_owned(),- "Basic realm=\"private\"".to_owned(),+ b"Basic realm=\"private\"".to_vec(),)],"auth required".to_owned(),Vec::new(),@@ -930,7 +934,7 @@ mod tests {Vec::new(),"wss://example.test/socket".parse()?,101,- vec![("sec-websocket-accept".to_owned(), "accept-token".to_owned())],+ vec![("sec-websocket-accept".to_owned(), b"accept-token".to_vec())],String::new(),Vec::new(),);@@ -1073,8 +1077,8 @@ mod tests {"http://login.example.test/security/baxia".parse()?,200,vec![- ("content-type".to_owned(), "application/json".to_owned()),- ("x-baxia-info".to_owned(), "challenge".to_owned()),+ ("content-type".to_owned(), b"application/json".to_vec()),+ ("x-baxia-info".to_owned(), b"challenge".to_vec()),],r#"{"success":false,"code":"AUTH_REQUIRED","message":"login required","ret":["FAIL_SYS_USER_VALIDATE"]}"#.to_owned(),Vec::new(),@@ -1110,7 +1114,7 @@ mod tests {&requested_url,&final_url,200,- &[("content-type".to_owned(), "text/html".to_owned())],+ &[("content-type".to_owned(), b"text/html".to_vec())],"<html><body>login keyword in body should not drive main document diagnostics</body></html>",true,1,@@ -1201,7 +1205,7 @@ mod tests {401,&[("www-authenticate".to_owned(),- "Bearer realm=\"api\"".to_owned(),+ b"Bearer realm=\"api\"".to_vec(),)],"unauthorized",Some(&config),