Flutter 使用 Charles进行抓包

2020-05-22  本文已影响0人  Harely

Charles 抓取Flutter网络请求

  不知怎么回事,Charles抓取原生网络请求轻而易举,但是在Flutter就是不行。后来在网上搜了下,知道了大概是不走代理造成的,经过多番尝试终于可以了。

$ nslookup localhost

//输出:
Server:     192.168.0.1
Address:    192.168.0.1#53

Name:   localhost//这就是我们要的localhost
Address: 127.0.0.1
RaisedButton(onPressed: () async {
          var dio = Dio();
          dio.options.contentType = "text";
          (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
              (HttpClient client) {
            client.findProxy = (uri) {
              //proxy all request to localhost:8888
              return "PROXY 127.0.0.1:8888";
            };
            client.badCertificateCallback =
                (X509Certificate cert, String host, int port) => true;
          };
          
          Response<String> response;
          response = await dio.get("http://www.test1111/blog");
          print(response.data);       
          
        },
      child: Text('Charles: Stream'),
   ),
选取当地映射 选取自己的json文件
上一篇下一篇

猜你喜欢

热点阅读