美文网首页
flutter dio 抓包

flutter dio 抓包

作者: jianshufei | 来源:发表于2022-11-23 16:44 被阅读0次

    flutter dio 抓包

    1、第一种

    写一个页面,输入ip地址和端口号,传给dio设置里

    (_dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) {
            client.idleTimeout = const Duration(seconds: 5);
            client.findProxy = (uri) {
              return "PROXY ${ip地址}:${端口号}";
            };
            //代理工具会提供一个抓包的自签名证书,会通不过证书校验,所以我们禁用证书校验
            client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
            return null;
          }
    

    2、第二种

    引入http_proxy: ^1.2.0第三方库,可获取代理信息

    HttpProxy proxy = await HttpProxy.createHttpProxy();
        debugPrint("PROXY=${proxy.host}");
        if (proxy.host != null) {
          (_dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) {
            client.idleTimeout = const Duration(seconds: 5);
            client.findProxy = (uri) {
              return "PROXY ${proxy.host}:${proxy.port}";
            };
            //代理工具会提供一个抓包的自签名证书,会通不过证书校验,所以我们禁用证书校验
            client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
            return null;
          };
        }
    

    相关文章

      网友评论

          本文标题:flutter dio 抓包

          本文链接:https://www.haomeiwen.com/subject/zibzxdtx.html