Future fetch()

Asynchronously grabs proxy URL's.

Source

Future fetch() async {
  var client = new http.Client();

  for (String url in urls) {
    var file = new File(url), proxyStream = new ProxyStream();
    if (await file.exists()) {
      await for (ProxyDef proxyDef in file.openRead().transform(proxyStream)) {
        _stream.add(proxyDef);
      }
    } else {
      var response = await client.get(url);
      var _ctrl = new StreamController<List<int>>();
      _ctrl
        ..add(response.bodyBytes)
        ..close();
      await _stream.addStream(_ctrl.stream.transform(proxyStream));
    }
  }

  _stream.close();
  client.close();
}