From bf5d43c5417c0399e91eb8d2b88b5cb73445b8d9 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 4 Jun 2026 10:29:36 +0200 Subject: [PATCH] Implement XMLHttpRequest.overrideMimeType() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the overrideMimeType(mime) method. Wires the final MIME type (override ?? response) into responseXML for the default response type (""): when the final MIME is text/xml, the body is lazily parsed into a Document and cached in a new _response_xml field. Other XML MIME types (application/xml, image/svg+xml) land in Mime.ContentType.other whose backing slices are unsafe to read after Mime.parse returns; supporting them is left for a follow-up. The override does not affect response / responseText today — responseText charset decoding and the document responseType's HTML-vs-XML parser choice are noted as follow-ups in the code. --- src/browser/tests/net/xhr.html | 92 +++++++++++++++++++++++ src/browser/webapi/net/XMLHttpRequest.zig | 59 +++++++++++++-- 2 files changed, 145 insertions(+), 6 deletions(-) diff --git a/src/browser/tests/net/xhr.html b/src/browser/tests/net/xhr.html index b76dde85..44e1b8bd 100644 --- a/src/browser/tests/net/xhr.html +++ b/src/browser/tests/net/xhr.html @@ -306,6 +306,98 @@ } + +