From e6c0a4efa0a546fd9a4914baaff879e5c5c0ee77 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Thu, 10 Feb 2022 21:05:35 -0600 Subject: [PATCH 1/2] Inspector wants the content-length set --- src/mono/wasm/debugger/BrowserDebugHost/Startup.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mono/wasm/debugger/BrowserDebugHost/Startup.cs b/src/mono/wasm/debugger/BrowserDebugHost/Startup.cs index c4de27f4ee9f6..ac64b32d5c119 100644 --- a/src/mono/wasm/debugger/BrowserDebugHost/Startup.cs +++ b/src/mono/wasm/debugger/BrowserDebugHost/Startup.cs @@ -139,7 +139,9 @@ async Task RewriteArray(HttpContext context) Dictionary[] tabs = await ProxyGetJsonAsync[]>(GetEndpoint(context)); Dictionary[] alteredTabs = tabs.Select(t => mapFunc(t, context, devToolsHost)).ToArray(); context.Response.ContentType = "application/json"; - await context.Response.WriteAsync(JsonSerializer.Serialize(alteredTabs)); + string text = JsonSerializer.Serialize(alteredTabs); + context.Response.ContentLength = text.Length; + await context.Response.WriteAsync(text); } async Task ConnectProxy(HttpContext context) From 1ed9c5682727d0682ee4eee58ee1302958e013ba Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Fri, 11 Feb 2022 22:21:58 -0600 Subject: [PATCH 2/2] Use utf8 length --- src/mono/wasm/debugger/BrowserDebugHost/Startup.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mono/wasm/debugger/BrowserDebugHost/Startup.cs b/src/mono/wasm/debugger/BrowserDebugHost/Startup.cs index ac64b32d5c119..8583186ad64fd 100644 --- a/src/mono/wasm/debugger/BrowserDebugHost/Startup.cs +++ b/src/mono/wasm/debugger/BrowserDebugHost/Startup.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Net.Http; using System.Text.Json; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -139,9 +140,9 @@ async Task RewriteArray(HttpContext context) Dictionary[] tabs = await ProxyGetJsonAsync[]>(GetEndpoint(context)); Dictionary[] alteredTabs = tabs.Select(t => mapFunc(t, context, devToolsHost)).ToArray(); context.Response.ContentType = "application/json"; - string text = JsonSerializer.Serialize(alteredTabs); - context.Response.ContentLength = text.Length; - await context.Response.WriteAsync(text); + byte[] bytes = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(alteredTabs)); + context.Response.ContentLength = bytes.Length; + await context.Response.Body.WriteAsync(bytes); } async Task ConnectProxy(HttpContext context)