Skip to content

Commit c38ca64

Browse files
PR feedback
1 parent c659d53 commit c38ca64

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/Components/Blazor/Server/src/MonoDebugProxy/BlazorMonoDebugProxyAppBuilderExtensions.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ private static void UseVisualStudioDebuggerConnectionRequestHandlers(this IAppli
6767
if (requestPath.StartsWithSegments("/json")
6868
&& !request.Headers.ContainsKey("User-Agent"))
6969
{
70+
var debuggerHost = "http://localhost:9222";
7071
if (requestPath.Equals("/json", StringComparison.OrdinalIgnoreCase) || requestPath.Equals("/json/list", StringComparison.OrdinalIgnoreCase))
7172
{
72-
var debuggerHost = "http://localhost:9222";
7373
var availableTabs = await GetOpenedBrowserTabs(debuggerHost);
7474

7575
// Filter the list to only include tabs displaying the requested app,
@@ -101,15 +101,10 @@ private static void UseVisualStudioDebuggerConnectionRequestHandlers(this IAppli
101101
}
102102
else if (requestPath.Equals("/json/version", StringComparison.OrdinalIgnoreCase))
103103
{
104+
var browserVersionJson = await GetBrowserVersionInfoAsync(debuggerHost);
105+
104106
context.Response.ContentType = "application/json";
105-
await context.Response.WriteAsync(JsonSerializer.Serialize(new Dictionary<string, string>
106-
{
107-
{ "Browser", "Chrome/71.0.3578.98" },
108-
{ "Protocol-Version", "1.3" },
109-
{ "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" },
110-
{ "V8-Version", "7.1.302.31" },
111-
{ "WebKit-Version", "537.36 (@15234034d19b85dcd9a03b164ae89d04145d8368)" },
112-
}));
107+
await context.Response.WriteAsync(browserVersionJson);
113108
}
114109
}
115110
else
@@ -263,6 +258,12 @@ private static string GetLaunchEdgeInstructions(string appRootUrl)
263258
}
264259
}
265260

261+
private static async Task<string> GetBrowserVersionInfoAsync(string debuggerHost)
262+
{
263+
using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
264+
return await httpClient.GetStringAsync($"{debuggerHost}/json/version");
265+
}
266+
266267
private static async Task<IEnumerable<BrowserTab>> GetOpenedBrowserTabs(string debuggerHost)
267268
{
268269
using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };

0 commit comments

Comments
 (0)