Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixes DevToolsPlugin failing on responses without a body. Closes #930 #931

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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