mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-20 16:15:47 +08:00
导出格式优化
This commit is contained in:
@@ -222,7 +222,7 @@ class HttpChannelHandler extends ChannelHandler<HttpRequest> {
|
||||
/// 异常处理
|
||||
_exceptionHandler(Channel channel, HttpRequest? request, error) {
|
||||
HostAndPort? hostAndPort = channel.getAttribute(AttributeKeys.host);
|
||||
hostAndPort ??= HostAndPort.host(channel.remoteAddress.host, channel.remotePort);
|
||||
hostAndPort ??= HostAndPort.host(scheme:HostAndPort.httpScheme, channel.remoteAddress.host, channel.remotePort);
|
||||
String message = error.toString();
|
||||
HttpStatus status = HttpStatus(-1, message);
|
||||
if (error is HandshakeException) {
|
||||
|
||||
@@ -38,6 +38,7 @@ class FavoriteStorage {
|
||||
return file;
|
||||
}
|
||||
|
||||
/// 添加收藏
|
||||
static Future<void> addFavorite(HttpRequest request) async {
|
||||
var favorites = await FavoriteStorage.favorites;
|
||||
if (favorites.contains(request)) {
|
||||
|
||||
@@ -88,12 +88,12 @@ Widget contextMenu(BuildContext context, EditableTextState editableTextState) {
|
||||
)
|
||||
];
|
||||
if (Platform.isIOS) {
|
||||
list.add(ContextMenuButtonItem(
|
||||
onPressed: () async {
|
||||
editableTextState.shareSelection(SelectionChangedCause.toolbar);
|
||||
},
|
||||
type: ContextMenuButtonType.share,
|
||||
));
|
||||
// list.add(ContextMenuButtonItem(
|
||||
// onPressed: () async {
|
||||
// editableTextState.shareSelection(SelectionChangedCause.toolbar);
|
||||
// },
|
||||
// type: ContextMenuButtonType.share,
|
||||
// ));
|
||||
}
|
||||
|
||||
return AdaptiveTextSelectionToolbar.buttonItems(
|
||||
|
||||
@@ -87,6 +87,7 @@ class NetworkTabState extends State<NetworkTabController> with SingleTickerProvi
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(left: 20, right: 20, top: 10),
|
||||
child: TabBarView(
|
||||
physics: const NeverScrollableScrollPhysics(), //禁止滑动
|
||||
controller: _tabController,
|
||||
children: [
|
||||
general(),
|
||||
|
||||
@@ -129,6 +129,7 @@ class _FavoriteItemState extends State<_FavoriteItem> {
|
||||
requestEdit();
|
||||
});
|
||||
}),
|
||||
const PopupMenuDivider(height: 0.3),
|
||||
popupItem("删除收藏", onTap: () {
|
||||
widget.onRemove?.call(widget.request);
|
||||
})
|
||||
|
||||
@@ -257,7 +257,8 @@ class _HistoryState extends State<_HistoryWidget> {
|
||||
//获取请求
|
||||
List<HttpRequest> requests = await storage.getRequests(item);
|
||||
var file = await File(result.path).create();
|
||||
Har.writeFile(requests, file, title: item.name);
|
||||
await Har.writeFile(requests, file, title: item.name);
|
||||
if (context.mounted) FlutterToastr.show("导出成功", context);
|
||||
Future.delayed(const Duration(seconds: 30), () => item.requests = null);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,19 +127,19 @@ class SearchConditionsState extends State<SearchConditions> {
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('取消')),
|
||||
child: const Text('取消', style: TextStyle(fontSize: 14))),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
widget.onSearch?.call(SearchModel());
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('清除搜索')),
|
||||
child: const Text('清除搜索', style: TextStyle(fontSize: 14))),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
widget.onSearch?.call(searchModel);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('确定')),
|
||||
child: const Text('确定', style: TextStyle(fontSize: 14))),
|
||||
],
|
||||
)
|
||||
],
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:network_proxy/network/host_port.dart';
|
||||
import 'package:network_proxy/network/http/http.dart';
|
||||
import 'package:network_proxy/network/http/http_headers.dart';
|
||||
|
||||
class Har {
|
||||
static int maxBodyLength = 1024 * 1024 * 4;
|
||||
@@ -37,6 +38,10 @@ class Har {
|
||||
'serverIPAddress': request.response?.remoteAddress
|
||||
};
|
||||
|
||||
//body已经解码 删除编码
|
||||
if (request.response?.headers.contentEncoding == 'br') {
|
||||
request.response?.headers.remove(HttpHeaders.CONTENT_ENCODING);
|
||||
}
|
||||
har['response'] = {
|
||||
"status": request.response?.status.code ?? 0, // 响应状态码
|
||||
"statusText": request.response?.status.reasonPhrase ?? '', // 响应状态码描述
|
||||
@@ -141,7 +146,7 @@ class Har {
|
||||
return {
|
||||
"mimeType": request.headers.contentType, // 请求体类型
|
||||
"text": request.bodyAsString, // 请求体内容
|
||||
"params": request.bodyAsString, // 请求体内容
|
||||
"params": [], // 请求体内容
|
||||
};
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user