fix import har

This commit is contained in:
wanghongenpin
2025-01-24 20:02:26 +08:00
parent 22c801ca36
commit 67e48d14ea
3 changed files with 9 additions and 5 deletions

View File

@@ -342,7 +342,11 @@ class HttpStatus {
/// 504 Gateway Timeout
static final HttpStatus gatewayTimeout = newStatus(504, "Gateway Timeout");
static HttpStatus newStatus(int statusCode, String reasonPhrase) {
static HttpStatus newStatus(int statusCode, String? reasonPhrase) {
if (reasonPhrase == null) {
return HttpStatus.valueOf(statusCode);
}
return HttpStatus(statusCode, reasonPhrase);
}

View File

@@ -163,9 +163,9 @@ class HistoryStorage {
var json = jsonDecode(readAsBytes);
var log = json['log'];
String name = formatDate(DateTime.now(), [mm, '-', d, ' ', HH, ':', nn, ':', ss]);
List? pages = log['pages'] as List;
if (pages.isNotEmpty) {
name = pages.first['title'];
List? pages = log['pages'] as List?;
if (pages?.isNotEmpty == true) {
name = pages?.first['title'];
}
//解析请求

View File

@@ -136,7 +136,7 @@ class Har {
List headers = request['headers'];
var httpRequest = HttpRequest(HttpMethod.valueOf(method), request['url'], protocolVersion: request['httpVersion']);
if (har.containsKey("_id")) httpRequest.requestId = har['_id']; // 页面标识
if (har.containsKey("_id")) httpRequest.requestId = har['_id'].toString(); // 页面标识
httpRequest.processInfo = har['_app'] == null ? null : ProcessInfo.fromJson(har['_app']);
httpRequest.body = request['postData']?['text']?.toString().codeUnits;
for (var element in headers) {