mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-20 16:15:47 +08:00
安卓抓flutter请求
This commit is contained in:
@@ -23,7 +23,7 @@ class MobileHistory extends StatefulWidget {
|
||||
final ProxyServer proxyServer;
|
||||
final GlobalKey<RequestListState> requestStateKey;
|
||||
|
||||
const MobileHistory({Key? key, required this.proxyServer, required this.requestStateKey}) : super(key: key);
|
||||
const MobileHistory({super.key, required this.proxyServer, required this.requestStateKey});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -92,7 +92,7 @@ class _MobileHistoryState extends State<MobileHistory> {
|
||||
|
||||
//导入har
|
||||
import(HistoryStorage storage) async {
|
||||
const XTypeGroup typeGroup = XTypeGroup(label: 'Har', extensions: <String>['har']);
|
||||
const XTypeGroup typeGroup = XTypeGroup(label: 'har', extensions: <String>['har'], uniformTypeIdentifiers: ["public.item"]);
|
||||
final XFile? file = await openFile(acceptedTypeGroups: <XTypeGroup>[typeGroup]);
|
||||
if (file == null) {
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_toastr/flutter_toastr.dart';
|
||||
import 'package:network_proxy/native/vpn.dart';
|
||||
import 'package:network_proxy/network/bin/server.dart';
|
||||
import 'package:network_proxy/network/host_port.dart';
|
||||
import 'package:network_proxy/network/http/http.dart';
|
||||
@@ -123,11 +124,12 @@ class RequestEditorState extends State<MobileRequestEditor> with SingleTickerPro
|
||||
var headers = requestKey.currentState?.getHeaders();
|
||||
var requestBody = requestKey.currentState?.getBody();
|
||||
|
||||
HttpRequest request = HttpRequest(HttpMethod.valueOf(currentState.requestMethod), Uri.encodeFull(currentState.requestUrl));
|
||||
HttpRequest request =
|
||||
HttpRequest(HttpMethod.valueOf(currentState.requestMethod), Uri.encodeFull(currentState.requestUrl));
|
||||
request.headers.addAll(headers);
|
||||
request.body = requestBody == null ? null : utf8.encode(requestBody);
|
||||
|
||||
var proxyInfo = widget.proxyServer?.isRunning == true ? ProxyInfo.of("127.0.0.1", widget.proxyServer!.port) : null;
|
||||
var proxyInfo = Vpn.isVpnStarted ? ProxyInfo.of("127.0.0.1", widget.proxyServer!.port) : null;
|
||||
HttpClients.proxyRequest(proxyInfo: proxyInfo, request).then((response) {
|
||||
FlutterToastr.show('请求成功', context);
|
||||
this.response = response;
|
||||
|
||||
Reference in New Issue
Block a user