Skip to content

Commit eec04e6

Browse files
Fixes DevToolsPlugin failing on responses without a body. Closes #930 (#931)
1 parent 6f40ca3 commit eec04e6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

dev-proxy-plugins/Inspection/DevToolsPlugin.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ private string GetBrowserPath(DevToolsPluginConfiguration configuration)
112112

113113
private Process[] GetBrowserProcesses(string browserPath)
114114
{
115-
return Process.GetProcesses().Where(p => {
115+
return Process.GetProcesses().Where(p =>
116+
{
116117
try
117118
{
118119
return p.MainModule is not null && p.MainModule.FileName == browserPath;
@@ -290,15 +291,18 @@ private async Task AfterResponseAsync(object sender, ProxyResponseArgs e)
290291
Body = string.Empty,
291292
Base64Encoded = false
292293
};
293-
if (IsTextResponse(e.Session.HttpClient.Response.ContentType))
294-
{
295-
body.Body = e.Session.HttpClient.Response.BodyString;
296-
body.Base64Encoded = false;
297-
}
298-
else
294+
if (e.Session.HttpClient.Response.HasBody)
299295
{
300-
body.Body = Convert.ToBase64String(e.Session.HttpClient.Response.Body);
301-
body.Base64Encoded = true;
296+
if (IsTextResponse(e.Session.HttpClient.Response.ContentType))
297+
{
298+
body.Body = e.Session.HttpClient.Response.BodyString;
299+
body.Base64Encoded = false;
300+
}
301+
else
302+
{
303+
body.Body = Convert.ToBase64String(e.Session.HttpClient.Response.Body);
304+
body.Base64Encoded = true;
305+
}
302306
}
303307
responseBody.Add(e.Session.HttpClient.Request.GetHashCode().ToString(), body);
304308

0 commit comments

Comments
 (0)