Skip to content

Commit

Permalink
Fixes DevToolsPlugin failing on responses without a body. Closes micr…
Browse files Browse the repository at this point in the history
  • Loading branch information
waldekmastykarz authored Nov 5, 2024
1 parent 6f40ca3 commit eec04e6
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions dev-proxy-plugins/Inspection/DevToolsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ private string GetBrowserPath(DevToolsPluginConfiguration configuration)

private Process[] GetBrowserProcesses(string browserPath)
{
return Process.GetProcesses().Where(p => {
return Process.GetProcesses().Where(p =>
{
try
{
return p.MainModule is not null && p.MainModule.FileName == browserPath;
Expand Down Expand Up @@ -290,15 +291,18 @@ private async Task AfterResponseAsync(object sender, ProxyResponseArgs e)
Body = string.Empty,
Base64Encoded = false
};
if (IsTextResponse(e.Session.HttpClient.Response.ContentType))
{
body.Body = e.Session.HttpClient.Response.BodyString;
body.Base64Encoded = false;
}
else
if (e.Session.HttpClient.Response.HasBody)
{
body.Body = Convert.ToBase64String(e.Session.HttpClient.Response.Body);
body.Base64Encoded = true;
if (IsTextResponse(e.Session.HttpClient.Response.ContentType))
{
body.Body = e.Session.HttpClient.Response.BodyString;
body.Base64Encoded = false;
}
else
{
body.Body = Convert.ToBase64String(e.Session.HttpClient.Response.Body);
body.Base64Encoded = true;
}
}
responseBody.Add(e.Session.HttpClient.Request.GetHashCode().ToString(), body);

Expand Down

0 comments on commit eec04e6

Please sign in to comment.