fix content is null or ''

This commit is contained in:
jason 2024-12-30 19:15:30 +08:00
parent 083f2cee66
commit 85d4cf17bd

View file

@ -150,17 +150,20 @@ public class PlaywrightInstance : IDisposable
ResponseInMemory = args.ResponseInMemory
};
var html = await response.TextAsync();
if (response.Headers["content-type"].Contains("application/json"))
{
if (response.Status == 200 && response.Ok)
{
var json = await response.JsonAsync();
result.ResponseData = JsonSerializer.Serialize(json);
{
if (!string.IsNullOrWhiteSpace(html))
{
var json = await response.JsonAsync();
result.ResponseData = JsonSerializer.Serialize(json);
}
}
}
else
{
var html = await response.TextAsync();
result.ResponseData = html;
}